diffdrive_plugin_6w.h
Go to the documentation of this file.
1 //=================================================================================================
2 // Copyright (c) 2011, Stefan Kohlbrecher, TU Darmstadt
3 // All rights reserved.
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 // * Neither the name of the Simulation, Systems Optimization and Robotics
13 // group, TU Darmstadt nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without
15 // specific prior written permission.
16 
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //=================================================================================================
28 /*
29  * Desc: ROS interface to a Position2d controller for a Differential drive.
30  * Author: Daniel Hewlett (adapted from Nathan Koenig)
31  */
32 #ifndef DIFFDRIVE_PLUGIN_HH
33 #define DIFFDRIVE_PLUGIN_HH
34 
35 #include <map>
36 
37 #include <gazebo/common/Plugin.hh>
38 #include <gazebo/common/Time.hh>
39 
40 // ROS
41 #include <ros/ros.h>
43 #include <tf/transform_listener.h>
44 #include <geometry_msgs/Twist.h>
45 #include <nav_msgs/Odometry.h>
46 
47 // Custom Callback Queue
48 #include <ros/callback_queue.h>
49 #include <ros/advertise_options.h>
50 
51 // Boost
52 #include <boost/thread.hpp>
53 #include <boost/bind.hpp>
54 
55 namespace gazebo
56 {
57 
58 class DiffDrivePlugin6W : public ModelPlugin
59 {
60 
61 public:
63  virtual ~DiffDrivePlugin6W();
64 
65 protected:
66  virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf);
67  virtual void Reset();
68  virtual void Update();
69 
70 private:
71  void publish_odometry();
72  void GetPositionCmd();
73 
74  physics::LinkPtr link;
75  physics::WorldPtr world;
76  physics::JointPtr joints[6];
77 
78  float wheelSep;
79  float wheelDiam;
80  float torque;
81  float wheelSpeed[2];
82 
83  // Simulation time of the last update
84  common::Time prevUpdateTime;
85 
87  float odomPose[3];
88  float odomVel[3];
89 
90  // ROS STUFF
95  nav_msgs::Odometry odom_;
96  std::string tf_prefix_;
97 
98  boost::mutex lock;
99 
100  std::string namespace_;
101  std::string topic_;
102  std::string link_name_;
103 
104  // Custom Callback Queue
106  boost::thread callback_queue_thread_;
107  void QueueThread();
108 
109  // DiffDrive stuff
110  void cmdVelCallback(const geometry_msgs::Twist::ConstPtr& cmd_msg);
111 
112  float x_;
113  float rot_;
114  bool alive_;
115 
116  // Pointer to the update event connection
117  event::ConnectionPtr updateConnection;
118 };
119 
120 }
121 
122 #endif
123 
void cmdVelCallback(const geometry_msgs::Twist::ConstPtr &cmd_msg)
physics::JointPtr joints[6]
virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf)
tf::TransformBroadcaster * transform_broadcaster_
event::ConnectionPtr updateConnection


hector_gazebo_plugins
Author(s): Stefan Kohlbrecher , Johannes Meyer
autogenerated on Fri Feb 5 2021 03:48:30