Home | Tutorials | Wiki | Issues
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Diff_drive Plugin Simulation Problem

Hi, I have written a urdf file for a 2 wheeled robot, but I can't seem to get it to drive properly using the diff_drive_controller gazebo plugin. Instead of driving normally, the robot somersaults in the direction that I want it to move in. Is there anything I'm doing wrong when I'm setting the conditions of the plugin? I'm new to ROS.

<?xml version="1.0"?>

<robot name="crobot">

<link name="base_link">
    <visual>
        <geometry>
            <box size="0.100 0.110 0.131"/>
        </geometry>     
        <origin xyz="0 0 0.0805"/>
    </visual>
    <collision>
        <geometry>
            <box size="0.100 0.110 0.131"/>
        </geometry> 
    </collision>
    <inertial>
        <mass value="1"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
</link>

<link name="basecenter1">
    <visual>
        <geometry>
            <box size="0.10 0.34 0.131"/>
        </geometry>
        <origin xyz="0 0 0.0805"/>
    </visual>
    <collision>
        <geometry>
            <box size="0.10 0.34 0.131"/>
        </geometry> 
    </collision>
    <inertial>
        <mass value="0.1"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
</link>

<link name="basecenter2">
    <visual>
        <geometry>
            <box size="0.330 0.110 0.131"/>
        </geometry>
        <origin xyz="0 0 0.0805"/>
    </visual>
    <collision>
        <geometry>
            <box size="0.330 0.110 0.131"/>
        </geometry> 
    </collision>
    <inertial>
        <mass value="0.1"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
</link>

<link name="blcorner">
    <visual>
        <geometry>
            <cylinder length="0.131" radius=".12"/>
        </geometry>
        <origin xyz="0 0 0.0805"/>
    </visual>
    <collision>
        <geometry>
            <cylinder length="0.131" radius=".12"/>
        </geometry> 
    </collision>
    <inertial>
        <mass value="1"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
</link>

<link name="brcorner">
    <visual>
        <geometry>
            <cylinder length="0.131" radius=".12"/>
        </geometry>
        <origin xyz="0 0 0.0805"/>
    </visual>
    <collision>
        <geometry>
            <cylinder length="0.131" radius=".12"/>
        </geometry> 
    </collision>
    <inertial>
        <mass value="1"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
</link>

<link name="flcorner">
    <visual>
        <geometry>
            <cylinder length="0.131" radius=".11"/>
        </geometry>
        <origin xyz="0 0 0.0805"/>
    </visual>
    <collision>
        <geometry>
            <cylinder length="0.131" radius=".11"/>
        </geometry> 
    </collision>
    <inertial>
        <mass value="1"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
</link>

<link name="frcorner">
    <visual>
        <geometry>
            <cylinder length="0.131" radius=".11"/>
        </geometry>
        <origin xyz="0 0 0.0805"/>
    </visual>
    <collision>
        <geometry>
            <cylinder length="0.131" radius=".11"/>
        </geometry> 
    </collision>
    <inertial>
        <mass value="1"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
</link>

<link name="lwheel">
    <visual>
        <geometry>
            <cylinder length="0.018" radius="0.0325"/>
        </geometry>
        <origin rpy="0 1.570796 0" xyz="0 0 0"/>
        <material name="blue">
            <color rgba="0 0 .8 1"/>
        </material>
    </visual>
    <collision>
        <geometry>
            <cylinder length="0.018" radius="0.0325"/> 
            <!--radius="0.0325"-->
        </geometry> 
    </collision>
    <inertial>
        <mass value="0.5"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
    <gazebo>
        <selfCollide>false</selfCollide>
    </gazebo>
</link>

<link name="rwheel">
    <visual>
        <geometry>
            <cylinder length="0.018" radius="0.0325"/>
        </geometry>
        <origin rpy="0 1.570796 0" xyz="0 0 0"/>
        <material name="blue">
            <color rgba="0 0 .8 1"/>
        </material>
    </visual>
    <collision>
        <geometry>
            <cylinder length="0.018" radius="0.0325"/>
            <!--radius="0.0325"-->
        </geometry> 
    </collision>
    <inertial>
        <mass value="0.5"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
    <gazebo>
        <selfCollide>false</selfCollide>
    </gazebo>
</link>

<joint name="base_lwheel" type="continuous">
    <parent link="base_link"/>
    <child link="lwheel"/>
    <origin xyz="-0.130 0 0.0325" rpy="-1.570796 0 0"/>
