0
$\begingroup$

Rosanswers logo

I'm just getting started with ROS Kinetic and trying to design and simulate a simple designed four-wheeled driving robot. In the xacro/urdf file, I defined it to consist of four wheels and a rectangular chassis. When I opened this model in Rviz, I can see that the model is connected as expected, with all four wheels attached to the chassis.

However, when I spawn the same robot in Gazebo (referencing the same xacro file), the chassis is connected to two of the wheels (due to the two joint types defined as 'fixed'). The other two wheels is 'not' connected and the chassis is on ground plane next to the two wheels (with the joint type defined as 'continuous'). When trying to simulate driving this model using ROS's teleop_twist_keyboard package, the motion of the two 'fixed' wheels don't move (connected to the chassis), and the other two wheels will move the whole body while revolving against 'air'. Below is a video of the simulation: https://youtu.be/nWNa54ZzeXE

Xacro File of the Robot:

<?xml version="1.0" ?>
<robot name="two_wheel_robot" xmlns:xacro="http://www.ros.org/wiki/xacro">
  <material name="black">
    <color rgba="0.0 0.0 0.0 1.0"/>
  </material>
  <material name="blue">
    <color rgba="0.203125 0.23828125 0.28515625 1.0"/>
  </material>
  <material name="green">
    <color rgba="0.0 0.8 0.0 1.0"/>
  </material>
  <material name="grey">
    <color rgba="0.2 0.2 0.2 1.0"/>
  </material>
  <material name="orange">
    <color rgba="1.0 0.423529411765 0.0392156862745 1.0"/>
  </material>
  <material name="brown">
    <color rgba="0.870588235294 0.811764705882 0.764705882353 1.0"/>
  </material>
  <material name="red">
    <color rgba="0.80078125 0.12890625 0.1328125 1.0"/>
  </material>
  <material name="white">
    <color rgba="1.0 1.0 1.0 1.0"/>
  </material>
  <gazebo reference="link_chassis">
    <material>Gazebo/Orange</material>
  </gazebo>
  <gazebo reference="link_left_wheel">
    <material>Gazebo/Blue</material>
  </gazebo>
  <gazebo reference="link_right_wheel">
    <material>Gazebo/Blue</material>
  </gazebo>
  <gazebo>
    <plugin filename="libgazebo_ros_diff_drive.so" name="differential_drive_controller">
      <legacyMode>false</legacyMode>
      <alwaysOn>true</alwaysOn>
      <updateRate>20</updateRate>
      <leftJoint>joint_left_wheel</leftJoint>
      <rightJoint>joint_right_wheel</rightJoint>
      <rightJoint>front_joint_right_wheel</rightJoint>
      <leftJoint>front_joint_left_wheel</leftJoint>
      <wheelSeparation>0.2</wheelSeparation>
      <wheelDiameter>0.2</wheelDiameter>
      <torque>0.5</torque>
      <commandTopic>cmd_vel</commandTopic>
      <odometryTopic>odom</odometryTopic>
      <odometryFrame>odom</odometryFrame>
      <robotBaseFrame>link_chassis</robotBaseFrame>
    </plugin>
  </gazebo>
  <link name="link_chassis">
    <!-- pose and inertial -->
    <pose>0 0 0.1 0 0 0</pose>
    <inertial>
      <mass value="5"/>
      <origin rpy="0 0 0" xyz="0 0 0.1"/>
      <inertia ixx="0.0395416666667" ixy="0" ixz="0" iyy="0.106208333333" iyz="0" izz="0.106208333333"/>
    </inertial>
    <!-- body -->
    <collision name="collision_chassis">
      <geometry>
        <box size="1.0 0.6 0.07"/>
      </geometry>
    </collision>
    <visual>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <geometry>
        <box size="1.0 0.6 0.07"/>
      </geometry>
      <material name="blue"/>
    </visual>
  </link>
  <link name="link_right_wheel">
    <inertial>
      <mass value="0.2"/>
      <origin rpy="0 1.5707 1.5707" xyz="-0.15 0.15 0"/>
      <inertia ixx="0.000526666666667" ixy="0" ixz="0" iyy="0.000526666666667" iyz="0" izz="0.001"/>
    </inertial>
    <collision name="link_right_wheel_collision">
      <origin rpy="0 1.5707 1.5707" xyz="-0.15 0.15 0"/>
      <geometry>
        <cylinder length="0.04" radius="0.1"/>
      </geometry>
    </collision>
    <visual name="link_right_wheel_visual">
      <origin rpy="0 1.5707 1.5707" xyz="-0.15 0.15 0"/>
      <geometry>
        <cylinder length="0.06" radius="0.1"/>
      </geometry>
    </visual>
  </link>
  <joint name="joint_right_wheel" type="continuous">
  <!-- <joint name="joint_right_wheel" type="fixed"> -->
    <origin rpy="0 0 0" xyz="-0.15 0.15 0"/>
    <child link="link_right_wheel"/>
    <parent link="link_chassis"/>
    <axis rpy="0 0 0" xyz="0 1 0"/>
    <limit effort="10000" velocity="1000"/>
    <joint_properties damping="1.0" friction="1.0"/>
  </joint>
  <link name="link_left_wheel">
    <inertial>
      <mass value="0.2"/>
      <origin rpy="0 1.5707 1.5707" xyz="-0.15 -0.15 0"/>
      <inertia ixx="0.000526666666667" ixy="0" ixz="0" iyy="0.000526666666667" iyz="0" izz="0.001"/>
    </inertial>
    <collision name="link_left_wheel_collision">
      <origin rpy="0 1.5707 1.5707" xyz="-0.15 -0.15 0"/>
      <geometry>
        <cylinder length="0.04" radius="0.1"/>
      </geometry>
    </collision>
    <visual name="link_left_wheel_visual">
      <origin rpy="0 1.5707 1.5707" xyz="-0.15 -0.15 0"/>
      <geometry>
        <cylinder length="0.06" radius="0.1"/>
      </geometry>
    </visual>
  </link>
  <joint name="joint_left_wheel" type="continuous">
  <!-- <joint name="joint_left_wheel" type="fixed"> -->
    <origin rpy="0 0 0" xyz="-0.15 -0.15 0"/>
    <child link="link_left_wheel"/>
    <parent link="link_chassis"/>
    <axis rpy="0 0 0" xyz="0 1 0"/>
    <limit effort="10000" velocity="1000"/>
    <joint_properties damping="1.0" friction="1.0"/>
  </joint>


  <link name="front_link_right_wheel">
    <inertial>
      <mass value="0.2"/>
      <origin rpy="0 1.5707 1.5707" xyz="0.15 0.15 0"/>
      <inertia ixx="0.000526666666667" ixy="0" ixz="0" iyy="0.000526666666667" iyz="0" izz="0.001"/>
    </inertial>
    <collision name="front_link_right_wheel_collision">
      <origin rpy="0 1.5707 1.5707" xyz="0.15 0.15 0"/>
      <geometry>
        <cylinder length="0.04" radius="0.1"/>
      </geometry>
    </collision>
    <visual name="front_link_right_wheel_visual">
      <origin rpy="0 1.5707 1.5707" xyz="0.15 0.15 0"/>
      <geometry>
        <cylinder length="0.06" radius="0.1"/>
      </geometry>
    </visual>
  </link>
  <!-- <joint name="front_joint_right_wheel" type="continuous"> -->
  <joint name="front_joint_right_wheel" type="fixed">
    <origin rpy="0 0 0" xyz="0.15 0.15 0"/>
    <child link="front_link_right_wheel"/>
    <parent link="link_chassis"/>
    <axis rpy="0 0 0" xyz="0 1 0"/>
    <limit effort="10000" velocity="1000"/>
    <joint_properties damping="1.0" friction="1.0"/>
  </joint>
      <link name="front_link_left_wheel">
        <inertial>
          <mass value="0.2"/>
          <origin rpy="0 1.5707 1.5707" xyz="0.15 -0.15 0"/>
          <inertia ixx="0.000526666666667" ixy="0" ixz="0" iyy="0.000526666666667" iyz="0" izz="0.001"/>
        </inertial>
        <collision name="front_link_left_wheel_collision">
          <origin rpy="0 1.5707 1.5707" xyz="0.15 -0.15 0"/>
          <geometry>
            <cylinder length="0.04" radius="0.1"/>
          </geometry>

    </collision>
    <visual name="front_link_left_wheel_visual">
      <origin rpy="0 1.5707 1.5707" xyz="0.15 -0.15 0"/>
      <geometry>
        <cylinder length="0.06" radius="0.1"/>
      </geometry>
    </visual>
  </link>
  <!-- <joint name="front_joint_left_wheel" type="continuous"> -->
  <joint name="front_joint_left_wheel" type="fixed">
    <origin rpy="0 0 0" xyz="0.15 -0.15 0"/>
    <child link="front_link_left_wheel"/>
    <parent link="link_chassis"/>
    <axis rpy="0 0 0" xyz="0 1 0"/>
    <limit effort="10000" velocity="1000"/>
    <joint_properties damping="1.0" friction="1.0"/>
  </joint>
