0
$\begingroup$

Rosanswers logo

Hi, I'm creating a URDF for my robot which is tracked and I'm trying to use the diff_drive plugin in gazebo to simulate it. I can control the robot using the keyboard teleop utility but it veers to the right and when I look at the wheels in Gazebo I can see that though the rear wheels are turning as expected the front wheels aren't, if anything they look like they're digging in. If I drive in reverse the opposite happens.

The joints are all set to be continuous rather than revolute with a limit, I just can't figure this out and feel I'm bashing my head against the wall!

Is the wheel not turning expected behaviour for diff_drive with skid steer emulation or have I messed up with the URDF?

image description

This is the first URDF and gazebo simulation that I've created so if I'm honest I've been doing a lot of trial and error to try and figure out why this isn't working and I've honestly lost track a little.

Full code is available on github if anyone wanted to give it a go themselves. I'm honest completely lost and no idea what to try next so if anyone could assist I would be massively grateful!

This is the definition of the right wheels:

  <link name="rear_right_wheel">
    <inertial>
      <origin rpy="0 0 0" xyz="0 0 0" />
      <mass value="0.001" />
      <inertia ixx="0.000283500005025417" ixy="0" ixz="0" iyy="0.000283500005025417" iyz="0" izz="0.000323999993270263" />
    </inertial>
    <visual>
      <origin rpy="-4.712389 0 0" xyz="0 -0.01 0" />
      <geometry>
        <cylinder length="0.02" radius="0.025" />
      </geometry>
      <material name="black" />
    </visual>
    <collision>
      <origin rpy="-4.712389 0 0" xyz="0 -0.01 0" />
      <geometry>
        <cylinder length="0.02" radius="0.025" />
      </geometry>
    </collision>
  </link>
  <link name="front_right_wheel">
    <inertial>
      <origin rpy="0 0 0" xyz="0 0 0" />
      <mass value="0.001" />
      <inertia ixx="0.000283500005025417" ixy="0" ixz="0" iyy="0.000283500005025417" iyz="0" izz="0.000323999993270263" />
    </inertial>
    <visual>
      <origin rpy="-4.712389 0 0" xyz="0 -0.01 0" />
      <geometry>
        <cylinder length="0.02" radius="0.025" />
      </geometry>
      <material name="black" />
    </visual>
    <collision>
      <origin rpy="-1.570796 0 0" xyz="0 -0.01 0" />
      <geometry>
        <cylinder length="0.02" radius="0.025" />
      </geometry>
    </collision>
  </link>

This is the definition for the transmissions:

<transmission name="rear_left_wheel_transmission">
  <type>transmission_interface/SimpleTransmission</type>
  <joint name="base_link_rear_left_wheel_joint">
    <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
  </joint>
  <actuator name="rear_left_wheel_actuator">
    <mechanicalReduction>1</mechanicalReduction>
    <hardwareInterface>VelocityJointInterface</hardwareInterface>
  </actuator>
</transmission>

<transmission name="rear_right_wheel_transmission">
  <type>transmission_interface/SimpleTransmission</type>
  <joint name="base_link_rear_right_wheel_joint">
    <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
  </joint>
  <actuator name="rear_right_wheel_actuator">
    <mechanicalReduction>1</mechanicalReduction>
    <hardwareInterface>VelocityJointInterface</hardwareInterface>
  </actuator>
</transmission>

<transmission name="front_left_wheel_transmission">
  <type>transmission_interface/SimpleTransmission</type>
  <joint name="base_link_front_left_wheel_joint">
    <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
  </joint>
  <actuator name="front_left_wheel_actuator">
    <mechanicalReduction>1</mechanicalReduction>
    <hardwareInterface>VelocityJointInterface</hardwareInterface>
  </actuator>
</transmission>

<transmission name="front_right_wheel_transmission">
  <type>transmission_interface/SimpleTransmission</type>
  <joint name="base_link_front_right_wheel_joint">
    <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
  </joint>
  <actuator name="front_right_wheel_actuator">
    <mechanicalReduction>1</mechanicalReduction>
    <hardwareInterface>VelocityJointInterface</hardwareInterface>
  </actuator>
</transmission>

This is the plugin definition:

  <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
    <legacyMode>false</legacyMode>
    <alwaysOn>true</alwaysOn>
    <publishWheelTF>true</publishWheelTF>
    <publishTf>1</publishTf>
    <publishWheelJointState>true</publishWheelJointState>
    <updateRate>100.0</updateRate>
    <leftJoint>base_link_rear_left_wheel_joint</leftJoint>
    <leftJoint>base_link_front_left_wheel_joint</leftJoint>
    <rightJoint>base_link_rear_right_wheel_joint</rightJoint>
    <rightJoint>base_link_front_right_wheel_joint</rightJoint>
    <wheelAcceleration>1.0</wheelAcceleration>
    <torque>20</torque>
    <commandTopic>/nefive/cmd_vel</commandTopic>
    <odometryTopic>odom</odometryTopic>
    <odometryFrame>odom</odometryFrame>
    <robotBaseFrame>base_link</robotBaseFrame>
  </plugin> 

Originally posted by kneave on ROS Answers with karma: 96 on 2021-09-21

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

So it turns out I had the coliders messed up and they were inside the chassis and completely bound up, you can see that in the original question.

If anyone stumbles upon this, this is the working diff_drive for gazebo. You'll want to change the name of the joints, the namespace, and the command topic to match your robot but as long as your URDF is right this should work:

  <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
    <legacyMode>false</legacyMode>
    <alwaysOn>true</alwaysOn>
    <publishWheelTF>true</publishWheelTF>
    <publishTf>1</publishTf>
    <publishWheelJointState>true</publishWheelJointState>
    <updateRate>100.0</updateRate>
    <leftJoint>base_link_rear_left_wheel_joint</leftJoint>
    <leftJoint>base_link_front_left_wheel_joint</leftJoint>
    <rightJoint>base_link_rear_right_wheel_joint</rightJoint>
    <rightJoint>base_link_front_right_wheel_joint</rightJoint>
    <wheelAcceleration>1.0</wheelAcceleration>
    <torque>20</torque>
    <commandTopic>/nefive/cmd_vel</commandTopic>
    <odometryTopic>odom</odometryTopic>
    <odometryFrame>odom</odometryFrame>
    <robotBaseFrame>base_link</robotBaseFrame>
    <robotNamespace>nefive</robotNamespace>
  </plugin>

Originally posted by kneave with karma: 96 on 2021-09-21

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

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.