00001 /* Base class for learning jockeys 00002 */ 00003 00004 #ifndef _LAMA_JOCKEYS_LEARNING_JOCKEY_H_ 00005 #define _LAMA_JOCKEYS_LEARNING_JOCKEY_H_ 00006 00007 #include <string> 00008 00009 #include <ros/ros.h> 00010 #include <actionlib/server/simple_action_server.h> 00011 00012 #include <lama_jockeys/jockey.h> 00013 #include <lama_jockeys/LearnAction.h> 00014 #include <lama_jockeys/LearnGoal.h> 00015 #include <lama_jockeys/LearnFeedback.h> 00016 00017 namespace lama_jockeys 00018 { 00019 00020 typedef actionlib::SimpleActionServer<lama_jockeys::LearnAction> LearnServer; 00021 00022 class LearningJockey : public Jockey 00023 { 00024 protected: 00025 00026 LearningJockey(const std::string& name); 00027 00028 virtual void onLearn() = 0; 00029 virtual void onStop() = 0; 00030 virtual void onInterrupt(); 00031 virtual void onContinue(); 00032 00033 void initAction(); 00034 00035 // NodeHandle instance must be created before this line. Otherwise strange 00036 // error may occur (this is done in Jockey). 00037 LearnServer server_; 00038 LearnResult result_; 00039 LearnFeedback feedback_; 00040 00041 // In case of INTERRUPT and CONTINUE, the attributes of current goal 00042 // are irrelevant. 00043 // This information needs to be saved for use after a CONTINUE action. 00044 LearnGoal goal_; 00045 00046 private: 00047 00048 void goalCallback(); 00049 void preemptCallback(); 00050 00051 // Change the visibility to avoid double calls. 00052 using Jockey::interrupt; 00053 using Jockey::resume; 00054 }; 00055 00056 } // namespace lama_jockeys 00057 00058 #endif // _LAMA_JOCKEYS_LEARNING_JOCKEY_H_