</robot>

Originally posted by ros_aaron on ROS Answers with karma: 3 on 2020-04-15

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You moved the link collision and visual relative to the joint axis, you probably shoud fix your front wheels so they aren't fixed. This should be less froglike:

<?xml version="1.0" ?>
<robot name="two_wheel_robot" xmlns:xacro="http://www.ros.org/wiki/xacro">
  <material name="black">
    <color rgba="0.0 0.0 0.0 1.0"/>
  </material>
  <material name="blue">
    <color rgba="0.203125 0.23828125 0.28515625 1.0"/>
  </material>
  <material name="green">
    <color rgba="0.0 0.8 0.0 1.0"/>
  </material>
  <material name="grey">
    <color rgba="0.2 0.2 0.2 1.0"/>
  </material>
  <material name="orange">
    <color rgba="1.0 0.423529411765 0.0392156862745 1.0"/>
  </material>
  <material name="brown">
    <color rgba="0.870588235294 0.811764705882 0.764705882353 1.0"/>
  </material>
  <material name="red">
    <color rgba="0.80078125 0.12890625 0.1328125 1.0"/>
  </material>
  <material name="white">
    <color rgba="1.0 1.0 1.0 1.0"/>
  </material>
  <gazebo reference="link_chassis">
    <material>Gazebo/Orange</material>
  </gazebo>
  <gazebo reference="link_left_wheel">
    <material>Gazebo/Blue</material>
  </gazebo>
  <gazebo reference="link_right_wheel">
    <material>Gazebo/Blue</material>
  </gazebo>
  <gazebo>
    <plugin filename="libgazebo_ros_diff_drive.so" name="differential_drive_controller">
      <legacyMode>false</legacyMode>
      <alwaysOn>true</alwaysOn>
      <updateRate>20</updateRate>
      <leftJoint>joint_left_wheel</leftJoint>
      <rightJoint>joint_right_wheel</rightJoint>
      <rightJoint>front_joint_right_wheel</rightJoint>
      <leftJoint>front_joint_left_wheel</leftJoint>
      <wheelSeparation>0.2</wheelSeparation>
      <wheelDiameter>0.2</wheelDiameter>
      <torque>0.5</torque>
      <commandTopic>cmd_vel</commandTopic>
      <odometryTopic>odom</odometryTopic>
      <odometryFrame>odom</odometryFrame>
      <robotBaseFrame>link_chassis</robotBaseFrame>
    </plugin>
  </gazebo>
  <link name="link_chassis">
    <!-- pose and inertial -->
    <pose>0 0 0.1 0 0 0</pose>
    <inertial>
      <mass value="5"/>
      <origin rpy="0 0 0" xyz="0 0 0.1"/>
      <inertia ixx="0.0395416666667" ixy="0" ixz="0" iyy="0.106208333333" iyz="0" izz="0.106208333333"/>
    </inertial>
    <!-- body -->
    <collision name="collision_chassis">
      <geometry>
        <box size="1.0 0.6 0.07"/>
      </geometry>
    </collision>
    <visual>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <geometry>
        <box size="1.0 0.6 0.07"/>
      </geometry>
      <material name="blue"/>
    </visual>
  </link>
  <link name="link_right_wheel">
    <inertial>
      <mass value="0.2"/>
      <origin rpy="0 1.5707 1.5707" xyz="0 0 0"/>
      <inertia ixx="0.000526666666667" ixy="0" ixz="0" iyy="0.000526666666667" iyz="0" izz="0.001"/>
    </inertial>
    <collision name="link_right_wheel_collision">
      <origin rpy="0 1.5707 1.5707" xyz="0 0 0"/>
      <geometry>
        <cylinder length="0.04" radius="0.1"/>
      </geometry>
    </collision>
    <visual name="link_right_wheel_visual">
      <origin rpy="0 1.5707 1.5707" xyz="0 0 0"/>
      <geometry>
        <cylinder length="0.06" radius="0.1"/>
      </geometry>
    </visual>
  </link>
  <joint name="joint_right_wheel" type="continuous">
  <!-- <joint name="joint_right_wheel" type="fixed"> -->
    <origin rpy="0 0 0" xyz="-0.30 0.3 0"/>
    <child link="link_right_wheel"/>
    <parent link="link_chassis"/>
    <axis rpy="0 0 0" xyz="0 1 0"/>
    <limit effort="10000" velocity="1000"/>
    <joint_properties damping="1.0" friction="1.0"/>
  </joint>
  <link name="link_left_wheel">
    <inertial>
      <mass value="0.2"/>
      <origin rpy="0 1.5707 1.5707" xyz="0 0 0"/>
      <inertia ixx="0.000526666666667" ixy="0" ixz="0" iyy="0.000526666666667" iyz="0" izz="0.001"/>
    </inertial>
    <collision name="link_left_wheel_collision">
      <origin rpy="0 1.5707 1.5707" xyz="0 0 0"/>
      <geometry>
        <cylinder length="0.04" radius="0.1"/>
      </geometry>
    </collision>
    <visual name="link_left_wheel_visual">
      <origin rpy="0 1.5707 1.5707" xyz="0 0 0"/>
      <geometry>
        <cylinder length="0.06" radius="0.1"/>
      </geometry>
    </visual>
  </link>
  <joint name="joint_left_wheel" type="continuous">
  <!-- <joint name="joint_left_wheel" type="fixed"> -->
    <origin rpy="0 0 0" xyz="-0.3 -0.3 0"/>
    <child link="link_left_wheel"/>
    <parent link="link_chassis"/>
    <axis rpy="0 0 0" xyz="0 1 0"/>
    <limit effort="10000" velocity="1000"/>
    <joint_properties damping="1.0" friction="1.0"/>
  </joint>


  <link name="front_link_right_wheel">
    <inertial>
      <mass value="0.2"/>
      <origin rpy="0 1.5707 1.5707" xyz="0.15 0.15 0"/>
      <inertia ixx="0.000526666666667" ixy="0" ixz="0" iyy="0.000526666666667" iyz="0" izz="0.001"/>
    </inertial>
    <collision name="front_link_right_wheel_collision">
      <origin rpy="0 1.5707 1.5707" xyz="0.15 0.15 0"/>
      <geometry>
        <cylinder length="0.04" radius="0.1"/>
      </geometry>
    </collision>
    <visual name="front_link_right_wheel_visual">
      <origin rpy="0 1.5707 1.5707" xyz="0.15 0.15 0"/>
      <geometry>
        <cylinder length="0.06" radius="0.1"/>
      </geometry>
    </visual>
  </link>
  <!-- <joint name="front_joint_right_wheel" type="continuous"> -->
  <joint name="front_joint_right_wheel" type="fixed">
    <origin rpy="0 0 0" xyz="0.15 0.15 0"/>
    <child link="front_link_right_wheel"/>
    <parent link="link_chassis"/>
    <axis rpy="0 0 0" xyz="0 1 0"/>
    <limit effort="10000" velocity="1000"/>
    <joint_properties damping="1.0" friction="1.0"/>
  </joint>
      <link name="front_link_left_wheel">
        <inertial>
          <mass value="0.2"/>
          <origin rpy="0 1.5707 1.5707" xyz="0.15 -0.15 0"/>
          <inertia ixx="0.000526666666667" ixy="0" ixz="0" iyy="0.000526666666667" iyz="0" izz="0.001"/>
        </inertial>
        <collision name="front_link_left_wheel_collision">
          <origin rpy="0 1.5707 1.5707" xyz="0.15 -0.15 0"/>
          <geometry>
            <cylinder length="0.04" radius="0.1"/>
          </geometry>

    </collision>
    <visual name="front_link_left_wheel_visual">
      <origin rpy="0 1.5707 1.5707" xyz="0.15 -0.15 0"/>
      <geometry>
        <cylinder length="0.06" radius="0.1"/>
      </geometry>
    </visual>
  </link>
  <!-- <joint name="front_joint_left_wheel" type="continuous"> -->
  <joint name="front_joint_left_wheel" type="fixed">
    <origin rpy="0 0 0" xyz="0.15 -0.15 0"/>
    <child link="front_link_left_wheel"/>
    <parent link="link_chassis"/>
    <axis rpy="0 0 0" xyz="0 1 0"/>
    <limit effort="10000" velocity="1000"/>
    <joint_properties damping="1.0" friction="1.0"/>
  </joint>
</robot>

Originally posted by bob-ROS with karma: 525 on 2020-04-16

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by ros_aaron on 2020-04-16:
Thanks @bob-ROS. That and changing the joint type to 'continuous' helped fixed the issue with the frog-like movement.

I still have one side of the chassis still sagging towards the ground plane. When I drive forward, it is fine but not able to turn left and right. I can still reverse, but it takes more time and a much wider(and less desirable) angle. Any suggestions on what I can do to change/fix this.

I've attached a link to a video for the results I'm getting now: https://www.youtube.com/watch?v=ZT62yeYip8Y

$\endgroup$

Your Answer

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