Hi community,
I am working on the Mapping section of the Rosject. I found that if I use a single launch file to launch map_server and rviz2, rviz2 will not receive the map topic from map_server. I believe it is because the map_server publishes the map topic before the rviz2 has launched. Because if I call the load map service, the rviz2 can show the map correctly.
Is there any method to solve this or should I write them in separate launch files? Below is my launch file.
import os
import launch.actions
import launch_ros.actions
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node
def generate_launch_description():
rviz_config_dir = <path-to-rviz-config>
map_file = <path-to-my-map>
return LaunchDescription([
Node(
package='nav2_map_server',
node_executable='map_server',
node_name='map_server',
output='screen',
parameters=[{'use_sim_time': True},
{'yaml_filename':map_file}
]),
Node(
package='rviz2',
node_executable='rviz2',
node_name='rviz2',
arguments=['-d', rviz_config_dir],
parameters=[{'use_sim_time': True}],
output='screen'
),
Node(
package='nav2_lifecycle_manager',
node_executable='lifecycle_manager',
node_name='lifecycle_manager_localization',
output='screen',
parameters=[{'use_sim_time': True},
{'autostart': True},
{'node_names': ['map_server']}])
])
Thanks,
Alan