Bird
Raised Fist0
ROSframework~10 mins

Setting navigation goals in ROS - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Setting navigation goals
Start Node
↓
Create Goal Message
↓
Set Goal Coordinates
↓
Send Goal to Action Server
↓
Wait for Result
↓
Check Status
↓
End
This flow shows how a navigation goal is created, sent to the robot, and how the result is checked.
Execution Sample
ROS
import actionlib
from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal

client = actionlib.SimpleActionClient('move_base', MoveBaseAction)
client.wait_for_server()

goal = MoveBaseGoal()
goal.target_pose.header.frame_id = 'map'
goal.target_pose.header.stamp = rospy.Time.now()
goal.target_pose.pose.position.x = 1.0
goal.target_pose.pose.position.y = 2.0
goal.target_pose.pose.orientation.w = 1.0

client.send_goal(goal)
client.wait_for_result()

result = client.get_state()
This code connects to the move_base action server, sets a goal position and orientation, sends it, waits for the robot to reach it, and checks the result.
Execution Table
StepActionGoal StateServer ResponseResult State
1Create MoveBaseGoal messageGoal emptyNo responseNo result
2Set goal position x=1.0, y=2.0Goal set to (1.0, 2.0)No responseNo result
3Set goal orientation w=1.0Goal orientation setNo responseNo result
4Send goal to move_base serverGoal sentServer acknowledges goalNo result
5Wait for resultGoal activeServer processing goalNo result
6Goal reached successfullyGoal reachedServer reports successSUCCEEDED
7Get result stateGoal reachedNo responseSUCCEEDED
💡 Goal reached successfully, navigation complete
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 6Final
goal.target_pose.pose.position.x0.01.01.01.01.01.0
goal.target_pose.pose.position.y0.02.02.02.02.02.0
goal.target_pose.pose.orientation.w0.00.01.01.01.01.0
resultNoneNoneNoneNoneNoneSUCCEEDED
Key Moments - 2 Insights
Why do we wait for the server before sending the goal?
Waiting for the server ensures the action server is ready to receive goals. Without this, sending a goal might fail. See execution_table step 4 where the server acknowledges the goal only after waiting.
What does the 'result' variable represent after waiting for the result?
The 'result' holds the status of the navigation goal, such as SUCCEEDED or FAILED. In execution_table step 7, 'result' is SUCCEEDED, meaning the robot reached the goal.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the goal position x after step 2?
A2.0
B0.0
C1.0
DNot set yet
💡 Hint
Check variable_tracker row for goal.target_pose.pose.position.x after step 2
At which step does the server acknowledge the goal?
AStep 3
BStep 4
CStep 5
DStep 6
💡 Hint
Look at execution_table Server Response column
If the robot fails to reach the goal, which step would show a different result state?
AStep 6
BStep 2
CStep 4
DStep 1
💡 Hint
Result state changes after waiting for result, see execution_table step 6
Concept Snapshot
Setting navigation goals in ROS:
- Create MoveBaseGoal message
- Set position and orientation
- Wait for action server to be ready
- Send goal to move_base
- Wait for result and check status
- SUCCEEDED means goal reached
Full Transcript
This visual execution trace shows how to set navigation goals in ROS using the move_base action server. First, a MoveBaseGoal message is created and its position and orientation are set. The client waits for the move_base server to be ready before sending the goal. After sending, it waits for the robot to reach the goal. The server responds with success or failure. Variables like goal position and result state change step by step. Key moments include waiting for the server and interpreting the result. The quiz tests understanding of goal setting and server communication.

Practice

(1/5)
1. What is the main purpose of setting a navigation goal in ROS?
easy
A. To tell the robot where to move using coordinates and orientation
B. To change the robot's color
C. To update the robot's software version
D. To stop the robot immediately

Solution

  1. Step 1: Understand navigation goals

    Navigation goals specify a target position and orientation for the robot to reach.
  2. Step 2: Identify the purpose

    Setting a navigation goal directs the robot where to move in its environment.
  3. Final Answer:

    To tell the robot where to move using coordinates and orientation -> Option A
  4. Quick Check:

    Navigation goal = target position [OK]
