Home | Tutorials | Wiki | Issues
Ask Your Question

differential drive robot not going in a straight line.

asked 2018-04-11 03:53:55 -0500

mewbot gravatar image

updated 2018-04-11 11:35:59 -0500

sloretz gravatar image

I have a differential drive robot using the differential drive controller plugin in gazebo

This is the .gazebo file.

    <?xml version="1.0"?>
    <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">

  <gazebo reference="base_link">
<gazebo reference="imu_link">
<!-- hokuyo -->
  <gazebo reference="hokuyo">
    <sensor type="ray" name="head_hokuyo_sensor">
      <pose>0 0 0 0 0 0</pose>
          <!-- Noise parameters based on published spec for Hokuyo laser
               achieving "+-30mm" accuracy at range < 10m.  A mean of 0.0m and
               stddev of 0.01m will put 99.7% of samples within 0.03m of the true
               reading. -->
      <plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_laser.so">
    <gazebo reference="imu_link">
    <sensor name="imu_sensor" type="imu">
      <plugin filename="libgazebo_ros_imu_sensor.so" name="imu_plugin">
        <xyzOffset>0 0 0</xyzOffset>
        <rpyOffset>0 0 0</rpyOffset>
      <pose>0 0 0 0 0 0</pose>
    <plugin name="imu_plugin" filename="libgazebo_ros_imu.so">

and this is the .xacro file

<?xml version='1.0'?>
<robot name="myrobot" xmlns:xacro="http://www.ros.org/wiki/xacro">
  <xacro:include filename="$(find mybot_description)/urdf/mybot.gazebo" />
  <xacro:include filename="$(find mybot_description)/urdf/materials.xacro" />
  <xacro:include filename="$(find mybot_description)/urdf/macros.xacro" />

  <link name='base_link'>
    <pose>0 0 0.1 0 0 0</pose>

      <mass value="10.0"/>
      <origin xyz="0.0 0 0.1" rpy=" 0 0 0"/>
          ixx="0.5" ixy="0" ixz="0"
          iyy="1.0" iyz="0"

    <collision name='collision'>
        <box size=".4 .2 .1"/>

    <visual name='base_link_visual'>
      <origin xyz="0 0 0" rpy=" 0 0 0"/>
        <box size=".4 .2 .1"/>

    <collision name='caster_collision'>
      <origin xyz="-0.15 0 -0.05" rpy=" 0 0 0"/>
        <sphere radius="0.05"/>

    <visual name='caster_visual'>
      <origin xyz="-0.15 0 -0.05" rpy=" 0 0 0"/>
        <sphere radius="0.05"/>

 <link name="imu_link">
      <origin xyz ...
edit retag flag offensive close merge delete


Could you update your post with embedded images/video link to illustrate how significant the observed drift is?

josephcoombe gravatar imagejosephcoombe ( 2018-04-12 11:22:14 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-04-12 11:24:05 -0500

updated 2018-04-12 16:47:35 -0500

There could be a number of causes to your differential drive robot drifting.

You can try:

  • View Contacts (View -> Contacts) to check for unintended contacts/collisions with the ground plane.
  • View Inertias (View -> Inertias) to confirm that your robot is symmetrical.
  • Add a small damping value to both wheels (e.g. 0.1) and enable implicitSpringDamper

After that, your main option is to implement a higher-level controller (e.g. PID) to compensate for drift away from an intended trajectory. In the real world, you are going to observe drift (try driving down a straight road in a car without touching steering wheel). In your car, you are the high-level controller.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-04-11 02:27:40 -0500

Seen: 43 times

Last updated: Apr 12