ROSNode.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno    
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00029 
00033 
00034 #ifndef ROS_NODE_H
00035 #define ROS_NODE_H
00036 
00037 // #include "includeROS.h"
00038 // #include "std_msgs/String.h"
00039 #include <sstream>
00040 #include <typeinfo>
00041 #include "resources.h"
00042 
00043 // #include "ROSiFace.h"
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 

Generated on Mon Feb 20 07:01:07 2017 for MIP by  doxygen 1.5.6