Ask Your Question

DiffDriveController in Gazebo Ros control

asked 2022-03-21 12:27:47 -0500

prcgnn gravatar image

updated 2022-03-25 17:23:01 -0500

lucasw gravatar image

Hi! I set up a sim via rviz & gazebo firstly using gazebo diff drive plug in. then I noticed some limits using this model and I attempted to switch to gazebo_ros_control diff_drive_controller. the robot spawns and visualizes in gazebo but when in rviz I try to command via joystick or setting a 2d goal nothing happens.

What is wrong? Am i missing something? Are the two libraries substitutes or do they complement each other?

Launch file

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

  <param name="/use_sim_time" value="true" />
  <param name="robot_description" command="$(find xacro)/xacro --inorder $(find nav-sim)/urdf/gbot.urdf.xacro" />
  <node pkg="rviz" type="rviz" name="rviz" output="screen"/>

  <node pkg="robot_state_publisher" name="robot_state_publisher"  type="robot_state_publisher" />

  <node pkg="joint_state_publisher" name="joint_state_publisher" type="joint_state_publisher" />

    <arg name="x" default="0"/>
    <arg name="y" default="0"/>
    <arg name="z" default="0"/>

<!--  <include file="$(find nav-sim)/launch/gbot_control_teleop.launch" />-->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
   <arg name="world_name" value="$(find nav-sim)/launch/complicated_world_tagged" />
   <arg name="debug" value="false" />
    <arg name="gui" value="true" />
    <arg name="paused" value="false"/>
    <arg name="use_sim_time" value="true"/>
    <arg name="headless" value="false"/>
    <arg name="verbose" value="true"/>
  <node name="spawn_robot_urdf" pkg="gazebo_ros" type="spawn_model" output="screen"
        args="-urdf -param robot_description -model gbot.urdf.xacro -x $(arg x) -y $(arg y) -z $(arg z)" >

  <rosparam file="$(find nav-sim)/config/gconfig.yaml" command="load" />
    <node name="spawner" pkg="controller_manager" type="spawner"
          respawn="false" output="screen" args= "mobile_base_controller" />


Plug in

    <?xml version="1.0"?>
  <gazebo reference="base_link">
    <plugin name="gazebo_ros_control" filename="">

<!--  <gazebo reference="base_link">-->
<!--    <plugin name="differential_drive_controller" filename="">-->
<!--      <alwaysOn>true</alwaysOn>-->
<!--      <legacyMode>false</legacyMode>-->
<!--      <updateRate>20</updateRate>-->
<!--      <leftJoint>left_wheel_joint</leftJoint>-->
<!--      <rightJoint>right_wheel_joint</rightJoint>-->
<!--      <wheelSeparation>${wheel_separation}</wheelSeparation>-->
<!--      <wheelDiameter>${wheel_radius * 2}</wheelDiameter>-->
<!--      <torque>20</torque>-->
<!--      <commandTopic>/twist_mux/cmd_vel</commandTopic>-->
<!--      <odometryTopic>/odom_in</odometryTopic>-->
<!--      <odometryFrame>odom</odometryFrame>-->
<!--      <robotBaseFrame>base_link</robotBaseFrame>-->
<!--      <publishWheelTF>false</publishWheelTF>-->
<!--      <publishWheelJointState>false</publishWheelJointState>-->
<!--      <odometrySource>world</odometrySource> &lt;!&ndash; 'encoder' instead of 'world' is also possible &ndash;&gt;-->
<!--      <publishTf>1</publishTf>-->
<!--    </plugin>-->
<!--  </gazebo>-->
  <!-- hokuyo -->
  <gazebo reference="laser_frame_HF">
    <sensor type="ray" name="head_hokuyo_sensor_front">
      <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 ...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-03-22 13:23:05 -0500

schulze18 gravatar image

Hi prcgnn. These two libraries are not complementary. ROS Control is a generic framework to implement controllers in ROS applications, for example, the diff_drive_controller. gazebo_ros_control is a Gazebo Plugin that "talks" with the ROS Control stack (through a Hardware Interface), allowing you to control a robot in Gazebo using a ROS Controller.

I suggest you read the documentation from ROS Control, and also how it works with Gazebo (link).

But that being said. As you did not post the entire robot's URDF, I imagine that you did not add the transmission associated to the joints you need to move (link).

Could you edit your question and include your terminals? Probably they have some useful information too.

Also, the way you define the yaml file, instead of "cmd_vel", your rostopic will probably be "mobile_base_controller/cmd_vel". It works fine, but if you want to use the teleop or rviz's joystick, you need to set them to use the new name.

Check this tutorial about diff_drive_controller, it may help you.

I hope this information is helpful, and you can solve your issue.

edit flag offensive delete link more


Thank you for your reply. I just added the urdf missing part. Have a look and tell me if you see something strange. The fact is this frobot is part of a larger navigation module based on twist mux (cmd_vel and joystick) and odom fram with topic odom_in. In the gazebo plug in I was able to specify all this parameters but in this ros_control I am not. Any hint?

prcgnn gravatar image prcgnn  ( 2022-03-23 03:39:32 -0500 )edit

In general, the ros controllers set their topic names based on the controller namespace ("mobile_base_controller" in your case). But you can use topic remap to change it (link). Is your controller working? For example, if you test without the joystick, teleop, etc, and you just do a "rostopic pub" into the topic ending with "cmd_vel" (probably "mobile_base_controller/cmd_vel"). Does the robot move? if you do a "rostopic list", is there any topic with "cmd_vel"?

schulze18 gravatar image schulze18  ( 2022-03-24 06:47:10 -0500 )edit

Yes, I already implemented the remap and all is inside cmd_vel and odom _in topics. If testing with rostopic pub the robot moves still slowsly. Yes, if input rostopic list cmd_vel is shown. It seemes like rviz and gazebo have different types of behaviour.For ex. a rotation of 90 deg in rviz corresponds to ~60 deg in gazebo. Any idea?

prcgnn gravatar image prcgnn  ( 2022-03-24 09:14:54 -0500 )edit

Make sure you are continuos publishing into cmd_vel, by using the "-r 100" in the ros topic pub. Do your wheels seem to be rotating in place in Gazebo? Like slipping on the floor? If so, probably you need to tune the friction and physical coefficients of your link (setting max_step_size to 0.001 and real_time_update_rate to 1000 in the Gazebo Physics usually also help in those cases too).

schulze18 gravatar image schulze18  ( 2022-03-25 12:39:03 -0500 )edit

Is it possible to tune Gazebo Physics inside urdf file? Or where do I have to specify them? I have no sdf. Yes I confirm you that robot moves when publishing cmd_vel topics.

prcgnn gravatar image prcgnn  ( 2022-03-29 04:29:29 -0500 )edit

Your Answer

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

Add Answer

Question Tools



Asked: 2022-03-21 12:27:47 -0500

Seen: 122 times

Last updated: Mar 23