ROSNode.h
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
00020
00021
00022
00023
00024
00025
00029
00033
00034 #ifndef ROS_NODE_H
00035 #define ROS_NODE_H
00036
00037
00038
00039 #include <sstream>
00040 #include <typeinfo>
00041 #include "resources.h"
00042
00043
00044 #include "ROSiFace.h"
00045
00046 using namespace MipResources;
00047
00048 namespace MipResources{
00050
00051
00052
00053
00057 enum ROSiFaceMessageTypes{
00059 ROSIFACE_TYPE_NAV_MSGS_ODOMETRY,
00061 ROSIFACE_TYPE_STD_MSGS_HEADER,
00063 ROSIFACE_TYPE_STD_MSGS_INT32,
00065 ROSIFACE_TYPE_GEOMETRY_MSGS_POINT,
00067 ROSIFACE_TYPE_GEOMETRY_MSGS_POINTSTAMPED,
00069 ROSIFACE_TYPE_STD_STRING,
00071 ROSIFACE_TYPE_SENSOR_IMU,
00073 ROSIFACE_TYPE_GEOMETRY_VECTOR3STAMPED,
00075 ROSIFACE_TYPE_GEOMETRY_MSGS_TWIST,
00077 ROSIFACE_TYPE_SENSOR_LASERSCAN,
00079 ROSIFACE_TYPE_SENSOR_RANGE,
00081 ROSIFACE_TYPE_SENSOR_IMAGE,
00083 ROSIFACE_TYPE_SENSOR_CAMERAINFO
00084 };
00085
00086
00090 class ROSNodeOptions : public Options {
00091 public:
00092 ROSNodeOptions();
00093
00094 string getObjectName() const {
00095 return "ROSNodeOptions";
00096 }
00097
00098 OptionGroupsType getGroup();
00099 };
00100
00101
00102
00111 class ROSNode : public Resource{
00112 protected:
00113 ROSNodeOptions _options;
00114
00115 private:
00116 static const ResourcePlate _plate = ROS_NODE_RES;
00117
00118 public:
00119
00121 ResourcePlate getPlate() const {
00122 return _plate;
00123 }
00124
00129 ROSNode(const string& nodeName);
00130
00135 ROSNode(int argc, const char* argv[]);
00136
00139 ~ROSNode();
00140
00151 int openTopic(const string& topicname, ROSiFaceOpeningModes mode, int queueLength=1, int bufferLength=1, ROSiFaceMessageTypes ty=ROSIFACE_TYPE_STD_STRING);
00152
00158 bool updateTopic(int topicSpecifier);
00159
00160
00167 bool getTopicMessage(int topicSpecifier, string &msg);
00168
00175 bool getUpdateTopicMessage(int topicSpecifier, string &msg);
00176
00183 bool writeTopic(int topicSpecifier, const string &msg);
00184
00188 void getTopicMessages(int topicSpecifier, deque<string> &msg);
00189
00193 void getUpdateTopicMessages(int topicSpecifier, deque<string> &msg);
00194
00195
00196
00197
00198 # include <include_std_msgs_String.h>
00199
00200 # include <include_sensor_msgs_Imu.h>
00201
00202 # include <include_geometry_msgs_Vector3Stamped.h>
00203
00204 # include <include_sensor_msgs_LaserScan.h>
00205
00206 #ifdef ROS_FUERTE
00207 # include <include_sensor_msgs_Range.h>
00208 #endif
00209
00210 # include <include_sensor_msgs_Image.h>
00211
00212 # include <include_sensor_msgs_CameraInfo.h>
00213
00214 #include <include_geometry_msgs_Twist.h>
00215 #include <include_geometry_msgs_PointStamped.h>
00216 #include <include_geometry_msgs_Point.h>
00217 #include <include_std_msgs_Int32.h>
00218 #include <include_std_msgs_Header.h>
00219 #include <include_nav_msgs_Odometry.h>
00220
00224 ros::NodeHandle* getROSNode();
00225
00228 int getOpenTopicsNum() const;
00229
00230 private:
00231 ros::NodeHandle* _node;
00232 vector<ROSiFaceBoss*> _openTopics;
00233 vector<ROSiFaceMessageTypes> _openTopicsType;
00234 };
00235
00236 }
00237 #endif // ROS_NODE_H
00238