Running RViz from Launch File with -d
I have been using python to launch all my ros2 nodes at once. When launching rviz2, I add the "-d + str(rvizconfigfile)" to the arguments. rvizconfigfile is determined using Path and getpackageshare_directory to list the full path to the configuration file. Upon launch, RViz shows the default configuration instead of my customized view. What's confusing me is that RViz shows the correct path to my file at the top center of the viewing window. I can use the RViz menu to "Open Config" and follow the exact path RViz has listed, and my custom configurations appear. Since I can open it with no problems through RViz, I don't think the problem is with the configuration file. Has anyone else run into this issue with RViz and ROS2?
Code used to launch RViz in Python:
base = Path(getpackageshare_directory('[base-package]'))
rviz_file = Path(base / [path-to-file])
rviz2node = launchros.actions.Node(
name='rviz2',
package='rviz2',
executable='rviz2',
arguments=[ '-d ' + str(rviz_file)]
)
Asked by alliprice on 2023-01-11 11:45:06 UTC
Comments