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

Why is the static_transform_broadcaster_node (tf2_ros) not built as an executable

asked 2022-12-19 04:27:19 -0500

tommy_erko gravatar image

updated 2022-12-19 04:28:19 -0500

I want to publish a static transformation in several places. It will be called from a launch file and the transformation data will be stored in a parameter file.

I see there is a static_transform_broadcaster_node implemented in tf2_ros package (that accepts the set of params), but it is not built as an executable and cannot be run as a node (you would have to wrap it in your own implementation. So the only way to publish the tf is static_transform_publisher "program" with the unmarked command line arguments.

Is there any reason for this? Why not build the node as an executable?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-12-20 02:26:39 -0500

tfoote gravatar image

I believe that you'll find that it's built into a standalone executable static_transform_publisher and provides the following help for the command line arguments:

root@ba6984009c30:/# ros2 run tf2_ros static_transform_publisher -h
usage: static_transform_publisher [--x X] [--y Y] [--z Z] [--qx QX] [--qy QY] [--qz QZ] [--qw QW] [--roll ROLL] [--pitch PITCH] [--yaw YAW] --frame-id FRAME_ID --child-frame-id CHILD_FRAME_ID

A command line utility for manually sending a static transform.

If no translation or orientation is provided, the identity transform will be published.

The translation offsets are in meters.

The rotation may be provided with roll, pitch, yaw euler angles in radians, or as a quaternion.

required arguments:
  --frame-id FRAME_ID parent frame
  --child-frame-id CHILD_FRAME_ID child frame id

optional arguments:
  --x X                 x component of translation
  --y Y                 y component of translation
  --z Z                 z component of translation
  --qx QX               x component of quaternion rotation
  --qy QY               y component of quaternion rotation
  --qz QZ               z component of quaternion rotation
  --qw QW               w component of quaternion rotation
  --roll ROLL           roll component Euler rotation
  --pitch PITCH         pitch component Euler rotation
  --yaw YAW             yaw component Euler rotation
edit flag offensive delete link more

Comments

Thank you for the answer. Yes, that is what I mentioned and it is now the only way to publish the static transform directly without implementing something by myself. But they also have this node implemented - and my question is why that node cannot be used directly (using ros2 run, with a yaml param file).

tommy_erko gravatar image tommy_erko  ( 2022-12-20 03:20:07 -0500 )edit
1

The command line tool could be extended to accept the parameters. The node that you point to is designed as a Component and is expected to be run inside of a container and you pass the parameters to it there.

There's a tutorial here: http://docs.ros.org/en/rolling/Tutori... and you would typically want to use it with a launch file: http://docs.ros.org/en/rolling/Tutori...

tfoote gravatar image tfoote  ( 2022-12-20 04:06:50 -0500 )edit

Thank you! I have very little experience with components and composable nodes, so I did not know I can look for that. I resolved it like this:

in launch file add to LaunchDescription

ComposableNodeContainer(
    name='tf_container',
    package='rclcpp_components',
    executable='component_container',
    namespace='',
    composable_node_descriptions=[
        ComposableNode(
            package='tf2_ros',
            plugin='tf2_ros::StaticTransformBroadcasterNode',
            name='tf_publisher',
            parameters=[tf_params])
    ],
    output='screen',
)

where tf_params yaml file looks like

tf_publisher:
  ros__parameters:
    frame_id: world
    child_frame_id: map
    translation.x: 0.0
    translation.y: 0.0
    translation.z: 0.0
    rotation.x: 0.0
    rotation.y: 0.0
    rotation.z: 0.0
    rotation.w: 1.0
tommy_erko gravatar image tommy_erko  ( 2022-12-20 06:15:01 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2022-12-19 04:27:19 -0500

Seen: 572 times

Last updated: Dec 20 '22