Home | Tutorials | Wiki | Issues
Ask Your Question
0

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"?>
   <robot>
  <gazebo>
    <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
      <legacyMode>false</legacyMode>
      <alwaysOn>true</alwaysOn>
      <updateRate>100</updateRate>
      <leftJoint>left_wheel_hinge</leftJoint>
      <rightJoint>right_wheel_hinge</rightJoint>
      <!--wheelSeparation>0.55</wheelSeparation>
      <wheelDiameter>0.1</wheelDiameter-->
      <torque>20</torque>
      <commandTopic>cmd_vel</commandTopic>
      <odometryTopic>mb1/odom</odometryTopic>
      <odometryFrame>odom</odometryFrame>
      <robotBaseFrame>base_link</robotBaseFrame>
    </plugin>
  </gazebo>

  <gazebo reference="base_link">
      <material>Gazebo/Orange</material>
    </gazebo>
<gazebo reference="imu_link">
      <material>Gazebo/Green</material>
    </gazebo>
<!-- hokuyo -->
  <gazebo reference="hokuyo">
    <sensor type="ray" name="head_hokuyo_sensor">
      <pose>0 0 0 0 0 0</pose>
      <visualize>true</visualize>
      <update_rate>40</update_rate>
      <ray>
        <scan>
          <horizontal>
            <samples>720</samples>
            <resolution>1</resolution>
            <min_angle>-1.570796</min_angle>
            <max_angle>1.570796</max_angle>
          </horizontal>
        </scan>
        <range>
          <min>0.10</min>
          <max>30.0</max>
          <resolution>0.01</resolution>
        </range>
        <noise>
          <type>gaussian</type>
          <!-- 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. -->
          <mean>0.0</mean>
          <stddev>0.01</stddev>
        </noise>
      </ray>
      <plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_laser.so">
        <topicName>/scan</topicName>
        <frameName>hokuyo</frameName>
      </plugin>
    </sensor>
</gazebo>
    <gazebo reference="imu_link">
    <gravity>true</gravity>
    <sensor name="imu_sensor" type="imu">
      <always_on>true</always_on>
      <update_rate>100</update_rate>
      <visualize>true</visualize>
      <topic>__default_topic__</topic>
      <plugin filename="libgazebo_ros_imu_sensor.so" name="imu_plugin">
        <topicName>mb1/imu</topicName>
        <bodyName>imu_link</bodyName>
        <updateRateHZ>10.0</updateRateHZ>
        <gaussianNoise>0.0</gaussianNoise>
        <xyzOffset>0 0 0</xyzOffset>
        <rpyOffset>0 0 0</rpyOffset>
        <frameName>imu_link</frameName>
      </plugin>
      <pose>0 0 0 0 0 0</pose>
    </sensor>
  </gazebo>
<!--gazebo>
    <plugin name="imu_plugin" filename="libgazebo_ros_imu.so">
      <alwaysOn>true</alwaysOn>
      <bodyName>imu_link</bodyName>
      <topicName>mb1/imu</topicName>
      <serviceName>imu_service</serviceName>
      <gaussianNoise>0.0</gaussianNoise>
      <updateRate>10.0</updateRate>
    </plugin>
  </gazebo-->
</robot>

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>

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

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

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


    <collision name='caster_collision'>
      <origin xyz="-0.15 0 -0.05" rpy=" 0 0 0"/>
      <geometry>
        <sphere radius="0.05"/>
      </geometry>
      <surface>
        <friction>
          <ode>
            <mu>0</mu>
            <mu2>0</mu2>
            <slip1>1.0</slip1>
            <slip2>1.0</slip2>
          </ode>
        </friction>
      </surface>
    </collision>

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

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

Comments

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
1

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

Stats

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

Seen: 306 times

Last updated: Apr 12