Hint: Navigation goals set robot's target position and direction [OK]
Common Mistakes:
  • Confusing navigation goals with software updates
  • Thinking navigation goals change robot appearance
  • Assuming navigation goals stop the robot
2. Which ROS frame is commonly used to set navigation goals relative to the environment?
easy
A. "base_link" frame
B. "odom" frame
C. "map" frame
D. "camera" frame

Solution

  1. Step 1: Identify common frames in ROS navigation

    Frames like "base_link", "odom", and "map" represent different coordinate systems.
  2. Step 2: Choose the frame for environment-relative goals

    The "map" frame is fixed to the environment and used for global navigation goals.
  3. Final Answer:

    "map" frame -> Option C
  4. Quick Check:

    Environment-relative goals use "map" frame [OK]
Hint: "map" frame is fixed to environment, perfect for goals [OK]
Common Mistakes:
  • Using "base_link" which is robot-centered
  • Choosing "odom" which drifts over time
  • Selecting "camera" which is unrelated to navigation
3. Given this ROS Python snippet to send a navigation goal:
goal.target_pose.header.frame_id = "map"
goal.target_pose.pose.position.x = 2.0
goal.target_pose.pose.position.y = 3.0
goal.target_pose.pose.orientation.w = 1.0
client.send_goal(goal)
client.wait_for_result()
What will the robot do?
medium
A. Throw an error due to missing orientation x, y, z
B. Move to position (3.0, 2.0) on the map facing backward
C. Stay still because orientation is incomplete
D. Move to position (2.0, 3.0) on the map facing forward

Solution

  1. Step 1: Analyze position and orientation values

    Position is set to x=2.0, y=3.0; orientation.w=1.0 means no rotation (facing forward).
  2. Step 2: Understand client commands

    Sending goal and waiting for result commands the robot to move to the specified pose.
  3. Final Answer:

    Move to position (2.0, 3.0) on the map facing forward -> Option D
  4. Quick Check:

    Goal pose = (2.0,3.0), orientation forward [OK]
Hint: Orientation w=1 means facing forward, position sets location [OK]
Common Mistakes:
  • Mixing up x and y coordinates
  • Assuming missing orientation x,y,z causes error
  • Thinking orientation.w=1 means backward
4. What is wrong with this ROS Python code snippet for setting a navigation goal?
goal.target_pose.header.frame_id = "map"
goal.target_pose.pose.position.x = 1.0
goal.target_pose.pose.position.y = 2.0
client.send_goal(goal)
client.wait_for_result()
medium
A. frame_id should be "odom" instead of "map"
B. Missing orientation in goal.pose causes navigation failure
C. Position values must be integers, not floats
D. client.wait_for_result() must come before send_goal()

Solution

  1. Step 1: Check completeness of goal pose

    Orientation is not set, which is required for a valid navigation goal.
  2. Step 2: Verify other parts

    frame_id "map" is correct; position floats are allowed; wait_for_result() must follow send_goal().
  3. Final Answer:

    Missing orientation in goal.pose causes navigation failure -> Option B
  4. Quick Check:

    Orientation required for goal [OK]
Hint: Always set orientation when sending navigation goals [OK]
Common Mistakes:
  • Ignoring missing orientation
  • Changing frame_id unnecessarily
  • Misordering wait_for_result and send_goal
5. You want the robot to navigate to two different points sequentially using ROS move_base. Which approach correctly sets and sends these goals?
hard
A. Send first goal, wait for result, then send second goal and wait again
B. Send both goals at the same time without waiting
C. Send second goal first, then send first goal after completion
D. Only send the last goal; the robot will visit both automatically

Solution

  1. Step 1: Understand sequential goal sending

    To visit points in order, send one goal and wait for it to finish before sending the next.
  2. Step 2: Evaluate options

    Sending both simultaneously confuses the robot; sending second first breaks order; last goal alone ignores first.
  3. Final Answer:

    Send first goal, wait for result, then send second goal and wait again -> Option A
  4. Quick Check:

    Sequential goals need wait between sends [OK]
Hint: Wait for each goal to finish before sending next [OK]
Common Mistakes:
  • Sending multiple goals simultaneously
  • Assuming robot queues goals automatically
  • Sending goals in wrong order
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard