- Mastering ROS for Robotics Programming(Second Edition)
- Lentin Joseph Jonathan Cacace
- 191字
- 2025-02-17 19:11:05
Moving the mobile robot in Gazebo
The robot we are working with is a differential robot with two wheels and two caster wheels. The complete characteristics of the robot should model as the Gazebo-ROS plugin for the simulation. Luckily, the plugin for a basic differential drive is already implemented.
To move the robot in Gazebo, we should add a Gazebo-ROS plugin file called libgazebo_ros_diff_drive.so to get the differential drive behavior in this robot.
Here is the complete code snippet of the definition of this plugin and its parameters:
<!-- Differential drive controller --> <gazebo> <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so"> <rosDebugLevel>Debug</rosDebugLevel> <publishWheelTF>false</publishWheelTF> <robotNamespace>/</robotNamespace> <publishTf>1</publishTf> <publishWheelJointState>false</publishWheelJointState> <alwaysOn>true</alwaysOn> <updateRate>100.0</updateRate> <leftJoint>front_left_wheel_joint</leftJoint> <rightJoint>front_right_wheel_joint</rightJoint> <wheelSeparation>${2*base_radius}</wheelSeparation> <wheelDiameter>${2*wheel_radius}</wheelDiameter> <broadcastTF>1</broadcastTF> <wheelTorque>30</wheelTorque> <wheelAcceleration>1.8</wheelAcceleration> <commandTopic>cmd_vel</commandTopic> <odometryFrame>odom</odometryFrame> <odometryTopic>odom</odometryTopic> <robotBaseFrame>base_footprint</robotBaseFrame> </plugin> </gazebo>
We can provide the parameters such as the wheel joints of the robot (joints should be of a continuous type), wheel separation, wheel diameters, odometry topic, and so on, in this plugin.
An important parameter that we need to move the robot is:
<commandTopic>cmd_vel</commandTopic>
This parameter is the command velocity topic to the plugin, which is basically a Twist message in ROS (sensor_msgs/Twist). We can publish the Twist message into the /cmd_vel topic, and we can see the robot start to move from its position.