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

ros2 launch - how to send a ROS msg type as parameter

asked 2022-03-28 05:29:03 -0500

ljaniec gravatar image

Hello,

I am working on a ROS msgs recorder and I am not sure how should I set up a launch parameter with given ROS message type.

I tried with something like:

self.declare_parameter(
    "msg_type", None, descriptor=ParameterDescriptor(dynamic_typing=True)
)
self.declare_parameter(
    "source_topic", None, descriptor=ParameterDescriptor(dynamic_typing=True)
)

and

start_string_recorder = Node(
        package="bag_recorder",
        executable="string_msg_recorder",
        name="string_msg_recorder",
        namespace=namespace,
        output="screen",
        parameters=[
            {
                "msg_type": "String",
                "source_topic": "/chatter",
            }
        ],
    )

But the resulting rosbag2 is empty and there is a problem with ros2 topic echo /chatter too:

Cannot echo topic '/chatter', as it contains more than one type: [rcl_interfaces/msg/ParameterValue, std_msgs/msg/String]

What is the best approach to launcher with this kind of needs (e.g. one of the parameters should be arguments is a ROS message type)?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-03-29 05:01:01 -0500

ljaniec gravatar image

I revised my code to use message type and a source topic as arguments in __init__ function.

It works in code but I still don't know if a launch script wouldn't be better.

I can use rosbag2 CLI there, but it's more annoying with parameters in YAML file, e.g. I couldn't set up a default path to save a folder with rosbag2. If anybody knows how to do it, I would appreciate your help.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2022-03-28 05:29:03 -0500

Seen: 316 times

Last updated: Mar 29 '22