SolidWorks URDF to Xacro

asked 2020-02-26 19:57:18 -0500

Obeseturtle gravatar image

updated 2020-02-26 20:00:51 -0500

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:


<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/"/>
<arg name="paused" value="$(arg paused)"/>
<arg name="gui" value="$(arg gui)"/>
<!-- send robot urdf to param server -->
<include file="$(find foo)/launch/ur5_upload.launch">
<arg name="limited" value="$(arg limited)"/>
 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"/>


<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)"/>


<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)"/>

<joint name="table_base_link_joint" type="fixed"> <parent link="table_base_link"/> <child link="base_link"/> <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/> </joint> </robot>

Table(Robot Base):

  name="foo ...
edit retag flag offensive close merge delete


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.

gvdhoorn gravatar image gvdhoorn  ( 2020-02-27 02:37:27 -0500 )edit

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.

maxsvetlik gravatar image maxsvetlik  ( 2020-02-28 09:00:26 -0500 )edit

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 ...(more)

Obeseturtle gravatar image Obeseturtle  ( 2020-03-01 18:50:38 -0500 )edit