URDF axis problem in retrieving the position

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
Fra
Posts: 3
Joined: Thu Jan 16, 2020 9:43 pm

URDF axis problem in retrieving the position

Post by Fra »

Hello everyone!
I'm new here and I'm also new as to the simulation/robotic world.

I stumbled upon this library due to a machine learning project I'm currently working on. I need to build a sort of playground in which I can train and tests my algorithms and I need to control every possible aspect of the environment (that's why openai's gym doesn't meet my requirements). I built my URDF model following some tutorials and the official reference but it doesn't work as I would expect and I would be very glad if someone can give me some tips to go forward.

The idea behind:
The first environment I'm working on it's composed by a plane and two cars. The cars are aligned on the same axis and, ideally, they should only move along this axis. At each timestep I should be able to measure the absolute positions of the two to compute distance etc.

What I did so far:
I created the model and, trying to mimic the example of the 2D biped (biped/biped2d_pybullet.urdf, provided in pybullet_data), I succeeded in constraining it on just one axis (URDF code in the next post).

The problem now is that, querying the position from my model (using bullet.getBasePositionAndOrientation(car)), it always returns the position of the fake element that I introduced just to restrict the movement of my car to only one axis.

Do you have a better or a more elegant solution to accomplish my task? How can I fix this unwanted behavior?
Thank you in advance!

edit: the perfect solution would allow the car also to follow some steep paths, hence should support the movement into two axis, not just one.
Last edited by Fra on Thu Jan 16, 2020 10:16 pm, edited 2 times in total.
Fra
Posts: 3
Joined: Thu Jan 16, 2020 9:43 pm

Re: URDF axis problem in retrieving the position

Post by Fra »

My URDF code that describes the car:

Code: Select all

<?xml version='1.0'?>
<robot name="simple_car">
  <material name="body_color">
    <color rgba="0.8 0.8 0 1"/>
  </material>
  <material name="wheel">
    <color rgba="0.2 0.2 0.2 1"/>
  </material>


  <link name="world">
    <inertial>
      <mass value="0"/>
      <inertia ixx="0.2125" ixy="-0.005" ixz="0.0225" iyy="0.205" iyz="0.045" izz="0.0125"/>
      <origin rpy="0 0 0" xyz="0 0 0"/>
    </inertial>
  </link>

	<joint name="axis_to_world" type="prismatic">
    <parent link="world"/>
    <child link="base_link"/>
    <axis xyz="1 0 0"/>
    <limit effort="0.0" lower="1" upper="-1" velocity="1000.0"/>
    <origin rpy="0 0 0" xyz="0 0 0"/>
  </joint>

  <!-- Base link -->
  <link name="base_link">
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
          <box size="1 0.5 0.25"/>
      </geometry>
      <material name="body_color"/>
    </visual>
    <inertial> 
        <mass value="10"/>
        <inertia ixx="0.2" ixy="0" ixz="0" iyy="0.2" iyz="0.0" izz="0.2"/>
    </inertial> 
  </link>
  <!-- Front Right Wheel -->
  <link name="f_r_wheel">
    <visual>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
      <material name="wheel"/>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
    </collision>
    <inertial>
        <origin xyz="0 0 0" rpy="1.570795 0 0" />
        <mass value="0.3"/>
        <inertia ixx="0.4" ixy="0" ixz="0" iyy="0.4" iyz="0.0" izz="0.2"/>
    </inertial>
  </link>
  <joint name="joint_f_r_wheel" type="continuous">
    <parent link="base_link"/>
    <child link="f_r_wheel"/>
    <origin xyz="0.25 -0.30 0" rpy="0 0 0" /> 
    <axis xyz="0 1 0" rpy="0 0 0" />
  </joint>  
  <!-- Back Right Wheel -->
  <link name="b_r_wheel">
    <visual>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
      <material name="wheel"/>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
    </collision>
    <inertial>
        <origin xyz="0 0 0" rpy="1.570795 0 0" />
        <mass value="0.3"/>
        <inertia ixx="0.4" ixy="0" ixz="0" iyy="0.4" iyz="0.0" izz="0.2"/>
    </inertial>
  </link>
  <joint name="joint_b_r_wheel" type="continuous">
    <parent link="base_link"/>
    <child link="b_r_wheel"/>
    <origin xyz="-0.25 -0.30 0" rpy="0 0 0" /> 
    <axis xyz="0 1 0" rpy="0 0 0" />
  </joint>  
  <!-- Front Left Wheel -->
  <link name="f_l_wheel">
    <visual>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
      <material name="wheel"/>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
    </collision>
    <inertial>
        <origin xyz="0 0 0" rpy="1.570795 0 0" />
        <mass value="0.3"/>
        <inertia ixx="0.4" ixy="0" ixz="0" iyy="0.4" iyz="0.0" izz="0.2"/>
    </inertial>
  </link>
  <joint name="joint_f_l_wheel" type="continuous">
    <parent link="base_link"/>
    <child link="f_l_wheel"/>
    <origin xyz="0.25 0.30 0" rpy="0 0 0" /> 
    <axis xyz="0 1 0" rpy="0 0 0" />
  </joint>
  <!-- Back Left Wheel -->
  <link name="b_l_wheel">
    <visual>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
      <material name="wheel"/>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
    </collision>
    <inertial>
        <origin xyz="0 0 0" rpy="1.570795 0 0" />
        <mass value="0.3"/>
        <inertia ixx="0.4" ixy="0" ixz="0" iyy="0.4" iyz="0.0" izz="0.2"/>
    </inertial>
  </link>
  <joint name="joint_b_l_wheel" type="continuous">
    <parent link="base_link"/>
    <child link="b_l_wheel"/>
    <origin xyz="-0.25 0.30 0" rpy="0 0 0" /> 
    <axis xyz="0 1 0" rpy="0 0 0" />
  </joint>
</robot>
Fra
Posts: 3
Joined: Thu Jan 16, 2020 9:43 pm

Re: URDF axis problem in retrieving the position

Post by Fra »

Still working on the same problem I found this https://github.com/bulletphysics/bullet3/issues/2336.
But it sounds more like a dirty workaround and doesn't solve the problems I have in determining the positions of my objects.

I hope someone can help me.
Post Reply