Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef USE_YARP_COMM
00020
00021 #ifndef ROSCOMM_H
00022 #define ROSCOMM_H
00023
00024 #include "RelPose.h"
00025 #include "VisFinder.h"
00026 #include "PerceptionPrimitive.h"
00027 #include "Comm.h"
00028
00029
00030 #include <map>
00031
00032 #include <vision_srvs/cop_call.h>
00033 #include <vision_srvs/cop_save.h>
00034 #include <vision_msgs/cop_answer.h>
00035 #include <vision_msgs/cop_feedback.h>
00036 #include <vision_msgs/cop_status.h>
00037 #include <vision_srvs/cop_get_methods_list.h>
00038 #include <std_msgs/String.h>
00039 #include <ros/ros.h>
00040
00041 #define STD_COP_OUTPUT_PORT "/tracking/out"
00042 #ifdef BOOST_THREAD
00043 #include <boost/thread.hpp>
00044 #include <boost/bind.hpp>
00045 using namespace boost;
00046 #endif
00047
00048
00049 namespace cop
00050 {
00051
00052
00053
00054
00055
00056 class ROSComm : public Comm
00057 {
00058 public:
00059 ROSComm(VisFinder* visFinder, PossibleLocations_t* pose, PerceptionPrimitive& vis, ros::Publisher * pub,
00060 int numOfObjects, int actionType, std::string callerid, std::map<std::string, std::vector<std::string> > &callerids) :
00061 m_visFinder(visFinder),
00062 m_pose(pose),
00063 m_visPrim(vis),
00064 m_publisher(pub),
00065 m_numOfObjects(numOfObjects),
00066 m_actionType(actionType),
00067 m_callerid(callerid),
00068 m_calleridMap(callerids)
00069 {
00070 }
00071
00072 ~ROSComm();
00073
00074
00075
00076
00077
00078
00079
00080 virtual void NotifyPoseUpdate(RelPose* pose, bool sendObjectRelation = true);
00081
00082
00083
00084
00085
00086
00087
00088 virtual void NotifyNewObject(Signature* sig, RelPose* pose);
00089
00090
00091
00092
00093
00094
00095
00096 void Start();
00097 private:
00098
00099
00100
00101
00102
00103 void ProcessCall();
00104
00105
00106
00107
00108
00109
00110
00111 void PublishAnswer(vision_msgs::cop_answer &answer);
00112
00113
00114 VisFinder* m_visFinder;
00115 PossibleLocations_t* m_pose;
00116 PerceptionPrimitive& m_visPrim;
00117 ros::Publisher* m_publisher;
00118 int m_numOfObjects;
00119 int m_actionType;
00120 std::string m_callerid;
00121 std::map<std::string, std::vector<std::string> > &m_calleridMap;
00122 };
00123
00124 class ROSTopicManager
00125 {
00126 public:
00127 ROSTopicManager(VisFinder* s_visFinder, SignatureDB *s_sigDb);
00128 ~ROSTopicManager();
00129
00130 void CloseROSTopic(std::string name);
00131
00132 void Listen(std::string name, volatile bool &g_stopall, ros::NodeHandle* node);
00133 bool ListenCallBack(vision_srvs::cop_call::Request& request, vision_srvs::cop_call::Response& answer);
00134
00135 bool SaveCallBack(vision_srvs::cop_save::Request& msg, vision_srvs::cop_save::Response& answer);
00136 bool ListProgramCallBack(vision_srvs::cop_get_methods_list::Request& msg, vision_srvs::cop_get_methods_list::Response& answer);
00137
00138 void NewSignatureCallBack(std_msgs::String::ConstPtr xmlFilename);
00139 void FeedbackCallBack(vision_msgs::cop_feedback::ConstPtr feedback);
00140
00141 void StatusThread();
00142
00143
00144 bool OpenCommOnROSTopic(std::string st);
00145
00146 void Subscriber(const ros::SingleSubscriberPublisher& subs);
00147
00148
00149 std::map<std::string, ros::Publisher*> m_openTopics;
00150
00151 ros::Publisher m_statusPublisher;
00152
00153 VisFinder* m_visFinder;
00154 SignatureDB* m_sig;
00155 std::map<std::string, std::vector<std::string> > m_subscriberPerTopics;
00156 };
00157 }
00158 #endif
00159
00160 #endif