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

ros2 launch using ignition while run command line in ros2

asked 2022-02-07 11:43:32 -0500

kak13 gravatar image

How do you load some command line such as "ros2 topic pub --once /S0 std_msgs/msg/Float64 '{data: 1.5}' && ros2 topic pub --once /S1 std_msgs/msg/Float64 '{data: 1.5}'" while leave ignition bridge in the launch file?

Even better, how do you create a node where you can load ros2 command line?

edit retag flag offensive close merge delete

Comments

I'm not sure I follow your question. Are you asking how to run ros2 topic pub ... from a launch file? If so, use the launch.actions.ExecuteProcess action.

ChuiV gravatar image ChuiV  ( 2022-02-09 19:50:23 -0500 )edit

Yes!! I think that's the one.

How do you use it exactly? I don't think I've ever seen it before

kak13 gravatar image kak13  ( 2022-02-13 23:27:49 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-02-14 08:53:26 -0500

ChuiV gravatar image

updated 2022-02-16 09:05:45 -0500

Sounds like you're looking for the ExecuteProcess Launch action:

from launch import LaunchDescription
from launch.action import ExecuteProcess

def generate_launch_description():
    return LaunchDescription([
        ExecuteProcess(cmd=['ros2', 'topic', 'pub', '--once', '/S0',
                            'std_msgs/msg/Float64', '{data: 1.5}']),
        ExecuteProcess(cmd=['ros2', 'topic', 'pub', '--once', '/S1',
                            'std_msgs/msg/Float64', '{data: 1.5}']),
    ])

Another example can be found in the launch examples: https://github.com/ros2/launch/blob/m...

edit flag offensive delete link more

Comments

Thank you so much!

kak13 gravatar image kak13  ( 2022-02-16 08:19:27 -0500 )edit

Question Tools

Stats

Asked: 2022-02-07 11:43:32 -0500

Seen: 396 times

Last updated: Feb 16 '22