System Specification
Ubuntu 22.04 LTS
ROS2-HUMBLE
Gazebo11
So basically, I am using gazebo to simulate an environment for my robot to map. Mapping using slam and nav2 works perfectly. However, when I want to launch the nav2 and rviz2 with the map that I had saved, the map does not load on rviz2 rviz visualization The launch file is as follows:
import os
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.conditions import IfCondition
from launch_ros.substitutions import FindPackageShare
from launch_ros.actions import Node
MAP_NAME='playground' #change to the name of your own map here
def generate_launch_description():
depth_sensor = os.getenv('LINOROBOT2_DEPTH_SENSOR', '')
nav2_launch_path = PathJoinSubstitution(
[FindPackageShare('nav2_bringup'), 'launch', 'bringup_launch.py']
)
rviz_config_path = PathJoinSubstitution(
[FindPackageShare('linorobot2_navigation'), 'rviz', 'linorobot2_navigation.rviz']
)
default_map_path = PathJoinSubstitution(
[FindPackageShare('linorobot2_navigation'), 'maps', f'{MAP_NAME}.yaml']
)
nav2_config_path = PathJoinSubstitution(
[FindPackageShare('linorobot2_navigation'), 'config', 'navigation.yaml']
)
return LaunchDescription([
DeclareLaunchArgument(
name='sim',
default_value='false',
description='Enable use_sime_time to true'
),
DeclareLaunchArgument(
name='rviz',
default_value='false',
description='Run rviz'
),
DeclareLaunchArgument(
name='map',
default_value=default_map_path,
description='Navigation map path'
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource(nav2_launch_path),
launch_arguments={
'map': LaunchConfiguration("map"),
'use_sim_time': LaunchConfiguration("sim"),
'params_file': nav2_config_path
}.items()
),
Node(
package='rviz2',
executable='rviz2',
name='rviz2',
output='screen',
arguments=['-d', rviz_config_path],
condition=IfCondition(LaunchConfiguration("rviz")),
parameters=[{'use_sim_time': LaunchConfiguration("sim")}]
)
])
To reproduce the problem simply,
mkdir ws
cd ws
mkdir src
git clone -b humble https://github.com/linorobot/linorobot2 src/linorobot2
git clone https://github.com/linorobot/linorobot2_viz src/linorobot2_viz
rosdep update && rosdep install --from-path src --ignore-src -y
colcon build
In one terminal run
source /opt/ros/humble/setup.bash
source install/setup.bash
ros2 launch linorobot2_gazebo gazebo.launch.py
Open another terminal
cd ws
source /opt/ros/humble/setup.bash
source install/setup.bash
ros2 launch linorobot2_navigation navigation.launch.py sim:=true rviz:=true
rviz will then show this image I have tried the nav2 turtlebot3 tutorial and their map shows up fine on rviz which indicates it's neither a gazebo nor rviz2 issue. I checked our topic list and found /map, /map_server/transition_event, /map_updates are present. I also cross-compared our launch file, robot_model file, and maps files with turtlebot3 but is unable to identify any part that is wrong. Does anyone have an idea about why the map is not received?