Challenge - 5 Problems
ROS Action Server Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediateWhat is the output behavior of this ROS action server code?
Consider a ROS action server implemented in Python that accepts a goal to count up to a number. What will the server do when it receives a goal with count=5?
ROS
import rclpy from rclpy.action import ActionServer from example_interfaces.action import Fibonacci class CountActionServer: def __init__(self, node): self._action_server = ActionServer( node, Fibonacci, 'count_action', self.execute_callback) def execute_callback(self, goal_handle): feedback_msg = Fibonacci.Feedback() feedback_msg.sequence = [0, 1] for i in range(1, goal_handle.request.order): feedback_msg.sequence.append( feedback_msg.sequence[i] + feedback_msg.sequence[i - 1]) goal_handle.publish_feedback(feedback_msg) goal_handle.succeed() result = Fibonacci.Result() result.sequence = feedback_msg.sequence return result
Attempts:
2 left
💡 Hint
Think about how the feedback sequence is built and when the result is returned.
✗ Incorrect
The execute_callback builds the Fibonacci sequence up to the requested order, publishing feedback at each step. After the loop, it calls succeed() and returns the full sequence as the result.
📝 Syntax
intermediateWhich option contains a syntax error in ROS action server implementation?
Identify the option that will cause a syntax error when defining the execute callback method for a ROS action server in Python.
Attempts:
2 left
💡 Hint
Check the function parameter list syntax carefully.
✗ Incorrect
Option B is missing a comma between parameters 'self' and 'goal_handle', causing a syntax error.
❓ state_output
advancedWhat is the final state of the action server after this code runs?
Given this ROS action server code snippet, what will be the final state of the goal after execute_callback finishes?
ROS
def execute_callback(self, goal_handle): if goal_handle.is_cancel_requested: goal_handle.canceled() return Fibonacci.Result() goal_handle.succeed() result = Fibonacci.Result() result.sequence = [0, 1, 1, 2, 3] return result
Attempts:
2 left
💡 Hint
Check the order of cancel request check and succeed call.
✗ Incorrect
If the goal is not canceled, the server calls succeed() and returns the result, so the final state is SUCCEEDED.
🔧 Debug
advancedWhy does this ROS action server code cause the client to never receive a result?
Examine the code and select the reason why the client never gets a result from the action server.
ROS
def execute_callback(self, goal_handle): feedback = Fibonacci.Feedback() feedback.sequence = [0, 1] for i in range(1, goal_handle.request.order): feedback.sequence.append(feedback.sequence[i] + feedback.sequence[i - 1]) goal_handle.publish_feedback(feedback) # Missing goal_handle.succeed() call result = Fibonacci.Result() result.sequence = feedback.sequence return result
Attempts:
2 left
💡 Hint
Check if the server signals goal completion properly.
✗ Incorrect
Without calling succeed(), the action server does not mark the goal as finished, so the client waits forever.
🧠 Conceptual
expertWhich statement best describes the role of feedback in a ROS action server?
Select the most accurate description of how feedback is used in a ROS action server implementation.
Attempts:
2 left
💡 Hint
Think about how clients track progress during long-running tasks.
✗ Incorrect
Feedback messages are sent repeatedly during goal execution to inform the client of progress before the final result is ready.
