gazebo_ros_tricycle_drive.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2013, Markus Bader <markus.bader@tuwien.ac.at>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *********************************************************************/
33 
41 #ifndef TRICYCLE_DRIVE_PLUGIN_HH
42 #define TRICYCLE_DRIVE_PLUGIN_HH
43 
44 #include <map>
45 
46 // Gazebo
48 
49 // ROS
50 #include <ros/ros.h>
52 #include <tf/transform_listener.h>
53 #include <geometry_msgs/Twist.h>
54 #include <geometry_msgs/Pose2D.h>
55 #include <nav_msgs/Odometry.h>
56 #include <nav_msgs/OccupancyGrid.h>
57 #include <sensor_msgs/JointState.h>
58 
59 // Custom Callback Queue
60 #include <ros/callback_queue.h>
61 #include <ros/advertise_options.h>
62 
63 // Boost
64 #include <boost/thread.hpp>
65 #include <boost/bind.hpp>
66 
67 namespace gazebo {
68 
69 class Joint;
70 class Entity;
71 
72 
73 class GazeboRosTricycleDrive : public ModelPlugin {
74 
76  public:
78  double speed;
79  double angle;
80  };
81 
83  {
84  ENCODER = 0,
85  WORLD = 1,
86  };
87 public:
90  void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf);
91 
92 protected:
93  virtual void UpdateChild();
94  virtual void FiniChild();
95 
96 private:
98  physics::ModelPtr parent;
99  void publishOdometry(double step_time);
100  void publishWheelTF();
101  void publishWheelJointState();
102  void motorController(double target_speed, double target_angle, double dt);
103 
104  event::ConnectionPtr update_connection_;
105 
106  physics::JointPtr joint_steering_;
107  physics::JointPtr joint_wheel_actuated_;
108  physics::JointPtr joint_wheel_encoder_left_;
109  physics::JointPtr joint_wheel_encoder_right_;
110 
119 
122 
123  std::string robot_namespace_;
124  std::string command_topic_;
125  std::string odometry_topic_;
126  std::string odometry_frame_;
127  std::string robot_base_frame_;
128 
129  // ROS STUFF
133  sensor_msgs::JointState joint_state_;
135  nav_msgs::Odometry odom_;
136 
137  boost::mutex lock;
138 
139 
140  // Custom Callback Queue
142  boost::thread callback_queue_thread_;
143  void QueueThread();
144 
145  // DiffDrive stuff
146  void cmdVelCallback(const geometry_msgs::Twist::ConstPtr& cmd_msg);
147 
149  void UpdateOdometryEncoder();
150 
152  bool alive_;
153  geometry_msgs::Pose2D pose_encoder_;
154  common::Time last_odom_update_;
155 
156  // Update Rate
157  double update_rate_;
159  common::Time last_actuator_update_;
160 
161  // Flags
164 
165 };
166 
167 }
168 
169 #endif
170 
gazebo::GazeboRosTricycleDrive::wheel_deceleration_
double wheel_deceleration_
Definition: gazebo_ros_tricycle_drive.h:114
gazebo::GazeboRosTricycleDrive::TricycleDriveCmd
Definition: gazebo_ros_tricycle_drive.h:75
gazebo::GazeboRosTricycleDrive::wheel_torque_
double wheel_torque_
Definition: gazebo_ros_tricycle_drive.h:121
ros::Publisher
gazebo::GazeboRosTricycleDrive::robot_namespace_
std::string robot_namespace_
Definition: gazebo_ros_tricycle_drive.h:123
gazebo::GazeboRosTricycleDrive::joint_steering_
physics::JointPtr joint_steering_
Definition: gazebo_ros_tricycle_drive.h:106
boost::shared_ptr< GazeboRos >
gazebo::GazeboRosTricycleDrive::WORLD
@ WORLD
Definition: gazebo_ros_tricycle_drive.h:85
gazebo::GazeboRosTricycleDrive::publishOdometry
void publishOdometry(double step_time)
Definition: gazebo_ros_tricycle_drive.cpp:444
gazebo
gazebo::GazeboRosTricycleDrive::cmd_
TricycleDriveCmd cmd_
Definition: gazebo_ros_tricycle_drive.h:151
ros.h
gazebo::GazeboRosTricycleDrive::pose_encoder_
geometry_msgs::Pose2D pose_encoder_
Definition: gazebo_ros_tricycle_drive.h:153
gazebo::GazeboRosTricycleDrive::cmd_vel_subscriber_
ros::Subscriber cmd_vel_subscriber_
Definition: gazebo_ros_tricycle_drive.h:131
gazebo::GazeboRosTricycleDrive::callback_queue_thread_
boost::thread callback_queue_thread_
Definition: gazebo_ros_tricycle_drive.h:142
gazebo::GazeboRosTricycleDrive::diameter_actuated_wheel_
double diameter_actuated_wheel_
Definition: gazebo_ros_tricycle_drive.h:112
gazebo::GazeboRosTricycleDrive::TricycleDriveCmd::speed
double speed
Definition: gazebo_ros_tricycle_drive.h:77
gazebo::GazeboRosTricycleDrive::OdomSource
OdomSource
Definition: gazebo_ros_tricycle_drive.h:82
gazebo::GazeboRosTricycleDrive
Definition: gazebo_ros_tricycle_drive.h:73
gazebo::GazeboRosTricycleDrive::update_connection_
event::ConnectionPtr update_connection_
Definition: gazebo_ros_tricycle_drive.h:104
gazebo::GazeboRosTricycleDrive::separation_encoder_wheel_
double separation_encoder_wheel_
Definition: gazebo_ros_tricycle_drive.h:118
gazebo::GazeboRosTricycleDrive::wheel_acceleration_
double wheel_acceleration_
Definition: gazebo_ros_tricycle_drive.h:113
gazebo::GazeboRosTricycleDrive::UpdateChild
virtual void UpdateChild()
Definition: gazebo_ros_tricycle_drive.cpp:214
gazebo::GazeboRosTricycleDrive::motorController
void motorController(double target_speed, double target_angle, double dt)
Definition: gazebo_ros_tricycle_drive.cpp:276
gazebo::GazeboRosTricycleDrive::parent
physics::ModelPtr parent
Definition: gazebo_ros_tricycle_drive.h:98
transform_broadcaster.h
gazebo::GazeboRosTricycleDrive::gazebo_ros_
GazeboRosPtr gazebo_ros_
Definition: gazebo_ros_tricycle_drive.h:97
gazebo::GazeboRosTricycleDrive::Load
void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf)
Definition: gazebo_ros_tricycle_drive.cpp:77
gazebo::GazeboRosTricycleDrive::publishWheelJointState_
bool publishWheelJointState_
Definition: gazebo_ros_tricycle_drive.h:163
gazebo::GazeboRosTricycleDrive::UpdateOdometryEncoder
void UpdateOdometryEncoder()
updates the relative robot pose based on the wheel encoders
Definition: gazebo_ros_tricycle_drive.cpp:394
gazebo::GazeboRosTricycleDrive::queue_
ros::CallbackQueue queue_
Definition: gazebo_ros_tricycle_drive.h:141
gazebo::GazeboRosTricycleDrive::wheel_speed_tolerance_
double wheel_speed_tolerance_
Definition: gazebo_ros_tricycle_drive.h:115
gazebo::GazeboRosTricycleDrive::TricycleDriveCmd::TricycleDriveCmd
TricycleDriveCmd()
Definition: gazebo_ros_tricycle_drive.h:77
gazebo::GazeboRosTricycleDrive::steering_speed_
double steering_speed_
Definition: gazebo_ros_tricycle_drive.h:117
gazebo::GazeboRosTricycleDrive::transform_broadcaster_
boost::shared_ptr< tf::TransformBroadcaster > transform_broadcaster_
Definition: gazebo_ros_tricycle_drive.h:132
gazebo::GazeboRosTricycleDrive::last_actuator_update_
common::Time last_actuator_update_
Definition: gazebo_ros_tricycle_drive.h:159
gazebo::GazeboRosTricycleDrive::TricycleDriveCmd::angle
double angle
Definition: gazebo_ros_tricycle_drive.h:79
gazebo::GazeboRosTricycleDrive::publishWheelTF
void publishWheelTF()
Definition: gazebo_ros_tricycle_drive.cpp:187
ros::CallbackQueue
gazebo::GazeboRosTricycleDrive::FiniChild
virtual void FiniChild()
Definition: gazebo_ros_tricycle_drive.cpp:369
gazebo::GazeboRosTricycleDrive::publishWheelTF_
bool publishWheelTF_
Definition: gazebo_ros_tricycle_drive.h:162
gazebo::GazeboRosTricycleDrive::joint_state_
sensor_msgs::JointState joint_state_
Definition: gazebo_ros_tricycle_drive.h:133
gazebo::GazeboRosTricycleDrive::odometry_topic_
std::string odometry_topic_
Definition: gazebo_ros_tricycle_drive.h:125
gazebo::GazeboRosTricycleDrive::joint_wheel_encoder_left_
physics::JointPtr joint_wheel_encoder_left_
Definition: gazebo_ros_tricycle_drive.h:108
gazebo::GazeboRosTricycleDrive::odometry_publisher_
ros::Publisher odometry_publisher_
Definition: gazebo_ros_tricycle_drive.h:130
gazebo::GazeboRosTricycleDrive::command_topic_
std::string command_topic_
Definition: gazebo_ros_tricycle_drive.h:124
callback_queue.h
gazebo::GazeboRosTricycleDrive::~GazeboRosTricycleDrive
~GazeboRosTricycleDrive()
Definition: gazebo_ros_tricycle_drive.cpp:74
transform_listener.h
gazebo::GazeboRosTricycleDrive::update_period_
double update_period_
Definition: gazebo_ros_tricycle_drive.h:158
gazebo::GazeboRosTricycleDrive::alive_
bool alive_
Definition: gazebo_ros_tricycle_drive.h:152
gazebo::GazeboRosTricycleDrive::odom_source_
OdomSource odom_source_
Definition: gazebo_ros_tricycle_drive.h:120
advertise_options.h
gazebo::GazeboRosTricycleDrive::joint_wheel_encoder_right_
physics::JointPtr joint_wheel_encoder_right_
Definition: gazebo_ros_tricycle_drive.h:109
gazebo::GazeboRosTricycleDrive::GazeboRosTricycleDrive
GazeboRosTricycleDrive()
Definition: gazebo_ros_tricycle_drive.cpp:71
gazebo::GazeboRosTricycleDrive::update_rate_
double update_rate_
Definition: gazebo_ros_tricycle_drive.h:157
gazebo::GazeboRosTricycleDrive::cmdVelCallback
void cmdVelCallback(const geometry_msgs::Twist::ConstPtr &cmd_msg)
Definition: gazebo_ros_tricycle_drive.cpp:378
gazebo::GazeboRosTricycleDrive::odometry_frame_
std::string odometry_frame_
Definition: gazebo_ros_tricycle_drive.h:126
gazebo::GazeboRosTricycleDrive::joint_state_publisher_
ros::Publisher joint_state_publisher_
Definition: gazebo_ros_tricycle_drive.h:134
gazebo::GazeboRosTricycleDrive::QueueThread
void QueueThread()
Definition: gazebo_ros_tricycle_drive.cpp:385
gazebo_ros_utils.h
gazebo::GazeboRosTricycleDrive::joint_wheel_actuated_
physics::JointPtr joint_wheel_actuated_
Definition: gazebo_ros_tricycle_drive.h:107
gazebo::GazeboRosTricycleDrive::diameter_encoder_wheel_
double diameter_encoder_wheel_
Definition: gazebo_ros_tricycle_drive.h:111
gazebo::GazeboRosTricycleDrive::last_odom_update_
common::Time last_odom_update_
Definition: gazebo_ros_tricycle_drive.h:154
gazebo::GazeboRosTricycleDrive::ENCODER
@ ENCODER
Definition: gazebo_ros_tricycle_drive.h:84
gazebo::GazeboRosTricycleDrive::lock
boost::mutex lock
Definition: gazebo_ros_tricycle_drive.h:137
gazebo::GazeboRosTricycleDrive::robot_base_frame_
std::string robot_base_frame_
Definition: gazebo_ros_tricycle_drive.h:127
gazebo::GazeboRosTricycleDrive::odom_
nav_msgs::Odometry odom_
Definition: gazebo_ros_tricycle_drive.h:135
gazebo::GazeboRosTricycleDrive::steering_angle_tolerance_
double steering_angle_tolerance_
Definition: gazebo_ros_tricycle_drive.h:116
ros::Subscriber
gazebo::GazeboRosTricycleDrive::publishWheelJointState
void publishWheelJointState()
publishes the wheel tf's
Definition: gazebo_ros_tricycle_drive.cpp:160


gazebo_plugins
Author(s): John Hsu
autogenerated on Thu Sep 5 2024 02:49:55