Ask Your Question
1

diff_drive_controller only drives straight, no turning

asked 2018-07-09 17:34:11 -0500

Callum Gundlach gravatar image

I'm testing out a two wheeled robot I designed and put in gazebo. I also have a static back wheel with very little friction that is only there for structural support. When I give linear x commands the bot drives forward and backward, however any angular z commands are completely ignored and the robot does nothing. My files are as follows:

rover_control.yaml:

rover:
# Publish all joint states -----------------------------------
joint_state_controller:
  type: joint_state_controller/JointStateController
  publish_rate: 50

mobile_base_controller:
  type: "diff_drive_controller/DiffDriveController"
  left_wheel: 'motor_wheel_left'
  right_wheel: 'motor_wheel_right'
  publish_rate: 50.0
  pose_covariance_diagonal : [0.001, .001, 1000000., 1000000., 1000000., 1000.]
  twist_covariance_diagonal: [0.001, .001, 1000000., 1000000., 1000000., 1000.]
  wheel_radius : 0.0508

rover_control.launch

<?xml version='1.0' encoding="UTF-8"?>
<launch>

<rosparam file="$(find rover_description)/config/rover_control.yaml" command="load"/>
<param name="rover/robot_description" command="cat $(find rover_description)/urdf/rover_description.urdf" />
<node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
      output="screen" ns="/rover" args="joint_state_controller
      mobile_base_controller"/>

<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"
      respawn="false" output="screen">
      <remap from="/joint_states" to="rover/joint_states"/>
</node>

</launch>

rover_description.urdf

    <robot
  name="rover_description">
  <link
    name="base_link">
    <inertial>
      <origin
        xyz="-0.081461 0.072568 0.22578"
        rpy="0 0 0" />
      <mass
        value="0.02" />
      <inertia
        ixx="0.0017841"
        ixy="-2.5191E-21"
        ixz="-3.1496E-20"
        iyy="0.0031046"
        iyz="-3.5569E-22"
        izz="0.0013209" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://rover_description/meshes/base_link.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="1 1 1 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://rover_description/meshes/base_link.STL" />
      </geometry>
    </collision>
  </link>
  <link
    name="motor_right">
    <inertial>
      <origin
        xyz="0.025956 0.025203 1.9204E-06"
        rpy="0 0 0" />
      <mass
        value="0.11635" />
      <inertia
        ixx="2.1884E-05"
        ixy="-6.1285E-06"
        ixz="1.7317E-08"
        iyy="0.00012501"
        iyz="-1.7272E-10"
        izz="0.00012659" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://rover_description/meshes/motor_right.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://rover_description/meshes/motor_right.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="base_motor_right"
    type="fixed">
    <origin
      xyz="0.024539 -0.097801 0.074156"
      rpy="1.5708 0 3.1416" />
    <parent
      link="base_link" />
    <child
      link="motor_right" />
    <axis
      xyz="0 0 0" />
    <limit
      effort="1"
      velocity="0.05" />
  </joint>
  <link
    name="wheel_right">
    <inertial>
      <origin
        xyz="6.9389E-17 -0.0127 0"
        rpy="0 0 0" />
      <mass
        value="0.078876" />
      <inertia
        ixx="7.3551E-05"
        ixy="-5.5111E-11"
        ixz="8.4703E-21"
        iyy="0.00014131"
        iyz="-1.8331E-21"
        izz="7.3551E-05" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://rover_description/meshes/wheel_right.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://rover_description/meshes/wheel_right.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="motor_wheel_right"
    type="continuous">
    <origin
      xyz="-0.042 0.019 0"
      rpy="0 ...
(more)
edit retag flag offensive close merge delete

Comments

In what directions do your wheels spin in 1) gazebo 2) rviz when turning?

Humpelstilzchen gravatar image Humpelstilzchen  ( 2018-07-10 01:58:41 -0500 )edit

In both gazebo and rviz the wheels would both spin counter-clockwise and clockwise depending on the value of linear.x.

Callum Gundlach gravatar image Callum Gundlach  ( 2018-07-10 08:28:44 -0500 )edit

And with rotational speed only?

Humpelstilzchen gravatar image Humpelstilzchen  ( 2018-07-10 09:35:41 -0500 )edit

Wheels do not move, in both rviz and gazebo

Callum Gundlach gravatar image Callum Gundlach  ( 2018-07-10 09:38:53 -0500 )edit

Have you checked the tf in rviz?

Humpelstilzchen gravatar image Humpelstilzchen  ( 2018-07-10 11:24:50 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-03-02 15:44:53 -0500

john.j.oneill gravatar image

I realize this is an old post, but I had the same issue and couldn't find an answer anywhere, so I'll post it here. It turned out I was missing wheel_separation : 1.0 in the yaml. It's supposed to automagically find it and the wheel radius from the urdf, but it my case it didn't and used a default of 0, which apparently led to a maths error when it calculated the differential drive equations (maybe a divide by zero?) even though it could go forwards/backwards just fine.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2018-07-09 17:34:11 -0500

Seen: 320 times

Last updated: Mar 02 '19