my mobile robot orientation is reversed with teleop_twist_keyboard

asked 2021-09-26 19:39:16 -0600

Kareem Magdy gravatar image

I am have been facing a lot of problems during building an autonomous robot I believe that I have worked everything out except for my robot seems to be not knowing which is its front and which is its back. when I use teleop_twist_keyboard node to verify my hardware the robot it rviz moves in backwards when "I" is pressed and forward when "," is presses but it is normal with "J" and "K". I am using ROS melodic on jetson nano and differential drive robot (2 wheels and 1 castor in the front). the robot thinks its front is on the side of the wheels I have revised my URDF several times but still not able to solve this problem. For an illustrative photo of rviz please follow this drive link: https://drive.google.com/file/d/1oSjD...

this is my URDF (exported from solidworks with some adjustments):

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


  <link name="base_footprint">
    <visual>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <geometry>
        <box size="0.001 0.001 0.001"/>
      </geometry>
    </visual>
  </link>
  <gazebo reference="base_footprint">
    <turnGravityOff>false</turnGravityOff>
  </gazebo>
  <joint name="base_footprint_joint" type="fixed">
    <origin rpy="0 0 0" xyz="0 0 0.05"/>
    <parent link="base_footprint"/>
    <child link="base_link"/>
  </joint>

  <link
    name="base_link">
    <inertial>
      <origin
        xyz="0.24207 0.075011 -0.15"
        rpy="0 0 0" />
      <mass
        value="2" />
      <inertia
        ixx="0.123"
        ixy="-0.00342"
        ixz="1.6959E-10"
        iyy="0.33471"
        iyz="-2.5131E-11"
        izz="0.26996" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://kandb/meshes/base_link.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://kandb/meshes/base_link.STL" />
      </geometry>
    </collision>
  </link>
  <link
    name="castor_link">
    <inertial>
      <origin
        xyz="1.3878E-17 -0.017606 0"
        rpy="0 0 0" />
      <mass
        value="0.25" />
      <inertia
        ixx="2.5954E-05"
        ixy="-3.2174E-23"
        ixz="-7.2378E-22"
        iyy="3.5446E-05"
        iyz="7.2135E-23"
        izz="2.5954E-05" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://kandb/meshes/castor_link.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://kandb/meshes/castor_link.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="castor_link_joint"
    type="fixed">
    <origin
      xyz="0.075 0.15 -0.005"
      rpy="1.5708 0 0" />
    <parent
      link="base_link" />
    <child
      link="castor_link" />
    <axis
      xyz="0 0 0" />
  </joint>

  <link
    name="arc_link">
    <inertial>
      <origin
        xyz="0 0.027476 0.15"
        rpy="0 0 0" />
      <mass
        value="1 ...
(more)
edit retag flag offensive close merge delete

Comments

From the picture, the orientation of your green axis is opposite for the wheels than the base, so if you follow right hand rule you will get opposite effect. I suggest reorient your axis or modify teleop program.

osilva gravatar image osilva  ( 2021-09-27 11:28:35 -0600 )edit

I tried flipping joint axis (x) in the urdf to be - 1 instead of 1 for both wheels but it didnt help. Should i choose another rotation axis (y or z)?

Kareem Magdy gravatar image Kareem Magdy  ( 2021-09-27 11:51:38 -0600 )edit

I don't have much time at the moment to look at your urdf in more detail, I will go over a little later tonight. But in the meantime, I suggest to read this to help your understanding of local and world frames: https://husarion.com/manuals/rosbot/#...

osilva gravatar image osilva  ( 2021-09-27 12:09:46 -0600 )edit

Thank you osilva

Kareem Magdy gravatar image Kareem Magdy  ( 2021-09-27 14:15:11 -0600 )edit