0
$\begingroup$

Rosanswers logo

I have created a URDF (in Xacro format) which has 4 wheels.

I added the skid-steer Gazebo plugin and amended the joints information etc. When I exeute my launch file /cmd_vel is in my topics list but my model does not move in either rviz nor gazebo when I publish commands to /cmd_vel.

Below is my xacro file:

<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="test_bot">

  <xacro:include filename="$(find sweep_bot)/urdf/sensors/camera.xacro"/>
  <xacro:include filename="$(find sweep_bot)/urdf/actuators/wheels.xacro"/>
  <xacro:include filename="$(find sweep_bot)/urdf/sensors/MultiCamera.xacro"/>

  <!-- body -->
  <xacro:property name="chasis_length" value="1.0"/>
  <xacro:property name="chasis_heigth" value="0.45"/>
  <xacro:property name="chasis_width" value="0.5"/>

  <link name="chasis">
    <inertial>
      <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
      <mass value="1.0"/>
      <inertia ixx="0.4" ixy="0.0" ixz="0.0" iyy="0.4" iyz="0.0" izz="0.2"/>
    </inertial>
    <visual name="">
      <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
      <geometry>
        <box size="${chasis_length} ${chasis_heigth} ${chasis_width}"/>
      </geometry>
      <material name="">
        <color rgba="0.0 1.0 0.0 1.0"/>
        <!-- <texture filename=""/> -->
      </material>
    </visual>
    <collision>
      <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
      <geometry>
        <box size="${chasis_length} ${chasis_heigth} ${chasis_width}"/>
      </geometry>
    </collision>
  </link>
  <gazebo reference='chasis'>
    <material>Gazebo/Orange</material>
  </gazebo>

  <!-- WHEELS -->
  <xacro:property name="wheel_radius" value="0.1"/>
  <xacro:property name="wheel_length" value="0.1"/>
  <xacro:property name="wheel_rpy" value="1.55 0.0 0.0"/>

  <xacro:macro name="wheel" params="side position flip alt">
    <xacro:property name="wheel_xyz" value="${alt * 0.3} ${flip * 0.2} -0.25"/>

    <link name="wheel_${side}_${position}">
      <inertial>
        <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
        <mass value="1.0"/>
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
      </inertial>
      <visual name="">
        <origin xyz="${wheel_xyz}" rpy="${wheel_rpy}"/>
        <geometry>
          <cylinder radius="${wheel_radius}" length="${wheel_length}"/>
        </geometry>
        <material name="">
          <color rgba="1.0 0.0 0.0 1.0"/>
          <texture filename=""/>
        </material>
      </visual>
      <collision>
        <origin xyz="${wheel_xyz}" rpy="${wheel_rpy}"/>
        <geometry>
          <cylinder radius="${wheel_radius}" length="${wheel_length}"/>
        </geometry>
      </collision>
    </link>

    <gazebo reference='"wheel_${side}_${position}'>
      <material>Gazebo/Red</material>
    </gazebo>

    <joint name="body_wheel_${side}_${position}_joint" type="revolute">
      <parent link="chasis"/>
      <child link="wheel_${side}_${position}"/>
      <limit lower="0.0" upper="0.0" effort="0.0" velocity="0.0"/>
    </joint>
  </xacro:macro>
  
  <xacro:wheel side="left" position="fore" flip='1' alt='1'/>
  <xacro:wheel side="right" position="fore" flip='-1' alt='1'/>
  <xacro:wheel side="left" position="aft" flip='1' alt='-1'/>
  <xacro:wheel side="right" position="aft" flip='-1' alt='-1'/>


  <!-- SKIP STEERING -->
  <gazebo>
    <plugin name="skid_steer_drive_controller" filename="libgazebo_ros_skid_steer_drive.so">
      <updateRate>100.0</updateRate>
      <robotNamespace>/</robotNamespace>
      <leftFrontJoint>body_wheel_left_fore_joint</leftFrontJoint>
      <rightFrontJoint>body_wheel_right_fore_joint</rightFrontJoint>
      <leftRearJoint>body_wheel_left_aft_joint</leftRearJoint>
      <rightRearJoint>body_wheel_right_aft_joint</rightRearJoint>
      <wheelSeparation>0.5</wheelSeparation>
      <wheelDiameter>0.2</wheelDiameter>
      <robotBaseFrame>chasis</robotBaseFrame>
      <torque>20</torque>
      <topicName>cmd_vel</topicName>
      <broadcastTF>true</broadcastTF>
    </plugin>
  </gazebo>
  <!--  -->

