Nav2 Setup
Nav2 (Navigation 2) is the ROS 2 navigation stack. It provides path planning, recovery behaviours, and costmap management.
Installation
bash
sudo apt install ros-humble-navigation2 ros-humble-nav2-bringupLaunch Nav2
bash
ros2 launch nav2_bringup navigation_launch.py use_sim_time:=trueKey Parameters (nav2_params.yaml)
yaml
bt_navigator:
ros__parameters:
global_frame: map
robot_base_frame: base_link
odom_topic: /odom
controller_server:
ros__parameters:
controller_plugins: ["FollowPath"]
FollowPath:
plugin: "nav2_regulated_pure_pursuit_controller::RegulatedPurePursuitController"
desired_linear_vel: 0.5
lookahead_dist: 0.6Sending a Goal
python
from nav2_simple_commander.robot_navigator import BasicNavigator
from geometry_msgs.msg import PoseStamped
nav = BasicNavigator()
goal = PoseStamped()
goal.header.frame_id = 'map'
goal.pose.position.x = 2.0
goal.pose.position.y = 1.5
nav.goToPose(goal)WARNING
Always initialise the robot's pose with 2D Pose Estimate in RViz before sending navigation goals.