Robotics StackExchange | Archived questions

SolidWorks URDF to Xacro

Hey guys,

I am new to gazebo and Rviz and I am struggling with something.
I exported my robots base via SolidWorks using URDF tool. Now I want to mount 2 UR5's into my base. I want to take it a step at a time so I wanted to start off by mounting just 1 arm.

The issue I am having is when trying to combine the URDF (robot base) file to the xacro (UR5) because based on what I learned I have to link them in the xacro itself Then the xacro file will be converted to URDF in the launch file.

I downloaded and saved the the Universal Robot Package to my environment and edited based on some information I found. My code is as follows:

ur5.launch:

<launch>
<arg name="limited" default="false" doc="If true, limits joint range [-PI, PI] on all joints."/>
<arg name="paused" default="false" doc="Starts gazebo in paused mode"/>
<arg name="gui" default="true" doc="Starts gazebo gui"/>
<!-- startup simulated world -->
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" default="worlds/empty.world"/>
<arg name="paused" value="$(arg paused)"/>
<arg name="gui" value="$(arg gui)"/>
</include>
<!-- send robot urdf to param server -->
<include file="$(find foo)/launch/ur5_upload.launch">
<arg name="limited" value="$(arg limited)"/>
</include>
<!--
 push robot_description to factory and spawn robot in gazebo 
-->
<node name="spawn_gazebo_model" pkg="gazebo_ros" type="spawn_model" args="-urdf -param robot_description -model robot -z 0.1" respawn="false" output="screen"/>
<include file="$(find ur_gazebo)/launch/controller_utils.launch"/>
<!-- start this controller -->
<rosparam file="$(find foo)/controller/arm_controller_ur5.yaml" command="load"/>
<node name="arm_controller_spawner" pkg="controller_manager" type="controller_manager" args="spawn arm_controller" respawn="false" output="screen"/>
<!-- load other controllers -->
<node name="ros_control_controller_manager" pkg="controller_manager" type="controller_manager" respawn="false" output="screen" args="load joint_group_position_controller"/>
</launch>

ur5_upload.launch:

<launch>
<arg name="limited" default="false" doc="If true, limits joint range [-PI, PI] on all joints."/>
<arg name="transmission_hw_interface" default="hardware_interface/PositionJointInterface"/>
<param unless="$(arg limited)" name="robot_description" command="$(find xacro)/xacro --inorder '$(find foo)/urdf/ur5_robot.urdf.xacro' transmission_hw_interface:=$(arg transmission_hw_interface)"/>
<param if="$(arg limited)" name="robot_description" command="$(find xacro)/xacro --inorder '$(find foo)/urdf/ur5_joint_limited_robot.urdf.xacro' transmission_hw_interface:=$(arg transmission_hw_interface)"/>
</launch>

ur5_robot.urdf.xacro:

<robot name="ur5">
<xacro:arg name="transmission_hw_interface" default="hardware_interface/PositionJointInterface"/>
<!-- common stuff -->
<xacro:include filename="$(find foo)/urdf/common.gazebo.xacro"/>
<!-- ur5 -->
<xacro:include filename="$(find foo)/urdf/ur5.urdf.xacro"/>
<xacro:include filename="$(find foo)/urdf/ur5_table.urdf.xacro"/>
<!-- arm -->
<xacro:ur5_robot prefix="" joint_limited="false" transmission_hw_interface="$(arg transmission_hw_interface)"/>

Table(Robot Base):

<robot
  name="foo">
  <link
    name="table_base_link">
    <inertial>
      <origin
        xyz="6.59953817434262E-17 9.12176108435972E-06 -2.26507811472884E-19"
        rpy="0 0 0" />
      <mass
        value="8.98801445396223" />
      <inertia
        ixx="0"
        ixy="0"
        ixz="0"
        iyy="0"
        iyz="0"
        izz="0" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://foo/meshes/base_link.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.792156862745098 0.819607843137255 0.933333333333333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://foo/meshes/base_link.STL" />
      </geometry>
    </collision>
  </link>
  <link
    name="Box_Base">
    <inertial>
      <origin
        xyz="1.2159E-06 -0.041897 1.5987E-05"
        rpy="0 0 0" />
      <mass
        value="6.3006" />
      <inertia
        ixx="0.00043006"
        ixy="1.3591E-06"
        ixz="1.8594E-06"
        iyy="0.00074627"
        iyz="-3.745E-05"
        izz="0.00066961" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://foo/meshes/Box_Base.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://foo/meshes/Box_Base.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="Joint_BB"
    type="fixed">
    <origin
      xyz="0 -0.237 0.6095"
      rpy="1.5707963267949 0 0" />
    <parent
      link="table_base_link" />
    <child
      link="Box_Base" />
    <axis
      xyz="0 0 0" />
  </joint>
  <link
    name="Robot_Base">
    <inertial>
      <origin
        xyz="7.5334E-17 0.028426 0.0064846"
        rpy="0 0 0" />
      <mass
        value="3.3533" />
      <inertia
        ixx="0.43109"
        ixy="-0.00063622"
        ixz="0.00019322"
        iyy="0.001432"
        iyz="-0.010707"
        izz="0.43052" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://foo/meshes/Robot_Base.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://foo/meshes/Robot_Base.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="Joint_RB"
    type="fixed">
    <origin
      xyz="0 0.29 0.7165"
      rpy="1.5707963267949 0 0" />
    <parent
      link="table_base_link" />
    <child
      link="Robot_Base" />
    <axis
      xyz="0 0 0" />
  </joint>
</robot>

Am I doing anything wrong? For some reason I cannot find any examples of adding URDF files to xacro so I must have a huge misunderstanding which is not allowing me to get the full picture.

Thank you for support.

Asked by Obeseturtle on 2020-02-26 20:57:18 UTC

Comments

I cannot find any examples of adding URDF files to xacro

as URDF is not composable (ie: cannot be "added" to anything else), this is to be expected.

Only .xacros can be composed with others.

Asked by gvdhoorn on 2020-02-27 03:37:27 UTC

What's the actual error that you're seeing? Or what behavior are you expecting that you don't see? As gvdhoorn implied, you may be better suited converting the URDF to a Xacro file so you can compose your higher order robot Xacro files.

Asked by maxsvetlik on 2020-02-28 10:00:26 UTC

I just wanted to link the robot base I made in SolidWorks to 2 UR5s. When launching the UR5s in the launch file it converts the xacro to URDF so I thought that there was a way to link them without using the xacros.

I am not sure what the standard way of creating your robot base and linking to the xacros was. What I did was just change the urdf manually to xacros. By manually I mean just changing the .urdf to .urdf.xacros and importing it to the UR5's xacro and it worked. but when trying to link it to a second UR5 that gave me issues.

What i'm doing now is just spawning 2 UR5s and my base as a URDF and edit the spawn position so that the UR5's are suspended in the air just below my robot base.

I used namespaces but what is occurring now is that the joint trajectory give me an error.

Joints on incoming goal don't match the controller joints.

Asked by Obeseturtle on 2020-03-01 19:50:38 UTC

Answers