</robot>

And here is the simle launch file:

<?xml version="1.0"?>
<launch>

    <!-- PARAMETERS -->
    <param name="robot_description" command="$(find xacro)/xacro $(find test_package)/urdf/testbot.xacro"/>

    <!-- RVIZ -->
    <node name='robot_state_publisher' pkg='robot_state_publisher' type='robot_state_publisher'/>
    <node name='joint_state_publisher_gui' pkg='joint_state_publisher_gui' type='joint_state_publisher_gui'/>
    <node name='rviz' pkg='rviz' type='rviz'/>

    <!-- GAZEBO -->
    <node name='gazebo' pkg='gazebo_ros' type='gazebo'/>
    <node name='sweeper_spawn' pkg='gazebo_ros' type='spawn_model' args='-urdf -model sweeper -param robot_description'/>
        
</launch>

I would appreciate some help.

update:

Thank you @tryan. I made the correction to my wheel joint i:e continous rather than rotate. But the effect was not as expected and I still need a little help. Rather than the model moving forward, it tumbles. I attached an image below:

image description

That happens when I publish 0.1 on linear X with every other linear and angular value set to 0. I obviously expected the wheels to move the model forward uniformly in the same linear direction. I can confirm the coordinate frames on all the wheels are all oriented in the same direction, with X being the red line, as shown below: image description

I tried altering only the value of linear Y instead but the model did not move at all.

I'm not sure if this behaviour is do do with my urdf model OR if it's a steer-drive plugin configuration issue.


Originally posted by sisko on ROS Answers with karma: 247 on 2020-12-14

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

As explained in the Building a Movable Robot Model with URDF tutorial, revolute joints have strict motion limits. For something like a wheel, you probably want a continuous joint.


UPDATE

It's moving, so you almost got it! However, it appears your wheels operate on the wrong axis. When you give it a linear x motion, the wheels tumble (rotation about the wrong axis); when you give it a linear y, there's no motion (skid steer can't move sideways). If you give it an angular z, I expect the wheels to tumble in opposite directions (correct command, wrong axis). As suggested in this Gazebo answer, it may help to read the controller's source code and take an incremental approach to testing. In this case, the controller is actually behaving as expected.

The missing piece is that you can change the axis of rotation for a joint with the <axis> element as mentioned in the URDF/XML/joint documentation. The default is rotation about the x-axis, which you observed. What you want is rotation about the y-axis, so add <axis>0 1 0</axis> to your wheel joint definition.


Originally posted by tryan with karma: 1421 on 2020-12-14

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by sisko on 2020-12-15:
Thanks Tryan. I wasn't very familiar with the axis element and I had been trying to get the necessary orientation via the origin element. I really appreciate your help and the clarity of your explanation in the second paragraph of your update.

Comment by jcjmagno on 2020-12-16:
Hi. I would like to ask if your robot is now moving forward and what did you do to make it move forward? Currently having similar issues.

Comment by sisko on 2020-12-16:
@jcjmagno: Hi. If your issue is exactly like mine. setting the axis of the joint should fix it. Originaally, the wheels had been trying to rotate around the x-axis which caused it to tumble in the wrong direction. Setting the the joint to rotate around the y-axis causes the robot to move "naturally" in the right direction

$\endgroup$

Your Answer

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