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

How to merge 2 topics in ROS2?

asked 2022-08-30 16:48:35 -0500

Thugunb gravatar image

updated 2022-08-30 16:49:22 -0500

I am trying to integrate nav2 into one of my robots and I'm almost done. Nav2 is publishing movement information into /cmd_vel while my robot is looking for that info through /robo/cmd_vel. I can't change the requirement from /robo/cmd_vel so is there any easy way to take information published in /cmd_vel into /robo/cmd_vel?

I initially considered writing a node to simply transfer the data but this seems like a task that would have a pre-existing command for ROS2.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2022-08-31 03:12:21 -0500

Reamees gravatar image

You need to remap the /cmd_vel topic in your launch file for nav2 to publish to the topic you want. Relevant snippet from this answer: how-to-remap-topic-in-a-ros2-launch-file

forward_turtlesim_commands_to_second_turtlesim_node = Node(
    package='turtlesim',
    executable='mimic',
    name='mimic',
    remappings=[
        ('/input/pose', '/turtlesim1/turtle1/pose'),
        ('/output/cmd_vel', '/turtlesim2/turtle1/cmd_vel'),
    ]
)

The node to republish a topic to a different topic already exists in the topic_tools package, the relay node there specifically, but as I said, in this case you would just want to remap the topic that nav2 outputs.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-08-30 16:48:35 -0500

Seen: 126 times

Last updated: Aug 31 '22