RemKhepServerROSController.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
00026
00031
00032 #ifndef __REM_KHEP_SRV_ROS_CTRL_H_
00033 #define __REM_KHEP_SRV_ROS_CTRL_H_
00034
00035
00036 #include <CommonOptions.h>
00037 #include <Option.h>
00038 #include "RemKhepServerROS.h"
00039
00040 #ifdef ROS_ELECTRIC
00041
00042 #include <geometry_msgs/Twist.h>
00043 #include <nav_msgs/Odometry.h>
00044 #include <ros/ros.h>
00045 #include <tf/transform_broadcaster.h>
00046
00047 #include <gazebo/Simulator.hh>
00048 #include <gazebo/Global.hh>
00049 #include <gazebo/Controller.hh>
00050 #include <gazebo/ControllerFactory.hh>
00051 #include <gazebo/Model.hh>
00052
00053
00054 #include <ros/callback_queue.h>
00055 #include <ros/advertise_options.h>
00056 #endif
00057
00058 #include <boost/thread.hpp>
00059
00060
00061 #define SAMPLE_TIME_USEC 30000
00062 #define WAIT_TIME_USEC 1000
00063
00064 #define KHS_COMM_DEBUG 0
00065 #define KHS_TIME_DEBUG 0
00066 #define KHS_EXECUTE_DEBUG 0
00067
00068 namespace gazebo{
00069 class Joint;
00070 class Entity;
00071
00072 class remKhepSrvROSController : public gazebo::Controller{
00073 public:
00074 remKhepSrvROSController(Entity *parent);
00075 virtual ~remKhepSrvROSController();
00076
00077 protected:
00078 virtual void LoadChild(XMLConfigNode *node);
00079 void SaveChild(std::string &prefix, std::ostream &stream);
00080 virtual void InitChild();
00081 void ResetChild();
00082 virtual void UpdateChild();
00083 virtual void FiniChild();
00084
00085 private:
00086
00087 void write_position_data();
00088 void publish_odometry();
00089
00090
00091 Model *parent_;
00092 ParamT<float>* wheelSepP;
00093 ParamT<float>* wheelDiamP;
00094 ParamT<float>* torqueP;
00095 ParamT<bool>* enableMotors;
00096 ParamT<int>* debugLevel;
00097 ParamT<int>* urg04lxActive;
00098 ParamT<string>* intMethodOdo;
00099 ParamT<string>* laserTopicName;
00100 ParamT<string>* topicName;
00101 ParamT<string>* nodeName;
00102 ParamT<string>* commType;
00103 ParamT<Decimal>* encodRes;
00104 float wheelSpeed[2];
00105
00106
00107
00108 KheperaServerROSPars* _khPars;
00109
00110
00111
00112
00113
00114 Time _execTimer;
00115
00116
00117 KheperaServerROS* _remKhepSrvROS;
00118
00119
00120 bool _firstRun;
00121
00122 bool _connected;
00123
00124 int _actCmd;
00125
00126 bool _enableMotors;
00127
00128 int _debugLevel;
00129
00130 Joint *joints[2];
00131 PhysicsEngine *physicsEngine;
00132 ParamT<std::string> *leftJointNameP;
00133 ParamT<std::string> *rightJointNameP;
00134
00135
00136 Decimal wd;
00137
00138 Decimal ws;
00139
00140 double d1;
00141 double d2;
00142 double dr;
00143 double da;
00144
00145 Time stepTime;
00146
00147
00148
00149 ros::Publisher pub_;
00150 ros::Subscriber sub_;
00151
00152 std::string tf_prefix_;
00153
00154 boost::mutex lock;
00155
00156 ParamT<std::string> *robotNamespaceP;
00157 std::string robotNamespace;
00158
00159
00160
00161 std::string topicNameOdom;
00162
00163
00164 ros::CallbackQueue queue_;
00165 boost::thread* callback_queue_thread_;
00166 tf::TransformBroadcaster br;
00167
00168 void QueueThread();
00169
00170
00171 void cmdVelCallback(const geometry_msgs::Twist::ConstPtr& cmd_msg);
00172
00173 Decimal _xVel;
00174 Decimal _omega;
00175 bool alive_;
00176 };
00177
00178 }
00179
00180 #endif
00181