0
$\begingroup$

I am building a 4 wheel differential drive robot. The robot is not moving left or right in gazebo, although it is moving forward and backward. The robot is moving completely fine in rviz2(forward, backward, left, right).

Version: ros2 foxy

Here is the urdf:

<?xml version="1.0"?>
<xacro:include filename="inertial_macros.xacro"/>

<material name="white">
    <color rgba="1 1 1 1" />
</material>

<material name="orange">
    <color rgba="1 0.3 0.1 1" />
</material>

<material name="blue">
    <color rgba="0.2 0.2 1 1" />
</material>

<material name="black">
    <color rgba="0 0 0 1" />
</material>


<!-- BASE LINK -->
<link name="base_link">

</link>


<!-- CHASSI LINK -->
<joint name="chassis_joint" type="fixed">
    <parent link="base_link"/>
    <child link="chassis"/>
    <origin xyz="-0.1 0 0"/>
</joint>

<link name="chassis">
    <visual>
        <!-- <origin xyz="0.15 0 0.075"/>   # This line is used to move the chasis relative to its link -->
        <geometry>
            <box size="0.5 0.3 0.05"/>
        </geometry>
        <material name="white"/>
    </visual>

    <collision>
        <!-- <origin xyz="0.3 0 0.075"/>   0.15 0 0.075 -->
        <geometry>
            <box size="0.5 0.3 0.05"/>   <!-- <box size="0.5 0.3 0.3"/> -->
        </geometry>
    </collision>

    <xacro:inertial_box mass="0.5" x="0.5" y="0.3" z="0.05">
        <origin xyz="0 0 0" rpy="0 0 0"/>
    </xacro:inertial_box>
</link>

<gazebo reference="chassis">
    <material>Gazebo/Orange</material>
</gazebo>

<!-- LEFT FRONT WHEEL LINK -->
<joint name="left_front_wheel_joint" type="continuous">
    <parent link="base_link"/>
    <child link="left_front_wheel"/>        
    <origin xyz="0.15 0.18 0" rpy="-${pi/2} 0 0"/>
    <axis xyz="0 0 1"/>
</joint>

<link name="left_front_wheel">
    <visual>
        <geometry>
            <cylinder radius="0.1" length="0.04"/>
        </geometry>
        <material name="blue"/>
    </visual>
    <collision>
        <geometry>
            <cylinder radius="0.1" length="0.04"/>
        </geometry>
    </collision>

    <xacro:inertial_cylinder mass="0.1" length="0.04" radius="0.1">
        <origin xyz="0 0 0" rpy="0 0 0"/>
    </xacro:inertial_cylinder>
</link>

<gazebo reference="left_front_wheel">
    <material>Gazebo/Blue</material>
    <mu1 value="0.1"/>
    <mu2 value="0.1"/>
</gazebo>

<!-- RIGHT FRONT WHEEL LINK -->
<joint name="right_front_wheel_joint" type="continuous">
    <parent link="base_link"/>
    <child link="right_front_wheel"/>        
    <origin xyz="0.15 -0.18 0" rpy="${pi/2} 0 0"/>
    <axis xyz="0 0 -1"/>
</joint>

<link name="right_front_wheel">
    <visual>
        <geometry>
            <cylinder radius="0.1" length="0.04"/>
        </geometry>
        <material name="blue"/>
    </visual>
    <collision>
        <geometry>
            <cylinder radius="0.1" length="0.04"/>
        </geometry>
    </collision>    

    <xacro:inertial_cylinder mass="0.1" length="0.04" radius="0.1">
        <origin xyz="0 0 0" rpy="0 0 0"/>
    </xacro:inertial_cylinder>
</link>

<gazebo reference="right_front_wheel">
    <material>Gazebo/Blue</material>
    <mu1 value="0.1"/>
    <mu2 value="0.1"/>
</gazebo>





<!-- LEFT BACK WHEEL LINK -->
<joint name="left_back_wheel_joint" type="continuous">
    <parent link="base_link"/>
    <child link="left_back_wheel"/>        
    <origin xyz="-0.35 0.18 0" rpy="-${pi/2} 0 0"/>
    <axis xyz="0 0 1"/>
</joint>

<link name="left_back_wheel">
    <visual>
        <geometry>
            <cylinder radius="0.1" length="0.04"/>
        </geometry>
        <material name="blue"/>
    </visual>
    <collision>
        <geometry>
            <cylinder radius="0.1" length="0.04"/>
        </geometry>
    </collision>

    <xacro:inertial_cylinder mass="0.1" length="0.04" radius="0.1">
        <origin xyz="0 0 0" rpy="0 0 0"/>
    </xacro:inertial_cylinder>
</link>

<gazebo reference="left_back_wheel">
    <material>Gazebo/Blue</material>
    <mu1 value="0.1"/>
    <mu2 value="0.1"/>
</gazebo>

<!-- RIGHT BACK WHEEL LINK -->
<joint name="right_back_wheel_joint" type="continuous">
    <parent link="base_link"/>
    <child link="right_back_wheel"/>        
    <origin xyz="-0.35 -0.18 0" rpy="${pi/2} 0 0"/>
    <axis xyz="0 0 -1"/>
</joint>

<link name="right_back_wheel">
    <visual>
        <geometry>
            <cylinder radius="0.1" length="0.04"/>
        </geometry>
        <material name="blue"/>
    </visual>
    <collision>
        <geometry>
            <cylinder radius="0.1" length="0.04"/>
        </geometry>
    </collision>

    <xacro:inertial_cylinder mass="0.1" length="0.04" radius="0.1">
        <origin xyz="0 0 0" rpy="0 0 0"/>
    </xacro:inertial_cylinder>
</link>

<gazebo reference="right_back_wheel">
    <material>Gazebo/Blue</material>
    <mu1 value="0.1"/>
    <mu2 value="0.1"/>
</gazebo>

Thanks

$\endgroup$

1 Answer 1

0
$\begingroup$

I think you have to provide more details.

  • Are you using gazebo_ros2_control? Or how do you command your robot in gazebo?

  • What do you mean with left/right? If it is a differential drive robot, it only can go forward/backward and rotate.

  • And what do you mean with robot is moving fine in rivz? It only displays your robot via tf.

I can't use your URDF because it's not complete.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.