1
$\begingroup$

I am trying to make a 4 wheeled robot simulation in Gazebo Sim (formerly Ignition). I am using the differential drive plugin for driving the robot using teleop through /cmd_vel topic.

My system details

  • OS : Ubuntu 22.04
  • ROS 2 version : Humble
  • Gazebo Sim version : Fortress

Here is my gazebo plugin for differential drive where I have mentioned 4 wheel joints

<gazebo>
    <plugin filename="ignition-gazebo-diff-drive-system" name="ignition::gazebo::systems::DiffDrive">
  <left_joint>left_front_joint</left_joint>
  <right_joint>right_front_joint</right_joint>
  <left_joint>left_back_joint</left_joint>
  <right_joint>right_back_joint</right_joint>
  <odom_publish_frequency>60</odom_publish_frequency>
  <wheel_separation>0.40</wheel_separation>
  <wheel_radius>0.17</wheel_radius>
  <topic>/cmd_vel</topic>
  <odom_topic>/odom</odom_topic>
  <frame_id>odom</frame_id>
  <child_frame_id>base_link</child_frame_id>
</plugin>

The Gazebo sim bridge for the ROS 2 topics is defined in the gz-sim.launch.py file

gz_ros2_bridge = Node(
    package="ros_gz_bridge",
    executable="parameter_bridge",
    arguments=[
        "/cmd_vel@geometry_msgs/msg/[email protected]",
        "/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock",
        "/odom@nav_msgs/msg/Odometry[gz.msgs.Odometry",
        "/model/skid_steer_robot/tf@tf2_msgs/msg/TFMessage[gz.msgs.Pose_V",
        "/scan@sensor_msgs/msg/LaserScan[gz.msgs.LaserScan",
        "/imu@sensor_msgs/msg/Imu[ignition.msgs.IMU",
    ],
    remappings=[
        ('/model/skid_steer_robot/tf', '/tf')
    ]
)

But as you can see in below images, the data visualization in Rviz2 is not working properly. The topics in rviz2 is somewhat not correclty visualized as compared to the simulation.

The below attached video will help you understand the problem I am facing more clearly.

enter image description here enter image description here

Here is the complete description package for the skid steer robot nilutpolkashyap/skid_steer_robot

Here is the video showing the error skid_steer_error.webm video

Thank you for your time

$\endgroup$

1 Answer 1

0
$\begingroup$

The diff drive plugin only assumes one left and right wheel, while you have two each side. What I would do it simply instantiate two plugins, one for the front wheels (with cmd_vel) and one for the back ones (with e.g. cmd_vel_back). Then run one bridge for cmd_vel, and another one for cmd_vel_back but remapping the ROS topic to cmd_vel. This way Gazebo will received your ROS cmd_vel topic on both the front and back wheels. One of the two plugins should also not publish anything, as you have a single odom or /tf topic anyway.

$\endgroup$
1
  • $\begingroup$ It did not solve the error for me. I noticed that I am getting the real-time factor as close as 10-20%. Is this in some way causing the error? $\endgroup$ Commented Jul 8 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.