Ask Your Question
0

How to move 4 wheeled robot

asked 2020-12-14 04:47:27 -0500

sisko gravatar image

updated 2020-12-14 21:25:20 -0500

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 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-12-14 09:08:03 -0500

tryan gravatar image

updated 2020-12-15 09:25:17 -0500

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.

edit flag offensive delete link more

Comments

1

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.

sisko gravatar image sisko  ( 2020-12-15 15:05:21 -0500 )edit

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.

jcjmagno gravatar image jcjmagno  ( 2020-12-16 20:05:37 -0500 )edit

@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

sisko gravatar image sisko  ( 2020-12-16 20:15:34 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-12-14 04:47:27 -0500

Seen: 678 times

Last updated: Dec 15 '20