URDF model falls through the ground

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
simont
Posts: 8
Joined: Mon Dec 09, 2019 7:01 am

URDF model falls through the ground

Post by simont »

Dear all, I have the below URDF file.

This is a description for a inverse pendelum robot which I want to train in a simulation with AI. When I load this file with pybullet for the training, it falls down through the ground and won't stop falling.

Has anybody an idea what could be wrong with the URDF file?

If there are missing some important information please let me know.

Thanks a lot for your help guys!

__________________________________________________________

Code: Select all

<?xml version="1.0" ?>
<robot name="Cartpole">

  <joint name="Rotation" type="continuous">
    <parent link="Cart"/>
    <child link="Shaft"/>
    <origin rpy="0  0  0" xyz="0.0215  0.247   0.0435"/>
    <axis xyz="1  0  0"/>
    <limit effort="0.0" lower="0.0" upper="0.0" velocity="0.0"/>
  </joint>

  <joint name="Cart_joint" type="prismatic">
    <parent link="Base"/>
    <child link="Cart"/>
    <origin rpy="0  0  0" xyz="-0.04147 -0.31058  0.22851"/>
    <axis xyz="0 -1  0"/>
    <limit effort="0.0" lower="-0.23555" upper="0.23555" velocity="0.0"/>
  </joint>

  <joint name="Pole_Shaft" type="fixed">
    <parent link="Shaft"/>
    <child link="Pole"/>
    <origin rpy="0  0  0" xyz="0.0193  0      0.007"/>
    <axis xyz="0  0  0"/>
    <limit effort="0" lower="0" upper="0" velocity="0"/>
  </joint>

  <link name="Cart">
    <inertial>
      <mass value="0.4494280957660571"/>
      <origin rpy="0  0  0" xyz="0  0  0"/>
      <inertia ixx="0.034344216689805106" ixy="-0.0013555840592494157" ixz="0.005746023053830929" iyy="0.033575305370647346" iyz="0.007655119926892856" izz="0.0029338994617400297"/>
    </inertial>
    <collision name="Cart_collision">
      <origin rpy="0  0  0" xyz="-0.00606  0.24716  0.03996"/>
      <geometry>
        <mesh filename="package:///home/agent-pipeline/cad-assets/urdf_cadassets/meshes/CAD/Cart.stl" scale="0.001 0.001 0.001"/>
      </geometry>
    </collision>
    <visual name="Cart_visual">
      <origin rpy="0  0  0" xyz="-0.00606  0.24716  0.03996"/>
      <geometry>
        <mesh filename="package:///home/agent-pipeline/cad-assets/urdf_cadassets/meshes/CAD/Cart.stl" scale="0.001 0.001 0.001"/>
      </geometry>
    </visual>
  </link>

  <link name="Shaft">
    <inertial>
      <mass value="0.024209988665072436"/>
      <origin rpy="0  0  0" xyz="0  0  0"/>
      <inertia ixx="0.00188987952436807" ixy="-1.1706804306416182e-05" ixz="5.008066577766269e-05" iyy="0.0017943029340322224" iyz="0.0004187314228447953" izz="0.00010090272031144335"/>
    </inertial>
    <collision name="Shaft_collision">
      <origin rpy="0  0  0" xyz="0.01237  0       0"/>
      <geometry>
        <mesh filename="package:///home/agent-pipeline/cad-assets/urdf_cadassets/meshes/CAD/Shaft.stl" scale="0.001 0.001 0.001"/>
      </geometry>
    </collision>
    <visual name="Shaft_visual">
      <origin rpy="0  0  0" xyz="0.01237  0       0"/>
      <geometry>
        <mesh filename="package:///home/agent-pipeline/cad-assets/urdf_cadassets/meshes/CAD/Shaft.stl" scale="0.001 0.001 0.001"/>
      </geometry>
    </visual>
  </link>

  <link name="Pole">
    <inertial>
      <mass value="0.01797430178868597"/>
      <origin rpy="0  0  0" xyz="0  0  0"/>
      <inertia ixx="0.0008366739796019355" ixy="-7.689518680322801e-07" ixz="2.477907732299824e-06" iyy="0.0007640110742674137" iyz="0.0002341786839091567" izz="7.299569596665657e-05"/>
    </inertial>
    <collision name="Pole_collision">
      <origin rpy="0  0  0" xyz="0       0      -0.07411"/>
      <geometry>
        <mesh filename="package:///home/agent-pipeline/cad-assets/urdf_cadassets/meshes/CAD/Pole.stl" scale="0.001 0.001 0.001"/>
      </geometry>
    </collision>
    <visual name="Pole_visual">
      <origin rpy="0  0  0" xyz="0       0      -0.07411"/>
      <geometry>
        <mesh filename="package:///home/agent-pipeline/cad-assets/urdf_cadassets/meshes/CAD/Pole.stl" scale="0.001 0.001 0.001"/>
      </geometry>
    </visual>
  </link>

  <link name="Base">
    <inertial>
      <mass value="2.5459113603106216"/>
      <origin rpy="0  0  0" xyz="0  0  0"/>
      <inertia ixx="0.5882136684497374" ixy="-0.02906460593367471" ixz="0.0501787117673072" iyy="0.14479915583911276" iyz="0.07620661469781886" izz="0.5291431708702397"/>
    </inertial>
    <collision name="Base_collision">
      <origin rpy="0  0  0" xyz="-0.10471 -0.14784  0.19902"/>
      <geometry>
        <mesh filename="package:///home/agent-pipeline/cad-assets/urdf_cadassets/meshes/CAD/Base.stl" scale="0.001 0.001 0.001"/>
      </geometry>
    </collision>
    <visual name="Base_visual">
      <origin rpy="0  0  0" xyz="-0.10471 -0.14784  0.19902"/>
      <geometry>
        <mesh filename="package:///home/agent-pipeline/cad-assets/urdf_cadassets/meshes/CAD/Base.stl" scale="0.001 0.001 0.001"/>
      </geometry>
    </visual>
  </link>

