ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Combining URDF-files with tf (static_transform)

asked 2019-03-30 14:21:32 -0500

steradiant gravatar image

Hello, I'm struggling with combining different urdf files (robots). I had some problems when I added everything in one urdf file ( ) so I tried another attempt. I split it up in two different urdf files and made a static transform between the two links.

This is my launch file

    <?xml version="1.0" ?>

  <!-- The robot name is required for gazebo to spawn a model. -->
  <arg name="robot_name" default="kuka-lwr-gripper"/>

  <!-- The recommended way of specifying the URDF file is to pass it in
       directly. -->
  <arg name="robot_path" default="$(find kuka-lwr-gripper)/robot"/> 
  <arg name="robot_urdf_file" default="$(arg robot_path)/$(arg robot_name)_standalone.urdf.xacro" />
  <arg name="gripper_urdf_file" default="$(arg robot_path)/simple_gripper/simple_gripper_model.urdf.xacro" />

  <!-- <arg name="controllers" default="joint_controllers"/> -->
  <arg name="controllers" default="joint_controllers"/>
  <arg name="t1_limits" default="false"/>

  <arg name="rviz_config" default="$(find lwr_launch)/launch/rviz/rviz_config.rviz"/>
  <arg name="rviz_bringup" default="true"/> <!--If false, do not launch rviz-->

  <arg name="hw_interface_file" default="$(find kuka-lwr-gripper)/config/hw_interface.yaml"/>
  <arg name="controller_config_file" default="$(find kuka-lwr-gripper)/config/controllers.yaml"/>
  <arg name="gazebo_world_file" default="$(find kuka-lwr-gripper)/worlds/"/>
  <arg name="t1_limits_file" default="$(find kuka-lwr-gripper)/config/t1_joint_limits.yaml"/>
  <arg name="GAZEBO_GUI" default="true"/>

  <!-- gripper parameters -->
  <arg name="gripper_controller_config_file" default="$(find kuka-lwr-gripper)/config/gripper_controllers.yaml"/>

  <!-- ROBOT -->
  <group ns="lwr">
    <param name="robot_description" command="$(find xacro)/xacro $(arg robot_urdf_file)"/>
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"/>

  <!-- GRIPPER -->
  <group ns="my_gripper">
    <param name="robot_description" command="$(find xacro)/xacro $(arg gripper_urdf_file)"/>

    <node name="my_tp_lwr" pkg="tf" type="static_transform_publisher" args="0 0 0.01 0 0 0 lwr_7_link base_link 100"/>

    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"/>

  <!-- GAZEBO -->
  <node name="spawn_urdf1" pkg="gazebo_ros" type="spawn_model" args="-param /lwr/robot_description -urdf -model $(arg robot_name)" respawn="false" output="screen" />
  <node name="spawn_urdf2" pkg="gazebo_ros" type="spawn_model" args="-param /my_gripper/robot_description -urdf -model my_gripper1" respawn="false" output="screen" />

  <!-- enable/disable gui at will, the rviz listens to the simulation -->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(arg gazebo_world_file)"/>
    <arg name="paused" value="false"/>
    <arg name="use_sim_time" value="true"/>
    <arg name="gui" value="$(arg GAZEBO_GUI)"/>
    <arg name="headless" value="false"/>
    <arg name="debug" value="false"/>

  <!-- Load updated joint limits (override information from single_lwr_moveit) to respect T1 mode limits -->
  <group if="$(arg t1_limits)" ns="robot_description_planning">
    <rosparam command="load" file="$(arg t1_limits_file)"/>

  <!-- load robotHW configurations to rosparam server -->
  <rosparam command="load" file="$(arg hw_interface_file)"/> 

  <!-- load all controller configurations to rosparam server -->
  <rosparam command="load" file="$(arg controller_config_file)" /> 

  <!-- load the gripper controller configuration to rosparam server -->
  <rosparam command="load" file="$(arg gripper_controller_config_file)"/> 

  <!-- real robot and controllers -->
  <group ns="lwr">
     <!-- spawn only desired controllers in current namespace --> 
     <node name="controller_spawner_js" pkg="controller_manager" type="spawner" respawn="false" output="screen" args="kuka_joint_state_controller"/>
     <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false" output="screen" args="$(arg controllers)"/>  

  <group ns="my_gripper">
     <!-- <param name="robot_description" command="$(find xacro)/ $(arg robot_urdf_file)"/> -->
     <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false" output="screen" args="left_finger_joint_position_controller right_finger_joint_position_controller joint_state_controller"/> 

  <!-- LAUNCH RVIZ -->

  <node name="lwr_rviz" pkg="rviz ...
