Ask Your Question
0

how to pass parameters to URDF in ros2 launch file?

asked 2021-07-02 08:40:57 -0600

pmuthu2s gravatar image

I know we can do this in ROS-1, but I'm not exactly sure with the syntax in ROS2.

Just a small try I had given:

start_robot_state_publisher_cmd = Node(
    package='robot_state_publisher',
    executable='robot_state_publisher',
    name='robot_state_publisher',
    output='screen',
    parameters=[{'use_sim_time': use_sim_time, 'frame_prefix': 'robot1/', 'robot_description': Command([robot_desc,'tfpre:=', 'robot1/'])}],
    arguments=[urdf])

tf pre is the parameter I'm trying to pass. But, I'm certainly sure there is some mistake with this ,method.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-07-02 10:04:39 -0600

jafar_abdi gravatar image

One way to do it is as follow

import xacro
...
urdf = xacro.process_file(file_path, mappings={'tfpre': 'robot1/'}).toxml()
# Use urdf
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-07-02 08:40:57 -0600

Seen: 76 times

Last updated: Jul 02 '21