</robot>
 
Last edited by simont on Thu Jan 23, 2020 10:40 am, edited 1 time in total.
simont
Posts: 8
Joined: Mon Dec 09, 2019 7:01 am

Re: URDF model falls through the ground

Post by simont »

Hi, i have the following progress:

I put a baseplate (ground) into the model and connected the ground with the base with a fixed joint like you can see below. Now the base part won't fall
down, but the other parts still fall down. So it seems like the connections (joints) between the parts are not correct. Any ideas?

Code: Select all

  
  <link name="ground">    
    <inertial>
      <mass value="0.0"/>
      <inertia ixx="0.0" ixy="0.0" ixz="0.0" iyy="0.0" iyz="0.0" izz="0.0"/>
    </inertial>

    <visual>
      <geometry>
        <box size="10 10 -0.0001" />
      </geometry>
      <material name="red" />
    </visual>

    <collision>
      <geometry>
        <box size="10 10 -0.0001" />
      </geometry>
    </collision>
  </link>

   <joint name="ground_joint" type="fixed"> 
    <parent link="ground" /> 
    <child link="Base" />
  </joint>
   
Last edited by simont on Thu Jan 23, 2020 10:41 am, edited 1 time in total.
LocknutBushing
Posts: 11
Joined: Sat Jan 18, 2020 4:37 am

Re: URDF model falls through the ground

Post by LocknutBushing »

Hi,

All components within the same URDF model have collision with each other disabled by default. The easiest way to get ground collision is to load the ground plane in as a separate model.

Code: Select all

import pybullet_data
p.setAdditionalSearchPath(pybullet_data.getDataPath())
planeID = p.loadURDF("plane.urdf")
LocknutBushing
Posts: 11
Joined: Sat Jan 18, 2020 4:37 am

Re: URDF model falls through the ground

Post by LocknutBushing »

I'm not sure why your joints aren't working. How exactly did you generate the URDF?
simont
Posts: 8
Joined: Mon Dec 09, 2019 7:01 am

Re: URDF model falls through the ground

Post by simont »

Wow, amazing, this is actually working!! Thankyou!
LocknutBushing wrote: Sun Jan 19, 2020 8:44 pm Hi,

All components within the same URDF model have collision with each other disabled by default. The easiest way to get ground collision is to load the ground plane in as a separate model.

Code: Select all

import pybullet_data
p.setAdditionalSearchPath(pybullet_data.getDataPath())
planeID = p.loadURDF("plane.urdf")
simont
Posts: 8
Joined: Mon Dec 09, 2019 7:01 am

Re: URDF model falls through the ground

Post by simont »

Hi, I used this script below. This script is working similar as this one: https://github.com/andreasBihlmaier/pysdf
LocknutBushing wrote: Sun Jan 19, 2020 8:52 pm I'm not sure why your joints aren't working. How exactly did you generate the URDF?

Code: Select all

#!/bin/bash

source catkin_ws/devel/setup.bash

if [ ! -d "$2" ]; then
  mkdir $2
fi

end_without_slash() {
  str="$1"
  i=$((${#str}-1))
  last_char="${str:$i:1}"
  if [ $last_char == "/" ]; then
    echo "${str%?}"
  else
    echo "$str"
  fi
}

src=$(end_without_slash "$1")
esc_src=$(echo "$src" | sed -e 's/[\/&]/\\&/g')
dst=$(end_without_slash "$2")
esc_dst=$(echo "$dst" | sed -e 's/[\/&]/\\&/g')

sdf=$(find "$src" -name "*.sdf")
meshes="$src/meshes/CAD/"

MESH_WORKSPACE_PATH=$meshes rosrun pysdf sdf2urdf.py "$sdf" "$dst/model.xml" --no-prefix

sed -i "s/\(package:\/\/\)$esc_src\/\(meshes\/CAD\)/\1$esc_dst\/\2/g" "$dst/model.xml"

cp -r "$src/meshes" "$dst"

For the transformation I execute this command:

$ ./sdf_to_urdf <sdf_dir> <urdf_output_dir>
simont
Posts: 8
Joined: Mon Dec 09, 2019 7:01 am

Re: URDF model falls through the ground

Post by simont »

Now I have still another challenge: The model keeps swinging back and forth. If you are interested, I have opened a new
post here: viewtopic.php?f=24&t=12852&p=42591#p42591
Post Reply