RVIZ how to pass in parameter in launch file
I am trying to write a launch file that automate my visualization process, the idea is to take a msg.Image topic name as argument and launch RVIZ to launch a image panel for that topic:
def generate_launch_description():
sensor_topic_arg = DeclareLaunchArgument(
'sensor_topic',
default_value='/test_sensor'
)
ld = launch.LaunchDescription([
sensor_topic_arg
])
ld.add_action(
Node(
package='rviz2',
executable='rviz2',
)
)
return ld
How can I pass the image topic to RVIZ as an argument, so that the RVIZ will be able to show the topic on an image panel on launch.
Asked by ziranshu on 2022-11-15 23:30:55 UTC
Answers
How can I pass the image topic to RVIZ as an argument, so that the RVIZ will be able to show the topic on an image panel on launch.
You don't do that. Instead, you should save the RViz config in a config file. Next time, while invoking RViz, please provide the complete path to that .rviz
file. For example, please see the code snippet below, in which rviz_config_file
variable holds the absolute path to the .rviz
file.
# Open RViz
rviz_node = Node(
package='rviz2',
executable='rviz2',
name='image_demo_rviz',
arguments=['-d', rviz_config_file]
)
Asked by ravijoshi on 2022-11-17 05:44:42 UTC
Comments