Robotics StackExchange | Archived questions

Floating robot moves in rviz, not gazebo ?

I feel I should apologize before I even start this post as I'm sure I've made some wild assumptions - forgive a newbie :)

I've built a real robot based on ROS, but it doesn't do anything sophisticated as yet - one Arduino node just listens for remote control signals, converts and publishes these as Twists on /cmd_vel, and then another Arduino node picks these up and converts them to motor controller signals. The ROS master runs on a raspberry PI. Then winter arrived and I haven't taken it outside since !

So now I want to add SLAM to the mix, and decided to build a simulated version to work on. I wrote the URDF, and tried to get things working in rviz and gazebo. In rviz the robot moves around fine, though it floats above the ground plane. In gazebo, the front wheels gradually swivel around for some reason even when no movement commands are received, and while the main wheels spin in the right directions when commands are sent to /cmd_vel, the robot remains stationary. URDF below .. I don't have enough points to upload the screenshots but hope my description is sufficient..

I've been trying to find out what I'm doing wrong over the last couple of weeks but now I'm running dry ... I'd really appreciate any advice. I'm sure the wheels should touch the ground, so my positioning is wrong., and I suspect I need more parameters in the gazebo part for friction (mu ? mu2 ?).

I'm running Ubuntu 18.04 on the ROS master, and also on the remote rviz/gazebo node (an Nvidia Jetson Nano), gazebo 9.0.0, rviz 1.13.4, ROS melodic.

Thanks for any help !

David

display.launch:

<launch>

  <param name="robot_description" textfile="urdf/storm.urdf" />

  <include file="$(find gazebo_ros)/launch/empty_world.launch" />

  <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-param robot_description -urdf -model storm" />

</launch>

storm.urdf:

