Rotation error and strange behavior in Gazebo simulation

asked 2015-03-15 16:35:36 -0500

Naman gravatar image

Hi all,

I wrote a basic URDF model for a robot with two wheels at the back and one caster wheel at the front. Then, I am using "turtlesim teleop" to control the robot using the keyboard. But the robot is not behaving as expected while turning and going in reverse, please see the video attached. While turning, the motion is not smooth whereas while reversing, it is behaving really strange. I have tried changing the values of different parameters (including friction, etc.) but with no success. In the video, the robot first goes straight, then turns right, then turns left, then goes straight and then reverse. The link to the video: https://www.youtube.com/watch?v=JOSOX...

The relevant code:

drsim.xacro

<?xml version="1.0"?>

<robot name="drsim" xmlns:xacro="http://www.ros.org/wiki/xacro">


<xacro:property name="PI" value="3.1415926535897931"/>

<xacro:property name="chassisHeight" value="0.1"/>
<xacro:property name="chassisLength" value="0.4"/>
<xacro:property name="chassisWidth" value="0.2"/>
<xacro:property name="chassisMass" value="50"/>

<xacro:property name="casterRadius" value="0.05"/>
<xacro:property name="casterMass" value="5"/>

<xacro:property name="wheelWidth" value="0.05"/>
<xacro:property name="wheelRadius" value="0.1"/>
<xacro:property name="wheelPos" value="0.1"/>
<xacro:property name="wheelMass" value="5"/>

<xacro:include filename="$(find drsim_description)/urdf/drsim.gazebo" />
<xacro:include filename="$(find drsim_description)/urdf/materials.xacro" />
<xacro:include filename="$(find drsim_description)/urdf/macros.xacro" />

<link name='base_link'>
    <collision>
        <origin xyz="0 0 ${2*casterRadius + chassisHeight/2}" rpy="0 0 0" />
        <geometry>
            <box size="${chassisLength} ${chassisWidth} ${chassisHeight}" />
        </geometry>
    </collision>
    <visual>
        <origin xyz="0 0 ${2*casterRadius + chassisHeight/2}" rpy="0 0 0" />
        <geometry>
            <box size="${chassisLength} ${chassisWidth} ${chassisHeight}" />
        </geometry>
        <material name="orange" />
    </visual>
</link>

<joint name="base_caster_joint" type="fixed">
    <parent link="base_link" />
    <child link="caster_wheel" />
</joint>

<link name="caster_wheel">
    <collision>
        <origin xyz="${chassisLength/2 - casterRadius} 0 ${casterRadius}" rpy="0 0 0"/>
        <geometry>
            <sphere radius="${casterRadius}" />
        </geometry>
    </collision>
    <visual>
        <origin xyz="${chassisLength/2 - casterRadius} 0 ${casterRadius}" rpy="0 0 0"/>
        <geometry>
            <sphere radius="${casterRadius}" />
        </geometry>
        <material name="red" />
    </visual>
    <inertial>
        <origin xyz="${chassisLength/2 - casterRadius} 0 ${casterRadius}" rpy="0 0 0"/>
        <mass value="${casterMass}"/>
        <sphere_inertia m="${casterMass}" r="${casterRadius}"/>
    </inertial>
</link>

<wheel lr="left" tY="1"/>
<wheel lr="right" tY="-1"/>

</robot>

macros.xacro

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

<macro name="box_inertia" params="m x y z">
<inertia  ixx="${m*(y*y+z*z)/12}" ixy = "0" ixz = "0"
  iyy="${m*(x*x+z*z)/12}" iyz = "0"
  izz="${m*(x*x+z*z)/12}"
/>
</macro>

<macro name="sphere_inertia" params="m r">
<inertia  ixx="${2*m*r*r/5}" ixy = "0" ixz = "0"
  iyy="${2*m*r*r/5}" iyz = "0"
  izz="${2*m*r*r/5}"
/>
</macro>

<macro name="cylinder_inertia" params="m r h">
<inertia  ixx="${m*(3*r*r+h*h)/12}" ixy = "0" ixz = "0"
  iyy="${m*(3*r*r+h*h)/12}" iyz = "0"
  izz="${m*r*r/2}"
/>
</macro>


<macro name="wheel" params="lr ...
(more)
edit retag flag offensive close merge delete

Comments

What behavior do you exactly expect? The video looks ok to me.

130s gravatar image 130s  ( 2015-03-15 19:55:27 -0500 )edit

The first problem is that turning (rotating Left or Right) is not smooth, sometimes it speeds up, then slows down, I want it to be smooth and consistent. Secondly, you can easily see at the end of video that while reversing, it starts behaving in a strange manner instead of just going in reverse.

Naman gravatar image Naman  ( 2015-03-15 20:04:09 -0500 )edit
1

Have you tried individual wheel controllers instead of differential drive? Or just playing with those diffdrive parameters?

lucasw gravatar image lucasw  ( 2015-03-21 08:17:44 -0500 )edit

Problem fixed?

UserK gravatar image UserK  ( 2020-05-12 16:05:55 -0500 )edit