How to setup diff_drive_controller to make it work with ros_control's velocity_controllers?

asked 2018-05-26 19:47:25 -0500

rayvburn gravatar image

Hello, I'm quite confused with how to setup ros_control's velocity/position PID controllers source in a differential drive robot with diff_drive_controller wiki.

Here are some ambiguities on conceptual level with some code snippets to make everything clearer. It is somehow related to #249435, but I think that these examples with some answers will greatly help other beginners to find some info on configuration diff_drive_controller package, because besides some very general examples I couldn't find much info how to set it up properly. Hence this question.

What I did so far

I've already passed 2 joints of my robot (defined in URDF) to diff_drive_controller. Controller takes cmd_vel commands quite well. The problem is that when I'm sending linear.x = 0.3 m/s, angular.z = 0.0 rad/s command, it doesn't drive exactly forward. Another thing is that when I send linear.x = 0.1 m/s it couldn't overcome friction and is standing still.

Here is a part of the controller_common.yaml (diff drive controller params) file content:

mobile_base_controller:
  enable_odom_tf: true
  odom_frame_id: odom
  publish_cmd: true
  type: diff_drive_controller/DiffDriveController
  left_wheel: wheel_0_joint
  right_wheel: wheel_1_joint
  # and so on, it works straight ahead so I won't paste whole file, params set are listed on wiki page

Here is control.yaml file's content - 2 velocity controllers I can't make working:

  joint_state_controller:
    type: joint_state_controller/JointStateController
    publish_rate: 50  

  left_wheel_velocity_controller:
    type: velocity_controllers/JointVelocityController
    joint: wheel_0_joint  # base_to_0_wheel
    pid: {p: 00.1, i: 0.00001, d: 0.0001}

  right_wheel_velocity_controller:
    type: velocity_controllers/JointVelocityController
    joint: wheel_1_joint  # base_to_1_wheel
    pid: {p: 100.0, i: 0.1, d: 10.0}

and here is .launch file's content:

<rosparam command="load" file="$(find diff_drive_mapping_robot)/config/control.yaml" /> 
<rosparam command="load" file="$(find diff_drive_mapping_robot)/config/controller_common.yaml" /> 

<node name="base_controller_spawner"  pkg="controller_manager"  type="spawner"  output="screen"  args="mobile_base_controller" />

<node name="joint_controllers_spawner" pkg="controller_manager" type="spawner" respawn="false"
  output="screen"  args="joint_state_controller
                         left_wheel_velocity_controller
                         right_wheel_velocity_controller" >

</node> 

<node name="controller_manager_node"  pkg="diff_drive_mapping_robot" type="controller_manager_node"  output="screen" />

My robot's hardware_interfaces are defined and registered exactly as shown here

I also updated my robot_description (stored on Parameter Server) to extend joint description with hardware_interface

 <!-- =============== WHEEL_LEFT ===============-->
 <link name="wheel_0_joint">
    <visual>
      <geometry>
        <cylinder length="0.027" radius="0.03315"/>
      </geometry>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <material name="black">
        <color rgba="0 0 0 1"/>
      </material>
    </visual>
  </link>
  <joint name="base_to_0_wheel" type="fixed">
    <parent link="base_link"/>
    <child link="wheel_0_joint"/>
    <origin xyz="0 0.0955 0.03315" rpy="1.5708 0 0"/>
    <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface> <!-- please notice -->
  </joint>


  <!-- =============== WHEEL_RIGHT ===============-->
   <link name="wheel_1_joint">
    <visual>
      <geometry>
        <cylinder length="0.027" radius="0.03315"/>
      </geometry>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <material name="black">
        <color rgba="0 0 0 1"/>
      </material>
    </visual>
  </link>
  <joint name="base_to_1_wheel" type="fixed">
    <parent link="base_link"/>
    <child link="wheel_1_joint"/>
    <origin xyz="0 -0.0955 0.03315" rpy="1.5708 0 0"/>
    <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface> <!-- please notice -->
  </joint>

Now, with the same joints (same names) for diff drive controller and listed velocity controllers I ... (more)

edit retag flag offensive close merge delete

Comments

Hi there, I am stuck at the very same problem for about 2 weeks now, as there doesnt seem to be much documentation. Did you get any further?

stuggibo gravatar imagestuggibo ( 2018-11-26 09:16:33 -0500 )edit

Unfortunately I had no luck. Finally used this package pid and it worked perfectly. EDIT: I forgot to post a link to my project's code. You may find it a useful example - Github repository

rayvburn gravatar imagerayvburn ( 2018-11-27 15:04:53 -0500 )edit

thanks, this helped me a lot :) did you somehow filter your velocity estimate?

stuggibo gravatar imagestuggibo ( 2018-12-20 08:49:20 -0500 )edit

No, sorry, I didn't need velocity filtering. Anyway, I'm glad I could help you a little.

rayvburn gravatar imagerayvburn ( 2018-12-23 03:03:32 -0500 )edit