<?xml version="1.0"?>
<robot name="myfirst">
    <material name="black">
        <color rgba="0 0 0 2.0"/>
    </material>

    <material name="cyan">
        <color rgba="0 1.0 1.0 1.0"/>
    </material>

    <material name="silver">
        <color rgba="0.92 0.92 0.92 2.0"/>
    </material>

    <material name="magenta">
        <color rgba="1.00 0 1.0 1.0"/>
    </material>

    <material name="red">
        <color rgba="1.00 0 0.0 2.0"/>
    </material>

    <!-- the main box - this is the base reference for the robot -->

    <link name="base_link">
        <visual>
            <origin xyz="0 0 1" rpy="0 0 0" />
            <geometry>
                <box size="2 1 1" />
            </geometry>
            <material name="cyan"/>
        </visual>
        <collision>
            <origin xyz="0.5 0 0.75" rpy="0 0 0" />
            <geometry>
                <box size="3 1.75 1.75" />
            </geometry>
        </collision>
        <inertial>
            <mass value="50"/>
            <inertia ixx="7.5" ixy="0.0" ixz="0.0" iyy="8.666667" iyz="0.0" izz="4.166667"/>
        </inertial>
    </link>

    <link name="lidar">
        <visual>
            <geometry>
               <cylinder length="0.1" radius="0.2"/>
            </geometry>
            <material name="magenta"/>
        </visual>
        <inertial>
            <mass value="1.0"/>
            <inertia ixx="0.015" ixy="0.0" ixz="0.0" iyy="0.0375" iyz="0.0" izz="0.0375"/>
        </inertial>
    </link>

    <link name="main_axle">
        <visual>
            <geometry>
                <cylinder length="1.62" radius="0.1"/>
            </geometry>
            <material name="red"/>
        </visual>
        <inertial>
            <mass value="1.0"/>
            <inertia ixx="0.015" ixy="0.0" ixz="0.0" iyy="0.0375" iyz="0.0" izz="0.0375"/>
        </inertial>
    </link>

    <link name="right_side_rail_1">
        <visual>
            <geometry>
                <cylinder length="0.8" radius="0.1"/>
            </geometry>
            <material name="red"/>
        </visual>
        <inertial>
            <mass value="1.0"/>
            <inertia ixx="0.015" ixy="0.0" ixz="0.0" iyy="0.0375" iyz="0.0" izz="0.0375"/>
        </inertial>
    </link>

    <link name="right_side_rail_2">
        <visual>
            <geometry>
                <cylinder length="1.2" radius="0.1"/>
            </geometry>
            <material name="red"/>
        </visual>
        <inertial>
            <mass value="1.0"/>
            <inertia ixx="0.015" ixy="0.0" ixz="0.0" iyy="0.0375" iyz="0.0" izz="0.0375"/>
        </inertial>
    </link>

    <link name="left_side_rail_1">
        <visual>
            <geometry>
                <cylinder length="0.8" radius="0.1"/>
            </geometry>
            <material name="red"/>
        </visual>
        <inertial>
            <mass value="1.0"/>
            <inertia ixx="0.015" ixy="0.0" ixz="0.0" iyy="0.0375" iyz="0.0" izz="0.0375"/>
        </inertial>
    </link>

    <link name="left_side_rail_2">
        <visual>
            <geometry>
                <cylinder length="1.2" radius="0.1"/>
            </geometry>
            <material name="red"/>
        </visual>
        <inertial>
            <mass value="1.0"/>
            <inertia ixx="0.015" ixy="0.0" ixz="0.0" iyy="0.0375" iyz="0.0" izz="0.0375"/>
        </inertial>
    </link>

    <link name="right_stick">
        <visual>
            <geometry>
                <cylinder length="0.9" radius="0.1"/>
            </geometry>
            <material name="silver"/>
        </visual>
        <inertial>
            <mass value="1.0"/>
            <inertia ixx="0.015" ixy="0.0" ixz="0.0" iyy="0.0375" iyz="0.0" izz="0.0375"/>
        </inertial>
    </link>

    <link name="left_stick">
      <geometry>
                <cylinder length="0.9" radius="0.1"/>
            </geometry>
            <material name="silver"/>
        </visual>
        <inertial>
            <mass value="1.0"/>
            <inertia ixx="0.015" ixy="0.0" ixz="0.0" iyy="0.0375" iyz="0.0" izz="0.0375"/>
        </inertial>
    </link>

    <link name="right_front_axle">
        <visual>
            <geometry>
                <cylinder length="0.32" radius="0.1"/>
            </geometry>
            <material name="red"/>
        </visual>
        <inertial>
            <mass value="1.0"/>
            <inertia ixx="0.015" ixy="0.0" ixz="0.0" iyy="0.0375" iyz="0.0" izz="0.0375"/>
        </inertial>
    </link>

    <link name="left_front_axle">
        <visual>
            <geometry>
                <cylinder length="0.32" radius="0.1"/>
            </geometry>
            <material name="red"/>
        </visual>
        <inertial>
            <mass value="1.0"/>
            <inertia ixx="0.015" ixy="0.0" ixz="0.0" iyy="0.0375" iyz="0.0" izz="0.0375"/>
        </inertial>
    </link>

    <link name="cross_rail">
        <visual>
            <geometry>
                <cylinder length="1.4" radius="0.1"/>
            </geometry>
            <material name="red"/>
        </visual>
        <inertial>
            <mass value="1.0"/>
            <inertia ixx="0.015" ixy="0.0" ixz="0.0" iyy="0.0375" iyz="0.0" izz="0.0375"/>
        </inertial>
    </link>

    <!-- wheels -->

    <link name="right_main_wheel">
        <visual>
            <geometry>
                <cylinder length="0.1" radius="0.5"/>
            </geometry>
            <material name="black"/>
        </visual>
        <inertial>
            <mass value="5.0"/>
            <inertia ixx="0.030792" ixy="0.0" ixz="0.0" iyy="0.030792" iyz="0.0" izz="0.05625"/>
        </inertial>
    </link>

    <link name="left_main_wheel">
        <visual>
            <geometry>
                <cylinder length="0.1" radius="0.5"/>
            </geometry>
            <material name="black"/>
        </visual>
        <inertial>
            <mass value="5.0"/>
            <inertia ixx="0.030792" ixy="0.0" ixz="0.0" iyy="0.030792" iyz="0.0" izz="0.05625"/>
        </inertial>
    </link>

    <link name="right_front_wheel">
        <visual>
            <geometry>
                <cylinder length="0.1" radius="0.25"/>
            </geometry>
            <material name="black"/>
        </visual>
        <inertial>
            <mass value="1.0"/>
            <inertia ixx="0.003808" ixy="0.0" ixz="0.0" iyy="0.003808" iyz="0.0" izz="0.072"/>
        </inertial>
    </link>

    <link name="left_front_wheel">
        <visual>
            <geometry>
                <cylinder length="0.1" radius="0.25"/>
            </geometry>
            <material name="black"/>
        </visual>
        <inertial>
            <mass value="1.0"/>
            <inertia ixx="0.003808" ixy="0.0" ixz="0.0" iyy="0.003808" iyz="0.0" izz="0.072"/>
        </inertial>
    </link>

    <!-- lidar is mounted on top of the body, towards the front -->

    <joint name="base_to_lidar" type="fixed">
        <parent link="base_link"/>
        <child link="lidar"/>
        <origin xyz="0.75 0 1.55" rpy="0 0 0" />
    </joint>

    <!-- main axle -->

    <joint name="base_to_axle" type="fixed">
        <parent link="base_link"/>
        <child link="main_axle"/>
        <origin xyz="0 0 0.55" rpy="1.5708 1.5708 0" />
    </joint>

    <!-- frame -->

    <joint name="base_to_cross_rail" type="fixed">
        <parent link="base_link"/>
        <child link="cross_rail"/>
        <origin xyz="1.05 0 1.05" rpy="1.5708 1.5708 0" />
    </joint>

     <joint name="left_side_rail_1_to_axle" type="fixed">
        <parent link="main_axle"/>
        <child link="left_side_rail_1"/>
        <origin rpy="0.785398 1.5708 0" xyz="-0.25 0.25 -0.6"/>
    </joint>

    <joint name="right_side_rail_1_to_axle" type="fixed">
        <parent link="main_axle"/>
        <child link="right_side_rail_1"/>
        <origin rpy="0.785398 1.5708 0" xyz="-0.25 0.25 0.6"/>
    </joint>

    <joint name="right_side_rail_2_to_1" type="fixed">
        <parent link="right_side_rail_1"/>
        <child link="right_side_rail_2"/>
        <origin rpy="-2.35619 0 0" xyz="0 0.4 -0.75"/>
    </joint>

    <joint name="left_side_rail_2_to_1" type="fixed">
        <parent link="left_side_rail_1"/>
        <child link="left_side_rail_2"/>
        <origin rpy="-2.35619 0 0" xyz="0 0.4 -0.75"/>
    </joint>

    <joint name="right_swivel" type="continuous">
        <parent link="right_side_rail_2"/>
        <child link="right_stick"/>
        <axis xyz="0 0 1"/>
        <origin rpy="1.5708 0 0" xyz="0 -0.35 0.5"/>
    </joint>

    <joint name="left_swivel" type="continuous">
        <parent link="left_side_rail_2"/>
        <child link="left_stick"/>
        <axis xyz="0 0 1"/>
        <origin rpy="1.5708 0 0" xyz="0 -0.35 0.5"/>
    </joint>

    <joint name="right_stick_to_axle" type="fixed">
        <parent link="right_stick"/>
        <child link="right_front_axle"/>
        <origin rpy="1.5708 0 1.5708" xyz="-0.06 0 0.4"/>
    </joint>

    <joint name="left_stick_to_axle" type="fixed">
        <parent link="left_stick"/>
        <child link="left_front_axle"/>
      <origin rpy="1.5708 0 1.5708" xyz="0.06 0 0.4"/>
    </joint>

    <!-- wheel joints -->

    <!-- Main wheels -->

    <joint name="right_main_wheel" type="continuous">
        <parent link="main_axle"/>
        <child link="right_main_wheel"/>
        <axis xyz="0 0 1"/>
        <origin rpy="0 0 0" xyz="0.0 0.0 0.75"/>
    </joint>

    <joint name="left_main_wheel" type="continuous">
        <parent link="main_axle"/>
        <child link="left_main_wheel"/>
        <axis xyz="0 0 1"/>
        <origin rpy="0 0 0" xyz="0.0 0.0 -0.75"/>
    </joint>

    <!-- front wheels -->

    <joint name="right_front_wheel" type="continuous">
        <parent link="right_front_axle"/>
        <child link="right_front_wheel"/>
        <axis xyz="0 0 1"/>
        <origin rpy="0 0 0" xyz="0.0 0.0 -0.1"/>
    </joint>

    <joint name="left_front_wheel" type="continuous">
        <parent link="left_front_axle"/>
        <child link="left_front_wheel"/>
        <axis xyz="0 0 1"/>
        <origin rpy="0 0 0" xyz="0.0 0.0 0.1"/>
    </joint>

    <!-- Gazebo plugins -->

    <gazebo>
        <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
            <rosDebugLevel>na</rosDebugLevel>
            <commandTopic>cmd_vel</commandTopic>
            <odometryTopic>odom</odometryTopic>
            <leftJoint>left_main_wheel</leftJoint>
            <rightJoint>right_main_wheel</rightJoint>
            <robotBaseFrame>base_link</robotBaseFrame>
            <odometryFrame>odom</odometryFrame>
            <wheelSeparation>1.62</wheelSeparation>
            <wheelDiameter>1.0</wheelDiameter>
            <publishWheelJointState>true</publishWheelJointState>
            <wheelAcceleration>0</wheelAcceleration>
            <wheelTorque>5</wheelTorque>
            <updateRate>100</updateRate>
        </plugin>
    </gazebo>

    <gazebo reference="base_link">
        <material>Gazebo/Turquoise</material>
    </gazebo>

    <gazebo reference="main_axle">
        <material>Gazebo/Red</material>
    </gazebo>

    <gazebo reference="right_side_rail_1">
        <material>Gazebo/Red</material>
    </gazebo>

    <gazebo reference="right_side_rail_2">
        <material>Gazebo/Red</material>
    </gazebo>

    <gazebo reference="left_side_rail_1">
        <material>Gazebo/Red</material>
    </gazebo>

    <gazebo reference="left_side_rail_2">
        <material>Gazebo/Red</material>
    </gazebo>

    <gazebo reference="right_stick">
        <material>Gazebo/Grey</material>
    </gazebo>

    <gazebo reference="left_stick">
        <material>Gazebo/Grey</material>
    </gazebo>

    <gazebo reference="right_front_axle">
        <material>Gazebo/Red</material>
    </gazebo>

    <gazebo reference="left_front_axle">
        <material>Gazebo/Red</material>
    </gazebo>

    <gazebo reference="cross_rail">
        <material>Gazebo/Red</material>
    </gazebo>

    <gazebo reference="right_main_wheel">
        <material>Gazebo/Black</material>
    </gazebo>

    <gazebo reference="left_main_wheel">
        <material>Gazebo/Black</material>
    </gazebo>

    <gazebo reference="right_front_wheel">
        <material>Gazebo/Black</material>
    </gazebo>

    <gazebo reference="left_front_wheel">
        <material>Gazebo/Black</material>
    </gazebo>
</robot>

Asked by dmb on 2020-02-09 08:42:27 UTC

Comments

Answers

A bit of a necro, but hopefully this will be helpful to others.
Seems like you haven't entered <origin> tags on your <visual>, <collision>, and <inertial> tags where necessary.
From the wiki: links joints

<origin> (optional: defaults to identity if not specified)

So the thing that's going on here is that your link origin is at xyz="0 0 0" rpy="0 0 0" but your other given positions for the link vary, so the contact is awkward. I've suffered from a similar problem, and explicitly defining the origin helped a lot to at least place the robot on the ground. My own problem proceeding afterwards is to make the ground contact work properly, given that URDF doesn't really communicate that information easily.
Hope this helps.

Asked by juxyper on 2022-04-12 08:32:36 UTC

Comments