0
$\begingroup$

Rosanswers logo

Hello Everyone

New to ROS and i'm trying to import a CAD model via simmechanics_to_urdf.

If i open the urdf in urdf-viz (https://github.com/OTL/urdf-viz) i get a proper model and can move the joints.

However if i open the same urdf and meshes in either Rviz or Gazebo the parts show up in strange positions. (mostly around the origin).

edit: seems the issue was at least in part the lack of a fixed joint at the base to apparently anchor the model. As soon as I added a fixed base joint everything started working in Rviz. Gazebo still has the same issue. urdf-viz does not require the fixed base joint so it would display correctly regardless

Any ideas? Sorry i don't have a better vocabulary to explain the issue.

 <robot name="finger">
  <link name="base_link" />
  <link name="base8">
    <inertial>
      <origin xyz="-1.26773e-06 0.000427739 0.00546823" rpy="0 0 0"/>
      <mass value="0.00171993"/>
      <inertia ixx="4.15282e-08" ixy="3.76912e-12" ixz="3.81441e-12" iyy="9.2702e-08" iyz="-1.64114e-09" izz="9.15731e-08"/>
    </inertial>
    <visual>
      <origin xyz="0 0 0.0114743" rpy="0 0 0"/>
      <geometry>
        <mesh filename="package://finger_description/meshes/base8_ipt_11dce11d.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="base8_color">
        <color rgba="0.74902 0.74902 0.74902 1.0"/>
      </material>
    </visual>
    <collision>
      <origin xyz="0 0 0.0114743" rpy="0 0 0"/>
      <geometry>
        <mesh filename="package://finger_description/meshes/base8_ipt_11dce11d.stl" scale="0.001 0.001 0.001"/>
      </geometry>
    </collision>
  </link>
  <link name="finger_segment1">
    <inertial>
      <origin xyz="0.00449723934 0.00021284299985 0.0071977" rpy="0 0 0"/>
      <mass value="0.00199166"/>
      <inertia ixx="1.06576e-07" ixy="1.37509e-11" ixz="3.64504e-11" iyy="1.21654e-07" iyz="-3.77147e-09" izz="5.43651e-08"/>
    </inertial>
    <visual>
      <origin xyz="0.0045 -1.77523001664e-05 0.008" rpy="0 0 0"/>
      <geometry>
        <mesh filename="package://finger_description/meshes/finger_segment_ipt_544d6e46.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="finger_segment1_color">
        <color rgba="0.74902 0.74902 0.74902 1.0"/>
      </material>
    </visual>
    <collision>
      <origin xyz="0.0045 -1.77523001664e-05 0.008" rpy="0 0 0"/>
      <geometry>
        <mesh filename="package://finger_description/meshes/finger_segment_ipt_544d6e46.stl" scale="0.001 0.001 0.001"/>
      </geometry>
    </collision>
  </link>
  <joint name="finger_segment1__base8" type="continuous">
    <origin xyz="-0.0045 0 0.0114743" rpy="0 0 0"/>
    <axis xyz="1.0 0.0 0.0"/>
    <parent link="base8"/>
    <child link="finger_segment1"/>
    <dynamics damping="0.1"/>
  </joint>
  <link name="finger_segment2">
    <inertial>
      <origin xyz="0.00449723934 0.000212842999506 0.0071977" rpy="0 0 0"/>
      <mass value="0.00199166"/>
      <inertia ixx="1.06576e-07" ixy="1.37509e-11" ixz="3.64504e-11" iyy="1.21654e-07" iyz="-3.77147e-09" izz="5.43651e-08"/>
    </inertial>
    <visual>
      <origin xyz="0.0045 -1.77523005075e-05 0.008" rpy="0 0 0"/>
      <geometry>
        <mesh filename="package://finger_description/meshes/finger_segment_ipt_544d6e46.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="finger_segment2_color">
        <color rgba="0.74902 0.74902 0.74902 1.0"/>
      </material>
    </visual>
    <collision>
      <origin xyz="0.0045 -1.77523005075e-05 0.008" rpy="0 0 0"/>
      <geometry>
        <mesh filename="package://finger_description/meshes/finger_segment_ipt_544d6e46.stl" scale="0.001 0.001 0.001"/>
      </geometry>
    </collision>
  </link>
  <joint name="finger_segment2__finger_segment1" type="continuous">
    <origin xyz="0 0 0.018" rpy="0 0 0"/>
    <axis xyz="1.0 0.0 0.0"/>
    <parent link="finger_segment1"/>
    <child link="finger_segment2"/>
    <dynamics damping="0.1"/>
  </joint>
  <link name="tip">
    <inertial>
      <origin xyz="0.004500186539 0.0001604209997 0.00787229999999" rpy="0 0 0"/>
      <mass value="0.0025752"/>
      <inertia ixx="1.13686e-07" ixy="1.11636e-11" ixz="5.21811e-12" iyy="1.23658e-07" iyz="-3.05198e-09" izz="5.44323e-08"/>
    </inertial>
    <visual>
      <origin xyz="0.0045 0 0" rpy="0 0 0"/>
      <geometry>
        <mesh filename="package://finger_description/meshes/tip_ipt_3a5e0dea.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="tip_color">
        <color rgba="0.74902 0.74902 0.74902 1.0"/>
      </material>
    </visual>
    <collision>
      <origin xyz="0.0045 0 0" rpy="0 0 0"/>
      <geometry>
        <mesh filename="package://finger_description/meshes/tip_ipt_3a5e0dea.stl" scale="0.001 0.001 0.001"/>
      </geometry>
    </collision>
  </link>
  <joint name="tip__finger_segment2" type="continuous">
    <origin xyz="0 0 0.018" rpy="0 0 0"/>
    <axis xyz="1.0 0.0 0.0"/>
    <parent link="finger_segment2"/>
    <child link="tip"/>
    <dynamics damping="0.1"/>
  </joint>
  <joint name="base_joint" type="fixed" >
    <parent link="base_link" />
    <child link="base8" />
    <origin xyz="0 0 0" rpy="0 0 0" />
  </joint>
  <gazebo reference="base8">
    <visual>
      <material>
        <ambient>0.74902 0.74902 0.74902 1.0</ambient>
        <diffuse>0.74902 0.74902 0.74902 1.0</diffuse>
        <specular>0.74902 0.74902 0.74902 1.0</specular>
      </material>
    </visual>
  </gazebo>
  <gazebo reference="finger_segment1">
    <visual>
      <material>
        <ambient>0.74902 0.74902 0.74902 1.0</ambient>
        <diffuse>0.74902 0.74902 0.74902 1.0</diffuse>
        <specular>0.74902 0.74902 0.74902 1.0</specular>
      </material>
    </visual>
  </gazebo>
  <gazebo reference="finger_segment2">
    <visual>
      <material>
        <ambient>0.74902 0.74902 0.74902 1.0</ambient>
        <diffuse>0.74902 0.74902 0.74902 1.0</diffuse>
        <specular>0.74902 0.74902 0.74902 1.0</specular>
      </material>
    </visual>
  </gazebo>
  <gazebo reference="tip">
    <visual>
      <material>
        <ambient>0.74902 0.74902 0.74902 1.0</ambient>
        <diffuse>0.74902 0.74902 0.74902 1.0</diffuse>
        <specular>0.74902 0.74902 0.74902 1.0</specular>
      </material>
    </visual>
  </gazebo>
  <gazebo>
    <pose>0.0 0.0 0.0 0.0 0.0 0.0</pose>
  </gazebo>
</robot>

Regards


Originally posted by Ironic on ROS Answers with karma: 3 on 2018-08-16

Post score: 0


Original comments

Comment by gvdhoorn on 2018-08-17:
I seem to remember that the urdfs coming out of that tool are not always entirely correct, leading to problems when you try to use them with ROS without any post-processing.

Without seeing your urdf we cannot help you I'm afraid.

Please copy-paste it into your question, use the edit button/link.

Comment by gvdhoorn on 2018-08-17:\

However if i open the same urdf and meshes in either Rviz or Gazebo the parts show up in strange positions. (mostly around the origin).

this could actually point to a different problem.

How are you "open[ing] the same urdf in [..] Rviz" exactly? Which commands do you use?

Comment by Ironic on 2018-08-17:
Hi gvdhoorn.

To launch in Rviz i use:

roslaunch urdf_tutorial display.launch model:=`rospack find PMC6dof_urdf`/urdf/PMC_6dof.urdf gui:=true

To launch in gazebo i run:

roscore
roslaunch gazebo_ros empty_world.launch
rosrun gazebo_ros spawn_model -file `rospack find PMC6dof_urdf`/urdf/PMC_6

Comment by Ironic on 2018-08-17:
I based my test in tutorials i found online. Just kept the robot name and just filled in my urdf (now in main answer). Thank You

Comment by gvdhoorn on 2018-08-17:
Just a quick comment:

<link name="base8:1">

I'm not sure names with colons in them are actually legal in ROS. See wiki/Names.

Comment by Ironic on 2018-08-17:
Removed all colons in names. Results are the same.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Just noticed that you don't have a base_link link in your urdf.

The default RViz config used by display.launch has base_link configured as the Fixed Frame.

Use the dropdown to change it (top-left, under Global Options in RViz), probably to base8:1.

As I don't have the meshes, I can't be certain, but I believe that will fix it.


Edit: three additional comments:

  • add a base_link to your urdf: by convention, base_link is the start of all ROS urdf trees. Quite a few tools, packages and humans will assume this, so it might make sense to add one. If you add it, make it the root of the tree.
  • I would not use colons in names of links: replace them with underscores.
  • your urdf has all joints rotating over the X axis. That is ok, but convention is for ROS frames to be x+ forward. Right now your model is Y axis aligned. Unless you have a strong need to keep it that way (external software fi), you might consider changing that to X axis aligned.

Originally posted by gvdhoorn with karma: 86574 on 2018-08-18

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Ironic on 2018-08-18:
Implemented your suggestions and updated the urdf file

I have tried opening the model in gazebo via two methods described here and these are the results:

Comment by Ironic on 2018-08-18:
If i open via the spawn method, meshes are overlapping as before. I get this warning in the terminal: multiple inconsistent exists due to fixed joint reduction overwriting previous value [0.0 0.0 0.0 0.0 0.0 0.0] with [0 0 1 0 -0 0]. Not sure what to do about it.

Comment by Ironic on 2018-08-18:
this seems to address similar issue: http://answers.gazebosim.org/question/12611/urdf-to-gazebo-differs-from-urdf-to-sdf-to-gazebo/

Comment by Ironic on 2018-08-18:
if i add the model to the gazebo model folder, i can add the model in the editor and here it is displayed correctly. however as soon as i close the editor the meshes revert to their strange positions.

Comment by gvdhoorn on 2018-08-19:
I'm assuming the RViz issues are now fixed?

re: gazebo: that is a bit of a different subject. Getting models to appear (and work!) properly in Gazebo is not trivial, especially not such small ones with these very small inertias. I'd recommend to ask a separate question on the Gazebo Anwers site.

Comment by Ironic on 2018-08-19:
Rviz is sorted. Will do. Thank you for all the help.

Comment by Ironic on 2018-08-19:
Tried increasing inertia substantially and problem disappeared. Seems this is a recurring problem. Thank you for the tip.

Comment by gvdhoorn on 2018-08-20:
re: small inertias: Gazebo's solvers are numeric. Small nrs can always become a problem then.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.