Ask Your Question

No /odom or /cmd_vel topics when using diff drive plugin

asked 2021-07-20 09:14:47 -0500

vertical_beef576 gravatar image

Hi, I have created a two wheeled model and have added the gazebo differential drive plugin to the urdf file. However, when I spawn the robot into gazebo and view the topics in a terminal (with "ros2 topic list") there isn't the /odom or /cmd_vel topics (which I would expect). How would I fix this and make the topics appear? Any help is much appreciated.

Below is my urdf code:

<?xml version="1.0"?>
<robot xmlns:xacro="" name="self balancing robot">
<xacro:property name="update_rate" value = "10"/>

<xacro:property name="layer_width" value="0.15"/>
<xacro:property name="layer_depth" value="0.1"/>
<xacro:property name="layer_height" value="0.003"/>
<xacro:property name="layer_mass" value="0.054"/>
<xacro:property name="layer_spacing" value="0.12"/>

<xacro:property name="rod_radius" value="0.005"/>
<xacro:property name="rod_length" value="0.25"/>
<xacro:property name="rod_mass" value="0.055"/>

<xacro:property name="motor_depth" value="0.041"/>
<xacro:property name="motor_width" value="0.041"/>
<xacro:property name="motor_height" value="0.041"/>
<xacro:property name="motor_mass" value="0.319"/>
<xacro:property name="motor_wheel_clearance" value="0.002"/>

<xacro:property name="wheel_mass" value="0.055"/>
<xacro:property name="wheel_radius" value="0.0415"/>
<xacro:property name="wheel_width" value="0.035"/>

<xacro:property name="first_layer_gap" value="${1/2*(layer_height+motor_height) + wheel_radius}"/>

<xacro:macro name="cuboid_inertia" params="mass depth width height">
<inertia ixx="${1/12 * mass * ((width * width) + (height * height))}" ixy="0" ixz="0" 
     iyy="${1/12 * mass * ((depth * depth) + (height * height))}" iyz="0" 
     izz="${1/12 * mass * ((width * width) + (depth * depth))}" />

<xacro:macro name="wheel_inertia" params="mass radius length">
<inertia ixx="${1/12 * mass * (3 * (radius * radius) + (length * length))}" ixy="0" ixz="0" 
     iyy="${1/12 * mass * (3 * (radius * radius) + (length * length))}" iyz="0" 
     izz="${1/2 * mass * (radius * radius)}" />

<xacro:macro name="rod_inertia" params="mass radius length">
<inertia ixx="${1/12 * mass * (3 * (radius * radius) + (length * length))}" ixy="0" ixz="0" 
     iyy="${1/2 * mass * (radius * radius)}" iyz="0" 
     izz="${1/12 * mass * (3 * (radius * radius) + (length * length))}" />

<xacro:macro name="new_layer" params="number">
    <link name="layer_${number}">
                <box size="${layer_depth} ${layer_width} ${layer_height}"/>
                <box size="${layer_depth} ${layer_width} ${layer_height}"/>
            <mass value="${layer_mass}"/>
            <origin xyz="0 0 ${first_layer_gap + (number * layer_spacing)}" rpy="0 0 0"/>
            <xacro:cuboid_inertia mass="${layer_mass}" depth="${layer_depth}" width="${layer_width}" height="${layer_height}"/>

<xacro:macro name="new_wheel" params="left_or_right">
    <link name="${left_or_right}_wheel">
                <cylinder length="${wheel_width}" radius="${wheel_radius}"/>
                <cylinder length="${wheel_width}" radius="${wheel_radius}"/>
            <mass value="${layer_mass}"/>
            <!--<origin xyz="0 0 0" rpy="0 0 0"/>-->
            <xacro:wheel_inertia mass="${wheel_mass}" radius="${wheel_radius ...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-07-20 20:22:54 -0500

Youssef_Lah gravatar image

In this link you will find how to use many gazebo plugins for ROS2 including diff_drive.

Here is an example of how to use diff_drive in ROS2 that worked for me (I assume that you have a valid URDF):

  <plugin name="diff_drive" filename="">


            <!-- wheels -->

            <!-- kinematics -->

            <!-- limits -->


            <!-- output -->

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



Asked: 2021-07-20 09:14:47 -0500

Seen: 36 times

Last updated: Jul 20