📖 Scenario: You are building a robot control system that needs to perform a task which takes time and can provide feedback during execution. You will create a ROS action definition file to specify the goal, feedback, and result messages for this task.
🎯 Goal: Create a ROS .action file that defines the structure for a robot's task including goal, feedback, and result sections.
📋 What You'll Learn
Create a RobotTask.action file with three sections separated by ---
Define a goal message with a string task_name and an int32 duration
Define a feedback message with a float32 progress field
Define a result message with a bool success and a string message
💡 Why This Matters
🌍 Real World
Robots often perform tasks that take time and need progress updates. ROS actions let you define these tasks clearly so the robot and other software can communicate effectively.
💼 Career
Understanding ROS action definitions is essential for robotics developers working on task execution, control systems, and robot communication.
Progress0 / 4 steps
1
Create the Goal section in the .action file
Create a file named RobotTask.action and write the Goal section with these exact fields: string task_name and int32 duration. Do NOT add any other sections yet.
ROS
Hint
The Goal section is the first part of the .action file before the first --- separator.
2
Add the Feedback section separated by ---
In the RobotTask.action file, add the separator --- after the Goal section, then add the Feedback section with the exact field: float32 progress.
ROS
Hint
The Feedback section comes after the first --- separator.
3
Add the Result section separated by ---
In the RobotTask.action file, add another separator --- after the Feedback section, then add the Result section with these exact fields: bool success and string message.
ROS
Hint
The Result section is the last part of the .action file after the second --- separator.
4
Complete and verify the full .action file structure
Ensure the RobotTask.action file has exactly three sections separated by --- in this order: Goal with string task_name and int32 duration, Feedback with float32 progress, and Result with bool success and string message. The file should be ready to use in a ROS action server.
ROS
Hint
Check that the separators and fields are exactly as specified for ROS to recognize the action.
Practice
(1/5)
1. What is the main purpose of an .action file in ROS?
easy
A. To define goals, results, and feedback for long-running tasks
B. To list all the nodes in a ROS system
C. To configure robot sensors
D. To specify message types for topics
Solution
Step 1: Understand the role of .action files
.action files are designed to define the structure of actions, which include goals, feedback, and results for tasks that take time.
Step 2: Compare with other ROS files
Unlike message or service files, .action files specifically handle long-running tasks with progress updates.
Final Answer:
To define goals, results, and feedback for long-running tasks -> Option A
Quick Check:
Action files = goals + feedback + results [OK]
Hint: Remember: .action files split into goal, result, feedback [OK]
Common Mistakes:
Confusing .action files with .msg or .srv files
Thinking .action files configure hardware
Assuming .action files list nodes
2. Which of the following is the correct structure of a ROS .action file?
easy
A. goal fields --- feedback fields --- result fields
B. goal fields --- result fields --- feedback fields
C. result fields --- feedback fields --- goal fields
D. feedback fields --- goal fields --- result fields
Solution
Step 1: Recall the .action file format
The .action file has three parts separated by lines with three dashes (---): first goal, then result, then feedback.
Step 2: Match the order
The correct order is goal fields first, result fields second, and feedback fields last.
Final Answer:
goal fields --- result fields --- feedback fields -> Option B
Quick Check:
Order = goal, result, feedback [OK]
Hint: Remember order: Goal first, Result second, Feedback last [OK]
The file has goal fields first, then feedback fields, then result fields, separated by --- lines.
Step 2: Verify field types in each section
Goal has int32, feedback has float32, result has int32. However, the correct order is goal, result, feedback.
Final Answer:
Result section must come before feedback -> Option A
Quick Check:
Correct order is goal, result, feedback [OK]
Hint: Check section order and field types carefully [OK]
Common Mistakes:
Thinking feedback must come last
Assuming feedback cannot have fields
Mixing up result and feedback order
5. You want to define an action for a robot to move to a position with feedback on distance left and a result indicating success. Which .action file snippet correctly defines this?
The goal should specify the target position (target_x, target_y). Feedback should provide ongoing info (distance_left). Result should indicate success (bool success).
Step 2: Match the correct order in the .action file
The order is goal fields first, then feedback fields, then result fields. float64 target_x
float64 target_y
---
float64 distance_left
---
bool success matches this order correctly.