localizing_jockey.cpp
Go to the documentation of this file.
00001 #include <lama_jockeys/localizing_jockey.h>
00002 
00003 namespace lama_jockeys
00004 {
00005 
00006 LocalizingJockey::LocalizingJockey(const std::string& name) :
00007   Jockey(name),
00008   server_(nh_, name, boost::bind(&LocalizingJockey::goalCallback, this, _1), false)
00009 {
00010   server_.registerPreemptCallback(boost::bind(&LocalizingJockey::preemptCallback, this));
00011 
00012   server_.start();
00013   ROS_DEBUG("Action server '%s' started for Localization", jockey_name_.c_str());
00014 }
00015 
00016 void LocalizingJockey::goalCallback(const lama_jockeys::LocalizeGoalConstPtr& goal)
00017 {
00018   goal_.action = goal->action;
00019 
00020   // Check that preempt has not been requested by the client.
00021   if (server_.isPreemptRequested() || !ros::ok())
00022   {
00023     ROS_INFO_STREAM(jockey_name_ << ": Preempted");
00024     // set the action state to preempted
00025     server_.setPreempted();
00026     return;
00027   }
00028 
00029   switch (goal_.action)
00030   {
00031     case lama_jockeys::LocalizeGoal::GET_VERTEX_DESCRIPTOR:
00032       ROS_DEBUG("Received action GET_VERTEX_DESCRIPTOR");
00033       initAction();
00034       goal_.descriptor_link = goal->descriptor_link;
00035       onGetVertexDescriptor();
00036       break;
00037     case lama_jockeys::LocalizeGoal::GET_EDGES_DESCRIPTORS:
00038       ROS_DEBUG("Received action GET_EDGES_DESCRIPTORS");
00039       initAction();
00040       goal_.descriptor_link = goal->descriptor_link;
00041       onGetEdgesDescriptors();
00042       break;
00043     case lama_jockeys::LocalizeGoal::LOCALIZE_IN_VERTEX:
00044       ROS_DEBUG("Received action LOCALIZE_IN_VERTEX");
00045       initAction();
00046       goal_.descriptor_link = goal->descriptor_link;
00047       onLocalizeInVertex();
00048       break;
00049     case lama_jockeys::LocalizeGoal::LOCALIZE_EDGE:
00050       ROS_DEBUG("Received action LOCALIZE_EDGE");
00051       initAction();
00052       goal_.descriptor_link = goal->descriptor_link;
00053       onLocalizeEdge();
00054       break;
00055     case lama_jockeys::LocalizeGoal::GET_DISSIMILARITY:
00056       ROS_DEBUG("Received action GET_DISSIMILARITY");
00057       initAction();
00058       goal_.descriptor_link = goal->descriptor_link;
00059       onGetDissimilarity();
00060       break;
00061     case lama_jockeys::LocalizeGoal::INTERRUPT:
00062       ROS_DEBUG("Received action INTERRUPT");
00063       interrupt();
00064       onInterrupt();
00065       break;
00066     case lama_jockeys::LocalizeGoal::CONTINUE:
00067       ROS_DEBUG("Received action CONTINUE");
00068       resume();
00069       onContinue();
00070       break;
00071   }
00072 }
00073 
00074 void LocalizingJockey::preemptCallback()
00075 {
00076   ROS_INFO_STREAM(jockey_name_ << ": Preempted");
00077   // set the action state to preempted
00078   server_.setPreempted();
00079 }
00080 
00081 void LocalizingJockey::initAction()
00082 {
00083   Jockey::initAction();
00084   result_ = LocalizeResult();
00085 }
00086 
00087 void LocalizingJockey::onGetVertexDescriptor()
00088 {
00089   ROS_DEBUG("%s: onGetVertexDescriptor not supported", jockey_name_.c_str());
00090   result_.state = lama_jockeys::LocalizeResult::NOT_SUPPORTED;
00091   result_.completion_time = ros::Duration(0.0);
00092   server_.setSucceeded(result_);
00093 }
00094 
00095 void LocalizingJockey::onGetEdgesDescriptors()
00096 {
00097   ROS_DEBUG("%s: onGetEdgesDescriptors not supported", jockey_name_.c_str());
00098   result_.state = lama_jockeys::LocalizeResult::NOT_SUPPORTED;
00099   result_.completion_time = ros::Duration(0.0);
00100   server_.setSucceeded(result_);
00101 }
00102 
00103 void LocalizingJockey::onLocalizeInVertex()
00104 {
00105   ROS_DEBUG("%s: onLocalizeInVertex not supported", jockey_name_.c_str());
00106   result_.state = lama_jockeys::LocalizeResult::NOT_SUPPORTED;
00107   result_.completion_time = ros::Duration(0.0);
00108   server_.setSucceeded(result_);
00109 }
00110 
00111 void LocalizingJockey::onLocalizeEdge()
00112 {
00113   ROS_DEBUG("%s: onLocalizeEdge not supported", jockey_name_.c_str());
00114   result_.state = lama_jockeys::LocalizeResult::NOT_SUPPORTED;
00115   result_.completion_time = ros::Duration(0.0);
00116   server_.setSucceeded(result_);
00117 }
00118 
00119 void LocalizingJockey::onGetDissimilarity()
00120 {
00121   ROS_DEBUG("%s: onGetDissimilarity not supported", jockey_name_.c_str());
00122   result_.state = lama_jockeys::LocalizeResult::NOT_SUPPORTED;
00123   result_.completion_time = ros::Duration(0.0);
00124   server_.setSucceeded(result_);
00125 }
00126 
00127 void LocalizingJockey::onInterrupt()
00128 {
00129   ROS_DEBUG("%s: localizing goal with lama object %d interrupted", jockey_name_.c_str(), goal_.descriptor_link.object_id);
00130 }
00131 
00132 void LocalizingJockey::onContinue()
00133 {
00134   ROS_DEBUG("%s: localizing goal with lama object %d resumed", jockey_name_.c_str(), goal_.descriptor_link.object_id);
00135 }
00136 
00137 } // namespace lama_jockeys
00138 


jockeys
Author(s): Gaël Ecorchard , Karel Košnar
autogenerated on Sat Jun 8 2019 19:03:15