edit retag flag offensive close merge delete


Are there any error messages? Are you sure the gripper files are being found? Are they in a different package than your new URDF file?

fvd gravatar image fvd  ( 2019-04-01 00:31:50 -0500 )edit

Yes, they are in different packages (the URDF for the robot and the URDF for the gripper; in the same catkin ws though) but that shouldn't be a problem in my opinion. And no, I don't get any errors, that was one reason to post here because I don't know where to search for the problem now. I'm pretty sure, that the gripper files are found, firstly there are no errors and secondly I can see the separate parts in Gazebo (not in RViz).

steradiant gravatar image steradiant  ( 2019-04-01 02:21:32 -0500 )edit

Can you post a link to a minimal version of your project workspace? Have you tried using a different package for the gripper?

fvd gravatar image fvd  ( 2019-04-01 06:12:42 -0500 )edit

I made a github project (I hope everything runs; it's my first time I pushed a project myself).

steradiant gravatar image steradiant  ( 2019-04-01 07:00:04 -0500 )edit

The project doesn't build because 'ncurses.h' is missing and other dependencies cannot be found. After blacklisting the offending packages, Gazebo gives ERROR: cannot launch node of type [controller_manager/spawner]: controller_manager for me. Can you confirm?

fvd gravatar image fvd  ( 2019-04-03 05:59:22 -0500 )edit

No, I don't get this error. The launch file starts without errors for me. Have you installed ros_control? If not, pleas run rosrun apt-get install ros-kinetic-ros-control

steradiant gravatar image steradiant  ( 2019-04-04 00:29:06 -0500 )edit

I think the dependencies of the package were not installed automatically and I didn't use a full ROS image for the test last time.

fvd gravatar image fvd  ( 2019-04-04 05:12:24 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2019-04-04 05:12:28 -0500

fvd gravatar image

updated 2019-04-04 05:16:56 -0500

It looks like there are two robot_state_publisher nodes and controllers publishing in their own namespaces, but Rviz and Gazebo are not getting the data. When I start up your package, the LWR (and gripper; essentially a second robot) are just limp on the floor in Gazebo. In Rviz, no joint states are received for the LWR.

image description

image description

The gripper can be added as a second RobotModel in Rviz if the robot_description is set to /my_gripper/robot_description, but it also receives no joint states. This is because your controllers are publishing to /lwr/joint_states and /my_gripper/joint_states, but Rviz and Gazebo are listening to /joint_states.

I would try this:

  • Combine your URDF by attaching the gripper to the tip of your robot, as described in your other question.
  • Start up your gripper+LWR and their controllers in the same namespace as Gazebo and Rviz

It might be possible to remap both your namespaces to the global /joint_states, but I don't know how to do it. I couldn't find anything on this, except a related post, where someone came to the same conclusion about the single URDF file.

edit flag offensive delete link more


Thanks for the answer! I've already tried one single URDF-model and I also know this post (related post) but I run into the same problem as described there, that every ros control gazebo plugin initialize all joints and therefore I have problems with using the lwr custom controllers and the standard effort controller at the same time (described in the related post an here ). I thought with different URDF files and different namespaces I would probably get rid of this problem.

steradiant gravatar image steradiant  ( 2019-04-07 11:54:18 -0500 )edit

Question Tools

1 follower


Asked: 2019-03-30 14:21:32 -0500

Seen: 1,479 times

Last updated: Apr 04 '19