Map Creation
Launch Gazebo (terminal 1):
ros2 launch big_robot_gazebo launch_sim.launch.xml
Run SLAM Toolbox (terminal 2):
ros2 launch big_robot_navigation map_building.launch.xml use_sim_time:=true
Run RViz (terminal 3):
ros2 launch big_robot_navigation map_view.launch.xml
Activate keyboard to move around map (terminal 4):
ros2 run teleop_twist_keyboard teleop_twist_keyboard
Save the map (terminal 5):
ros2 run nav2_map_server map_saver_cli -f <save name>
- Ex; ros2 run nav2_map_server map_saver_cli -f my_map2
see replies for navigation + localization steps
Navigation + Localization
Launch Gazebo (terminal 1):
ros2 launch big_robot_gazebo launch_sim.launch.xml
Launch both localization and navigation (terminal 2):
ros2 launch big_robot_navigation bringup_launch.xml use_sim_time:=True map:=my_map.yaml
- Replace my_map.yaml with the name of your map.
- If you’re in Gazebo at the same time, set use_sim_time:=true.
Launch RViz to visualize the map and robot (terminal 3):
ros2 launch big_robot_navigation nav2_view.launch.xml
View global cost map (from saved map) in RViz:
Click add -> by topic -> global_costmap -> map
- Regions will pop up describing where obstacles are and aren’t
View local cost map (from LiDar) in RViz:
Click add -> by topic -> local_costmap -> map
Localize the robot (AMCL):
*Nav2 uses Adaptive Monte Carlo Localization to estimate where the robot is on the map
In RViz:
- Click “2D Pose Estimate” (green arrow icon).
- Click and drag where your robot currently is on the map, aligning the arrow with its orientation.
This tells Nav2 roughly where the robot starts. You should see particles (small arrows) spread around the robot – these will converge as the robot localizes.
Send a navigation goal:
Once localization stabilizes:
In RViz:
- Click “2D Goal Post”
- Click anywhere on the map where you want the robot to go.
If everything is set up correctly:
- The robot will plan a path (visible as a purple line with arrows).
- It will start moving autonomously along the planned trajectory.
- You’ll see it dynamically avoid obstacles if local cost maps are enabled.