Hello everyone,
I have been playing with my ROSbot 2.0 PRO for a couple of weeks and I’m stuck in a lack of clear documentation.
I have installed the husarion packages and tried both navigation_demo_sim.launch and navigation_demo_pro.launch. These launch files starts the navigation and SLAM packages so than I can build a map after moving around the robot with the keyboard teleop and calling the map_saver_cli of ROS2. While doing so, the topic /pose is published but there is no position published in it. My understanding is that it will be sent only if the robot knows the map and can determine it’s position based on AMCL mapping.
So, now that I have my generated map (map.pgm and map.yaml), I want to use it into navigation_demo_sim.launch and navigation_demo_pro.launch. What needs to be modified in those launch files to take into account my newly generated map instead of building a new one every time and not benefiting from the /pose topic ?
All the documentation that I can find is on ROS1. I found a topic here describing what I want to do in ROS 2:
answer_ros.com
I tried to implement it in your existing launch (rosbot_navigation_sim.launch) with no success, see code below.
So my question is, do you know how to achieve what I want to do and can you provide a launch file to make my ROSbot 2.0 PRO work with AMCL on an already built map ?
Thank you a lot for your help !
Ps: Subsidiary question : How can I easily change the Gazebo world in your simulation demo ? The current world is huge, therefore the generated map is quite heavy too.
import os
from launch import LaunchDescription
import launch.actions
import launch_ros.actions
from launch.actions import DeclareLaunchArgument, SetEnvironmentVariable
from ament_index_python.packages import get_package_prefix
from ament_index_python.packages import get_package_share_directory
from nav2_common.launch import RewrittenYaml
def generate_launch_description():
rosbot_description = get_package_share_directory('rosbot_description')
use_sim_time = launch.substitutions.LaunchConfiguration('use_sim_time',
default='true')
autostart = launch.substitutions.LaunchConfiguration('autostart')
params_file = launch.substitutions.LaunchConfiguration('params')
default_bt_xml_filename = launch.substitutions.LaunchConfiguration(
'default_bt_xml_filename')
remappings = []
# Map server ---------------ADDED--------------
map_server_config_path = os.path.join(
get_package_share_directory('rosbot_description'),
'maps',
'map_sim.yaml'
)
#---------------------------------------------------
# Create our own temporary YAML files that include substitutions
param_substitutions = {
'use_sim_time': use_sim_time,
'default_bt_xml_filename': default_bt_xml_filename,
'autostart': autostart,
}
lifecycle_nodes = ['controller_server',
'planner_server',
'recoveries_server',
'bt_navigator',
'map_server', #---------------ADDED--------------
'waypoint_follower']
configured_params = RewrittenYaml(
source_file=params_file,
param_rewrites=param_substitutions,
convert_types=True)
return LaunchDescription([
# Set env var to print messages to stdout immediately
SetEnvironmentVariable('RCUTILS_LOGGING_BUFFERED_STREAM', '1'),
launch.actions.DeclareLaunchArgument(
'use_sim_time', default_value='false',
description='Use simulation (Gazebo) clock if true'),
launch.actions.DeclareLaunchArgument(
'autostart', default_value='true',
description='Automatically startup the nav2 stack'),
launch.actions.DeclareLaunchArgument(
'params',
default_value=[rosbot_description,
'/config/nav2_params.yaml'],
description='Full path to the ROS2 parameters file to use'),
DeclareLaunchArgument(
'default_bt_xml_filename',
default_value=os.path.join(
get_package_share_directory('nav2_bt_navigator'),
'behavior_trees', 'navigate_w_replanning_and_recovery.xml'),
description='Full path to the behavior tree xml file to use'),
launch_ros.actions.Node(
package='nav2_controller',
executable='controller_server',
output='screen',
parameters=[configured_params],
remappings=remappings),
launch_ros.actions.Node(
package='nav2_planner',
executable='planner_server',
name='planner_server',
output='screen',
parameters=[configured_params],
remappings=remappings),
launch_ros.actions.Node(
package='nav2_recoveries',
executable='recoveries_server',
name='recoveries_server',
output='screen',
parameters=[{'use_sim_time': use_sim_time}],
remappings=remappings),
launch_ros.actions.Node(
package='nav2_bt_navigator',
executable='bt_navigator',
name='bt_navigator',
output='screen',
parameters=[configured_params],
remappings=remappings),
launch_ros.actions.Node(
package='nav2_waypoint_follower',
executable='waypoint_follower',
name='waypoint_follower',
output='screen',
parameters=[configured_params],
remappings=remappings),
#---------------ADDED--------------
launch_ros.actions.Node(
package='nav2_map_server',
executable='map_server',
output='screen',
parameters=[{'yaml_filename': map_server_config_path}],
remappings=remappings),
#----------------------------------------
launch_ros.actions.Node(
package='nav2_lifecycle_manager',
executable='lifecycle_manager',
name='lifecycle_manager_navigation',
output='screen',
parameters=[{'use_sim_time': use_sim_time},
{'autostart': autostart},
{'node_names': lifecycle_nodes}]),
])