</joint>
<joint name="base_rwheel" type="continuous">
    <parent link="base_link"/>
    <child link="rwheel"/>
    <origin xyz="0.130 0 0.0325" rpy="-1.570796 0 0"/>
</joint>

<joint name="base_basecenter1" type="fixed">
    <parent link="base_link"/>
    <child link="basecenter1"/>
    <origin xyz="0 -0.005 0"/>
</joint>
<joint name="base_basecenter2" type="fixed">
    <parent link="base_link"/>
    <child link="basecenter2"/>
    <origin xyz="0 0 0"/>
</joint>
<joint name="base_blcorner" type="fixed">
    <parent link="base_link"/>
    <child link="blcorner"/>
    <origin xyz="-0.05 -0.055 0"/>
</joint>
<joint name="base_brcorner" type="fixed">
    <parent link="base_link"/>
    <child link="brcorner"/>
    <origin xyz="0.05 -0.055 0"/>
</joint>
<joint name="base_flcorner" type="fixed">
    <parent link="base_link"/>
    <child link="flcorner"/>
    <origin xyz="-0.05 0.055 0"/>
</joint>
<joint name="base_frcorner" type="fixed">
    <parent link="base_link"/>
    <child link="frcorner"/>
    <origin xyz="0.05 0.055 0"/>
</joint>

<gazebo>
    <plugin name="diff_drive_controller" filename="libgazebo_ros_diff_drive.so">
        <rosDebugLevel>false</rosDebugLevel>
        <alwaysOn>true</alwaysOn>
        <publishWheelJointState>true</publishWheelJointState>
        <updateRate>100.0</updateRate>
        <leftJoint>base_lwheel</leftJoint>
        <rightJoint>base_rwheel</rightJoint>
        <wheelSeparation>0.26</wheelSeparation>
        <wheelDiameter>0.065</wheelDiameter>
        <wheelAcceleration>1</wheelAcceleration>
        <wheelTorque>20</wheelTorque>
        <commandTopic>cmd_vel</commandTopic>
        <odometryTopic>odom</odometryTopic>
        <odometryFrame>odom</odometryFrame>
        <robotBaseFrame>base_link</robotBaseFrame>
    </plugin>
</gazebo>

</robot>

Diff_drive Plugin Simulation Problem

Hi, I have written a urdf file for a 2 wheeled robot, but I can't seem to get it to drive properly using the diff_drive_controller gazebo plugin. Instead of driving normally, the robot somersaults in the direction that I want it to move in. Is there anything I'm doing wrong when I'm setting the conditions of the plugin? I'm new to ROS.

<?xml version="1.0"?>

<robot name="crobot">

name="crobot">

<link name="base_link">
    <visual>
        <geometry>
            <box size="0.100 0.110 0.131"/>
        </geometry>     
        <origin xyz="0 0 0.0805"/>
    </visual>
    <collision>
        <geometry>
            <box size="0.100 0.110 0.131"/>
        </geometry> 
    </collision>
    <inertial>
        <mass value="1"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
</link>

<link name="basecenter1">
    <visual>
        <geometry>
            <box size="0.10 0.34 0.131"/>
        </geometry>
        <origin xyz="0 0 0.0805"/>
    </visual>
    <collision>
        <geometry>
            <box size="0.10 0.34 0.131"/>
        </geometry> 
    </collision>
    <inertial>
        <mass value="0.1"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
</link>

<link name="basecenter2">
    <visual>
        <geometry>
            <box size="0.330 0.110 0.131"/>
        </geometry>
        <origin xyz="0 0 0.0805"/>
    </visual>
    <collision>
        <geometry>
            <box size="0.330 0.110 0.131"/>
        </geometry> 
    </collision>
    <inertial>
        <mass value="0.1"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
</link>

<link name="blcorner">
    <visual>
        <geometry>
            <cylinder length="0.131" radius=".12"/>
        </geometry>
        <origin xyz="0 0 0.0805"/>
    </visual>
    <collision>
        <geometry>
            <cylinder length="0.131" radius=".12"/>
        </geometry> 
    </collision>
    <inertial>
        <mass value="1"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
</link>

<link name="brcorner">
    <visual>
        <geometry>
            <cylinder length="0.131" radius=".12"/>
        </geometry>
        <origin xyz="0 0 0.0805"/>
    </visual>
    <collision>
        <geometry>
            <cylinder length="0.131" radius=".12"/>
        </geometry> 
    </collision>
    <inertial>
        <mass value="1"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
