How to make ROS differential drive robot move forward with teleop?

asked 2020-12-15 22:21:12 -0500

jcjmagno gravatar image

updated 2022-04-30 13:34:03 -0500

lucasw gravatar image

Hi. I'm new to ROS and Gazebo simulation. I tried to create a differential drive robot for various experiments such sa SLAM etc.

I have set my joint to rotate on the y-axis as setting them on x or z makes them move weird. But when I try to make my robot move forward using teleop, the wheels move vertically instead of horizontally.

Tried on Ubuntu 18.04 LTS, ROS Melodic, Gazebo 9 and 20.04 LTS, ROS Noetic, Gazebo 11

EDIT: Added yaml code

EDIT2: Added launch code

Here is the relevant part of my urdf:

 <link name="base_link">
 </link>

<joint name="base_joint" type="fixed">
    <parent link="base_link"/>
    <child link="chassis"/>
</joint>

<link name="chassis">

    <inertial>
        <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
        <mass value="25"/>
        <inertia ixx="3.002" ixy="0.0" ixz="0.0" iyy="4.011" iyz="0.0" izz="2.8465"/>
    </inertial>
    <visual name="chassis_visual">
        <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
        <geometry>
            <box size="0.962 0.664 1" />
        </geometry>
    </visual>
    <collision name="chassis_collision">
        <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
        <geometry>
            <box size="0.962 0.664 1" />
        </geometry>
    </collision>
</link>

<link name="front_left_wheel">
    <inertial>
        <origin xyz="0.3 0.232 -0.525" rpy="1.5707 0.0 0.0"/>
        <mass value="5"/>
        <inertia ixx="0.02" ixy="0.0" ixz="0.0" iyy="0.02" iyz="0.0" izz="0.02"/>
    </inertial>
   <visual name="front_left_wheel_visual">
        <origin xyz="0.3 0.232 -0.525" rpy="1.5707 0.0 0.0"/>
        <geometry>
            <cylinder radius="0.1" length="0.1"/>
        </geometry>
    </visual>
    <collision name="front_left_wheel_collision">
        <origin xyz="0.3 0.232 -0.525" rpy="1.5707 0.0 0.0"/>
        <geometry>
            <cylinder radius="0.1" length="0.1"/>
        </geometry>
    </collision>
</link>

<link name="front_right_wheel">
    <inertial>
        <origin xyz="0.3 -0.232 -0.525" rpy="1.5707 0.0 0.0"/>
        <mass value="5"/>
        <inertia ixx="0.02" ixy="0.0" ixz="0.0" iyy="0.02" iyz="0.0" izz="0.02"/>
    </inertial>
    <visual name="front_right_wheel_visual">
        <origin xyz="0.3 -0.232 -0.525" rpy="1.5707 0.0 0.0"/>
        <geometry>
            <cylinder radius="0.1" length="0.1"/>
        </geometry>
    </visual>
    <collision name="front_right_wheel_collision">
        <origin xyz="0.3 -0.232 -0.525" rpy="1.5707 0.0 0.0"/>
        <geometry>
            <cylinder radius="0.1" length="0.1"/>
        </geometry>
    </collision>
</link>

<link name="rear_left_wheel">
    <inertial>
        <origin xyz="-0.3 0.232 -0.525" rpy="1.5707 0.0 0.0"/>
        <mass value="5"/>
        <inertia ixx="0.02" ixy="0.0" ixz="0.0 ...
(more)
edit retag flag offensive close merge delete

Comments

is this a duplicate of your other question #q367681? If yes, please close this one and add additional information to the other question by editing it. Thank you.

mgruhler gravatar image mgruhler  ( 2020-12-16 02:57:55 -0500 )edit

Can you post your publisher code? Are you using twist messages or Float64? In other words, are you using the ros_control plugin or the differential plugin?

patrchri gravatar image patrchri  ( 2020-12-16 10:51:42 -0500 )edit

Hi. I used this for teleop: http://wiki.ros.org/teleop_twist_keyb... I tried both ros_control and differential drive gazebo plugin When I set the joint axis to y, the wheels move upward instead of forward. When set to x, the wheels revolve around the robot vertically. When set to y, the wheels then move like a propeller.

jcjmagno gravatar image jcjmagno  ( 2020-12-16 19:25:32 -0500 )edit

The joint axis of the wheels should be set to y. I see in your urdf file, you have the rear wheels as fixed joints. Have you checked if converting them to continuous will change the results? Also remove the parts regarding ros_control and try it step-by-step; firstly make the front differential to work.

patrchri gravatar image patrchri  ( 2020-12-17 08:20:33 -0500 )edit

Hi. Thank you for your comments, really appreciate it. I tried changing the joints of the rear wheels to continuous and it didn't change the results. Also, I get warnings if I remove the ros control plugin so I just leave it in.

jcjmagno gravatar image jcjmagno  ( 2020-12-17 19:05:30 -0500 )edit

What warning do you get? If you just want to use the differential plugin, ros_control could be removed.

patrchri gravatar image patrchri  ( 2020-12-18 10:45:32 -0500 )edit

I get this warning: I just edited the post, added my launch file just in case it may help.

jcjmagno gravatar image jcjmagno  ( 2020-12-18 19:20:16 -0500 )edit