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

Why do I need the static transform if my urdf is properly defined?

asked 2014-12-06 08:38:15 -0600

AlexR gravatar image

updated 2014-12-10 06:54:15 -0600

Hi,

As the questions says, I do not understand why do we need the static_transform_publisher when the urdf model of the robot with all sensors is properly defined in the urdf file. Doesn't loading the urdf places all the tf's correctly. If so, why do we need to remap frames most of the times for example when using hector_slam ? Can someone explain.

EDIT

I would edit my question for better understanding. I am using pioneer p3dx for 2d slam mapping. Here is my launch file that I use for moving the robot around. I am using it with kinect and a hokuyo laser sensor. The position of the kinect and laser is defined in the urdf files properly and I can visualize them on the rviz.

<launch>

  <node pkg="rosaria" type="RosAria" name="RosAria"/>
  <node pkg="topic_tools" type="relay" name="relay1" args="/RosAria/pose /odom" />
  <node pkg="topic_tools" type="relay" name="relay2" args="/cmd_vel /RosAria/cmd_vel" />

  <param name="robot_description" command="$(find xacro)/xacro.py '$(find kinect)/urdf/p3dx_real.xacro'" />

  <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher">
    <param name="publish_frequency" type="double" value="20.0" />
  </node>

  <node pkg="tf" type="static_transform_publisher" name="static_transform_publisher" args="0 0 0 0 0 0 base_link base_footprint 50"/>
  <node pkg="tf" type="static_transform_publisher" name="static_transform_publisher2" args="-0.2 0 0.036 0 0 0 base_link center_wheel 50"/>
  <node pkg="tf" type="static_transform_publisher" name="static_transform_publisher3" args="-0.178 0 0.052 0 0 0 base_link swivel 50"/>

</launch>

Now, i launch the kinect and hokuyo files separately. I can make fairly good maps using the gmapping and my tf's do not give me any error when using the gmapping.

when I want to use the hector slam, because I know my urdf is proper, when I use the parameters for scan --> /scan , odom --> /odom and map ---> /map. I always get TF error about base_link to base_laser not defined.

Why is that? I am guessing if it is because somehow my tf from the urdf are not being read or I am missing a tf link in between. But why then the Gmapping seems to work perfectly on the same robot model.

EDIT 2:

I am attaching my tf view_frames. You can see that the base_laser has the parent as base_link. Mostly the tf frame is flattened. See the attached frames pdf file

Here's my launch file:

<?xml version="1.0"?>

<launch>
  <arg name="tf_map_scanmatch_transform_frame_name" default="scanmatcher_frame"/>
  <arg name="base_frame" default="base_link"/>
  <arg name="odom_frame" default="odom"/>
  <arg name="pub_map_odom_transform" default="true"/>
  <arg name="scan_subscriber_queue_size" default="5"/>
  <arg name="scan_topic" default="scan"/>
  <arg name="map_size" default="4048"/>

  <node pkg="hector_mapping" type="hector_mapping" name="hector_mapping" output="screen">

    <!-- Frame names -->
    <param name="map_frame" value="map" />
    <param name="base_frame" value="base_link" />
    <param name="odom_frame" value="odom" />

    <!-- Tf use -->
    <param name="use_tf_scan_transformation" value="true"/>
    <param name="use_tf_pose_start_estimate" value="false"/>
    <param name="pub_map_odom_transform" value="$(arg pub_map_odom_transform)"/>

    <!-- Map size / start point -->
    <param name="map_resolution" value="0.050"/>
    <param name="map_size" value="$(arg map_size)"/>
    <param name="map_start_x" value="0.5"/>
    <param ...
(more)
edit retag flag offensive close merge delete

Comments

Are you using robot_state_publisher with your URDF?

ahendrix gravatar image ahendrix  ( 2014-12-07 00:45:19 -0600 )edit

Please edit your question to explain a little more about what you're doing and how you're using the static_transform_publisher. To be able to explain why to do something we will need to know what you're doing.

tfoote gravatar image tfoote  ( 2014-12-07 00:48:57 -0600 )edit

I edited the question.

AlexR gravatar image AlexR  ( 2014-12-09 01:09:09 -0600 )edit

Thanks for the update. Can you share a little bit more? Maybe what are the frames in your robot model? What is the output of view_frames.py when you're running the two setups? We need to debug what's different about the systems.

tfoote gravatar image tfoote  ( 2014-12-09 03:05:30 -0600 )edit
1

As a side comment you should use remapping instead of relays for things like changing topics. It's much more efficient as it actually changes the topic publishing instead of receiving it and rebroadcasting it. Take a look at rqt_graph to see the difference.

tfoote gravatar image tfoote  ( 2014-12-09 03:06:42 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
3

answered 2015-03-02 18:20:53 -0600

tfoote gravatar image

The final solution you have only has one static transform publisher, and I think that's necessary to connect map to nav since you are not running a localization module. Usually amcl or gmapping are used.

edit flag offensive delete link more
-1

answered 2014-12-07 10:04:47 -0600

l0g1x gravatar image

The URDF is just a xml file which describes how your robot looks, where your linkages are created, what joints join two linkages together, what sensors you have and where they are placed with respect to the robot. It does not magically take care of transforming coordinate frames (linkages) for you; you still need to setup your transforms using either the transform_broadcaster class, or like in your case the static_transform_publisher node (only for sensors rigidly mounted to your frame).

You can think about it like a message's header frame: msg.header.frame = "camera_link"

The message is being published with a description of how it looks, but you need to setup the transform between the coordinate frame "camera_link" (because obviously we just said the header frame of that msg is "camera_link") and whatever the parent coordinate frame would be. You can do that with the static tf publisher or tf broadcaster like i said

edit flag offensive delete link more

Comments

2

If you have the links in your URDF you should not need a static_transform_publisher.

tfoote gravatar image tfoote  ( 2014-12-07 15:38:51 -0600 )edit

Noted, thanks. Does this also apply even for gazebo?

l0g1x gravatar image l0g1x  ( 2014-12-07 16:15:22 -0600 )edit

Yes, as long as you have joint states being published and a robot_state_publisher sending out the tf frames it will work in any environment. real or simulated,

tfoote gravatar image tfoote  ( 2014-12-07 19:08:42 -0600 )edit
1

The robot_state_publisher does magically publish the transforms between the frames defined in your URDF; you don't need to duplicate those with a static_transform_publisher

ahendrix gravatar image ahendrix  ( 2014-12-07 22:02:23 -0600 )edit

@ahedrix Thanks, I am using the robot_state_publisher but still getting the tf error messages about missing base_link to base_laser transform.

AlexR gravatar image AlexR  ( 2014-12-09 01:10:15 -0600 )edit

Do you have the base_link and base_laser frames defined in your URDF? It may be useful to edit your question to include or link to the URDF that you're using.

ahendrix gravatar image ahendrix  ( 2014-12-09 20:43:13 -0600 )edit

@ahendrix I have attached the tf view_frames. Please have a look. I can see the base_laser with parent base_link.

AlexR gravatar image AlexR  ( 2014-12-09 21:03:52 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-12-06 08:38:15 -0600

Seen: 2,905 times

Last updated: Mar 02 '15