teo_plugin.h
Go to the documentation of this file.
00001 /*
00002  *  Gazebo - Outdoor Multi-Robot Simulator
00003  *  Copyright (C) 2003  
00004  *     Nate Koenig & Andrew Howard
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 /*
00022  * Desc: ROS interface to a Position2d controller for a Differential drive.
00023  * Author: Daniel Hewlett (adapted from Nathan Koenig)
00024  */
00025 #ifndef TEO_PLUGIN_HH
00026 #define TEO_PLUGIN_HH
00027 
00028 #include <map>
00029 
00030 #include <gazebo/Param.hh>
00031 #include <gazebo/Controller.hh>
00032 #include <gazebo/Model.hh>
00033 
00034 // ROS 
00035 #include <ros/ros.h>
00036 #include <tf/transform_broadcaster.h>
00037 #include <tf/transform_listener.h>
00038 #include <geometry_msgs/Twist.h>
00039 #include <nav_msgs/Odometry.h>
00040 
00041 // Custom Callback Queue
00042 #include <ros/callback_queue.h>
00043 #include <ros/advertise_options.h>
00044 
00045 // Boost
00046 #include <boost/thread.hpp>
00047 #include <boost/bind.hpp>
00048 
00049 namespace gazebo
00050 {
00051     class Joint;
00052     class Entity;
00053 
00054     class TeoPlugin :
00055         public Controller
00056     {
00057 
00058         public:
00059           TeoPlugin(Entity * parent);
00060           virtual ~TeoPlugin();
00061 
00062         protected:
00063           virtual void LoadChild(XMLConfigNode *node);
00064           virtual void InitChild();
00065           void ResetChild();
00066           virtual void UpdateChild();
00067           virtual void FiniChild();
00068 
00069         private:
00070           void write_position_data();
00071           void publish_odometry();
00072 
00073           libgazebo::PositionIface *pos_iface_;
00074           Model * parent_;
00075 
00076           Joint * joints_[4];
00077 
00078           // Simulation time of the last update
00079           Time prevUpdateTime_;
00080 
00081           float odomPose[3];
00082           float odomVel[3];
00083 
00084           bool enable_motors;
00085 
00086           // ROS STUFF
00087           ros::NodeHandle* rosnode_;
00088           ros::Publisher pub_;
00089           ros::Subscriber sub_;
00090           tf::TransformBroadcaster *transform_broadcaster_;
00091           nav_msgs::Odometry odom_;
00092           std::string tf_prefix_;
00093 
00094           boost::mutex lock;
00095 
00096           ParamT<std::string> * robotNamespaceP;
00097           ParamT<std::string> * topicNameP;
00098           ParamT<std::string> * frNameP;
00099           ParamT<std::string> * flNameP;
00100           ParamT<std::string> * brNameP;
00101           ParamT<std::string> * blNameP;
00102 
00103           std::string robotNamespace;
00104           std::string topicName;
00105 
00106           // Custom Callback Queue
00107           ros::CallbackQueue queue_;
00108           boost::thread* callback_queue_thread_;
00109           void QueueThread();
00110 
00111           // DiffDrive stuff
00112           void cmdVelCallback(const geometry_msgs::Twist::ConstPtr& cmd_msg);
00113 
00114           float vel_x_;
00115           float rot_z_;
00116           float previous_displ_;
00117           bool alive_;
00118     };
00119 }
00120 
00121 #endif
00122 


teo_gazebo_plugin
Author(s): Jose Luis Rivero
autogenerated on Fri Dec 6 2013 21:34:45