📖 Scenario: You are programming a robot to move to specific points in a room. You want to tell the robot exactly where to go by setting navigation goals.
🎯 Goal: Build a simple ROS node that sets a navigation goal with exact coordinates and orientation for the robot to reach.
📋 What You'll Learn
Create a ROS node named goal_sender
Define a navigation goal with position x=2.0, y=3.0 and orientation w=1.0
Use the move_base_msgs/MoveBaseGoal message to set the goal
Send the goal to the move_base action server
💡 Why This Matters
🌍 Real World
Robots in warehouses or homes need to move to specific locations safely and accurately. Setting navigation goals lets you control where the robot goes.
💼 Career
Understanding how to send navigation goals is essential for robotics engineers working with autonomous robots and ROS.
Progress0 / 4 steps
1
Create the ROS node and import necessary libraries
Write the first lines of a Python ROS node named goal_sender. Import rospy, actionlib, and MoveBaseAction and MoveBaseGoal from move_base_msgs.msg. Initialize the node with rospy.init_node('goal_sender').
ROS
Hint
Use import statements for the libraries and rospy.init_node to start the node.
2
Create an action client to communicate with move_base
Create an action client named client using actionlib.SimpleActionClient for the move_base action server with MoveBaseAction. Wait for the server to be ready using client.wait_for_server().
ROS
Hint
Use SimpleActionClient with the server name 'move_base' and the action type MoveBaseAction.
3
Define the navigation goal with position and orientation
Create a MoveBaseGoal object named goal. Set goal.target_pose.header.frame_id to "map". Set goal.target_pose.header.stamp to rospy.Time.now(). Set goal.target_pose.pose.position.x to 2.0 and goal.target_pose.pose.position.y to 3.0. Set goal.target_pose.pose.orientation.w to 1.0.
ROS
Hint
Use the MoveBaseGoal message fields to set the position and orientation inside target_pose.pose. Don't forget to set the header timestamp.
4
Send the goal to the move_base action server
Send the goal to the move_base server using client.send_goal(goal). Then wait for the result with client.wait_for_result().
ROS
Hint
Use send_goal to send the goal and wait_for_result to wait until the robot reaches the goal.
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
Step 1: Understand navigation goals
Navigation goals specify a target position and orientation for the robot to reach.
Step 2: Identify the purpose
Setting a navigation goal directs the robot where to move in its environment.
Final Answer:
To tell the robot where to move using coordinates and orientation -> Option A
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
Step 1: Identify common frames in ROS navigation
Frames like "base_link", "odom", and "map" represent different coordinate systems.
Step 2: Choose the frame for environment-relative goals
The "map" frame is fixed to the environment and used for global navigation goals.
Final Answer:
"map" frame -> Option C
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: