Sending Goals to the Robot Navigation Stack

Now everything is ready, if you haven’t already start the simulation, SLAM and the navigation stack with nav_demo.launch.py using the normal,

ros2 launch navigation_demos nav_demo.launch.py

Send a Goal Pose Manually

To send the robot to a goal we need to provide a goal to the “/navigation_to_pose” action server. An autonomous algorithm/agent would publish goal messages directly to the action server. Like all things in ROS, we can send messages in the terminal to emulate this.

Ensure you have RVIZ visible on the screen, and in a new terminal (placed somewhere as to not block your view of RVIZ) send the command below.

ros2 action send_goal /navigate_to_pose nav2_msgs/action/NavigateToPose "pose:
  header:
    stamp:
      sec: 0
      nanosec: 0
    frame_id: 'map'
  pose:
    position:
      x: 1.0
      y: 0.0
      z: 0.0
    orientation:
      x: 0.0
      y: 0.0
      z: 0.0
      w: 1.0
behavior_tree: ''"

Hooray! The robot should be navigating! You should see the robot drive forward, whilst publishing the global path and the trajectory the controller is attempting to take.

Send a Goal Using Visual Tools

It is much easier as a human to select a point on the map, rather than estimate the coordinates of a position. In RVIZ, along the top bar there is a button called Nav 2 Goal, read the steps below, then head to rviz to try it out.

  1. Press the Nav2 Goal button to enable the tool

  2. Hover over a specific point in the map you wish to navigate to

  3. Press and HOLD the left mouse button

  4. Drag your mouse around to change the direction of the arrows

  5. Release the left mouse button

The base of the arrow indicates the pose position, whereas the arrow indicates the pose orientation. Once you release the left mouse button, the goal is sent.

Sending a navigation goal via RVIZ visual tools.

Hooray! The robot should be driving to where your arrow was!