</link>

<link name="flcorner">
    <visual>
        <geometry>
            <cylinder length="0.131" radius=".11"/>
        </geometry>
        <origin xyz="0 0 0.0805"/>
    </visual>
    <collision>
        <geometry>
            <cylinder length="0.131" radius=".11"/>
        </geometry> 
    </collision>
    <inertial>
        <mass value="1"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
</link>

<link name="frcorner">
    <visual>
        <geometry>
            <cylinder length="0.131" radius=".11"/>
        </geometry>
        <origin xyz="0 0 0.0805"/>
    </visual>
    <collision>
        <geometry>
            <cylinder length="0.131" radius=".11"/>
        </geometry> 
    </collision>
    <inertial>
        <mass value="1"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
</link>

<link name="lwheel">
    <visual>
        <geometry>
            <cylinder length="0.018" radius="0.0325"/>
        </geometry>
        <origin rpy="0 1.570796 0" xyz="0 0 0"/>
        <material name="blue">
            <color rgba="0 0 .8 1"/>
        </material>
    </visual>
    <collision>
        <geometry>
            <cylinder length="0.018" radius="0.0325"/> 
            <!--radius="0.0325"-->
        </geometry> 
    </collision>
    <inertial>
        <mass value="0.5"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
    <gazebo>
        <selfCollide>false</selfCollide>
    </gazebo>
</link>

<link name="rwheel">
    <visual>
        <geometry>
            <cylinder length="0.018" radius="0.0325"/>
        </geometry>
        <origin rpy="0 1.570796 0" xyz="0 0 0"/>
        <material name="blue">
            <color rgba="0 0 .8 1"/>
        </material>
    </visual>
    <collision>
        <geometry>
            <cylinder length="0.018" radius="0.0325"/>
            <!--radius="0.0325"-->
        </geometry> 
    </collision>
    <inertial>
        <mass value="0.5"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
    <gazebo>
        <selfCollide>false</selfCollide>
    </gazebo>
</link>

<joint name="base_lwheel" type="continuous">
    <parent link="base_link"/>
    <child link="lwheel"/>
    <origin xyz="-0.130 0 0.0325" rpy="-1.570796 0 0"/>
</joint>
<joint name="base_rwheel" type="continuous">
    <parent link="base_link"/>
    <child link="rwheel"/>
    <origin xyz="0.130 0 0.0325" rpy="-1.570796 0 0"/>
</joint>

<joint name="base_basecenter1" type="fixed">
    <parent link="base_link"/>
    <child link="basecenter1"/>
    <origin xyz="0 -0.005 0"/>
</joint>
<joint name="base_basecenter2" type="fixed">
    <parent link="base_link"/>
    <child link="basecenter2"/>
    <origin xyz="0 0 0"/>
</joint>
<joint name="base_blcorner" type="fixed">
    <parent link="base_link"/>
    <child link="blcorner"/>
    <origin xyz="-0.05 -0.055 0"/>
</joint>
<joint name="base_brcorner" type="fixed">
    <parent link="base_link"/>
    <child link="brcorner"/>
    <origin xyz="0.05 -0.055 0"/>
</joint>
<joint name="base_flcorner" type="fixed">
    <parent link="base_link"/>
    <child link="flcorner"/>
    <origin xyz="-0.05 0.055 0"/>
</joint>
<joint name="base_frcorner" type="fixed">
    <parent link="base_link"/>
    <child link="frcorner"/>
    <origin xyz="0.05 0.055 0"/>
</joint>

<gazebo>
    <plugin name="diff_drive_controller" filename="libgazebo_ros_diff_drive.so">
        <rosDebugLevel>false</rosDebugLevel>
        <alwaysOn>true</alwaysOn>
        <publishWheelJointState>true</publishWheelJointState>
        <updateRate>100.0</updateRate>
        <leftJoint>base_lwheel</leftJoint>
        <rightJoint>base_rwheel</rightJoint>
        <wheelSeparation>0.26</wheelSeparation>
        <wheelDiameter>0.065</wheelDiameter>
        <wheelAcceleration>1</wheelAcceleration>
        <wheelTorque>20</wheelTorque>
        <commandTopic>cmd_vel</commandTopic>
        <odometryTopic>odom</odometryTopic>
        <odometryFrame>odom</odometryFrame>
        <robotBaseFrame>base_link</robotBaseFrame>
    </plugin>
</gazebo>

</robot>