Bird
Raised Fist0
ROSframework~20 mins

Action client with feedback in ROS - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
ROS Action Client Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate
2:00remaining
What does this ROS action client print when receiving feedback?
Consider a ROS action client that sends a goal and prints feedback messages received from the server. What will be printed if the server sends feedback with progress 50% and then 100%?
ROS
import actionlib
from some_msgs.msg import SomeAction, SomeGoal

def feedback_cb(feedback):
    print(f"Progress: {feedback.progress}%")

client = actionlib.SimpleActionClient('some_action', SomeAction)
client.wait_for_server()
goal = SomeGoal()
client.send_goal(goal, feedback_cb=feedback_cb)
client.wait_for_result()
AProgress: 50%\nProgress: 100%
BProgress: 100%\nProgress: 50%
CNo output because feedback_cb is not called
DProgress: 0%\nProgress: 50%
Attempts:
2 left
💡 Hint
Feedback callbacks are called each time the server sends feedback.
❓ state_output
intermediate
2:00remaining
What is the final state of the action client after goal completion?
Given a ROS action client that sends a goal and waits for the result, what will be the state of the client after the server completes the goal successfully?
ROS
import actionlib
from some_msgs.msg import SomeAction, SomeGoal

client = actionlib.SimpleActionClient('some_action', SomeAction)
client.wait_for_server()
goal = SomeGoal()
client.send_goal(goal)
client.wait_for_result()
state = client.get_state()
Aactionlib.GoalStatus.PREEMPTED (2)
Bactionlib.GoalStatus.SUCCEEDED (3)
Cactionlib.GoalStatus.ABORTED (4)
Dactionlib.GoalStatus.PENDING (0)
Attempts:
2 left
💡 Hint
Check the meaning of the state codes in actionlib.GoalStatus.
📝 Syntax
advanced
2:00remaining
Which option correctly sets up a feedback callback in a ROS action client?
Select the code snippet that correctly passes a feedback callback function to the send_goal method of a ROS action client.
Aclient.send_goal(goal, feedbackCallback=feedback_cb())
Bclient.send_goal(goal, feedback=feedback_cb)
Cclient.send_goal(goal, feedbackCallback=feedback_cb)
Dclient.send_goal(goal, feedback_cb=feedback_cb)
Attempts:
2 left
💡 Hint
Check the parameter name expected by send_goal for feedback callbacks.
🔧 Debug
advanced
2:00remaining
Why does this ROS action client not print feedback messages?
This ROS action client code does not print any feedback messages even though the server sends them. What is the cause?
ROS
import actionlib
from some_msgs.msg import SomeAction, SomeGoal

def feedback_cb(feedback):
    print(f"Progress: {feedback.progress}%")

client = actionlib.SimpleActionClient('some_action', SomeAction)
client.wait_for_server()
goal = SomeGoal()
client.send_goal(goal)
client.wait_for_result()
AThe feedback callback is not passed to send_goal, so it is never called.
BThe feedback callback function has a syntax error and is ignored.
CThe goal message is empty, so no feedback is sent.
DThe client never waits for the server, so feedback is lost.
Attempts:
2 left
💡 Hint
Check how the feedback callback is connected to the client.
🧠 Conceptual
expert
2:00remaining
What is the role of feedback in a ROS action client-server interaction?
In ROS action communication, what is the main purpose of feedback messages sent from the action server to the client?
ATo send the final result of the goal execution to the client.
BTo confirm that the goal has been accepted by the server.
CTo inform the client about the ongoing progress or partial results before the goal completes.
DTo cancel the goal execution on the server side.
Attempts:
2 left
💡 Hint
Think about what feedback means in everyday tasks.

Practice

(1/5)
1. What is the main purpose of an action client in ROS when using feedback?
easy
A. To directly control robot hardware without feedback
B. To send goals to an action server and receive progress updates
C. To replace service calls with simpler requests
D. To only receive the final result without intermediate updates

Solution

  1. Step 1: Understand the role of an action client

    An action client sends goals to an action server and can receive feedback during execution.
  2. Step 2: Identify feedback purpose

    Feedback callbacks provide real-time progress updates while the task runs.
  3. Final Answer:

    To send goals to an action server and receive progress updates -> Option B
  4. Quick Check:

    Action client = send goals + get feedback [OK]
Hint: Action clients send goals and get feedback updates [OK]
Common Mistakes:
  • Thinking action clients only get final results
  • Confusing action clients with service clients
  • Ignoring feedback callbacks
2. Which of the following is the correct way to create an action client with feedback in ROS Python?
easy
A. client = actionlib.SimpleActionClient('move', MoveAction, feedback_cb=feedback_cb)
B. client = actionlib.ActionClient('move', MoveAction, feedback_cb=feedback_cb)
C. client = actionlib.SimpleActionClient('move', MoveAction)
D. client = actionlib.ActionClient('move', MoveAction)

Solution

  1. Step 1: Recall ROS Python action client syntax

    The standard way is to use SimpleActionClient with server name and action type.
  2. Step 2: Feedback callback is set separately

    Feedback callbacks are registered when sending goals, not in constructor.
  3. Final Answer:

    client = actionlib.SimpleActionClient('move', MoveAction) -> Option C
  4. Quick Check:

    SimpleActionClient + feedback_cb separate [OK]
Hint: Feedback callback is passed when sending goal, not client creation [OK]
Common Mistakes:
  • Passing feedback_cb in constructor (wrong)
  • Using ActionClient instead of SimpleActionClient
  • Missing action type argument
3. Given this ROS Python snippet, what will be printed if the feedback callback receives progress=50?
def feedback_cb(feedback):
    print(f"Progress: {feedback.progress}%")

client = actionlib.SimpleActionClient('task', TaskAction)
client.wait_for_server()
goal = TaskGoal()
client.send_goal(goal, feedback_cb=feedback_cb)
medium
A. Progress: 50%
B. Progress: feedback.progress%
C. Progress: None%
D. No output because feedback_cb is not called

Solution

  1. Step 1: Understand feedback callback behavior

    The feedback_cb prints the progress attribute from feedback with formatting.
  2. Step 2: Substitute progress value

    If feedback.progress is 50, the print outputs "Progress: 50%" exactly.
  3. Final Answer:

    Progress: 50% -> Option A
  4. Quick Check:

    Formatted string with feedback.progress = output [OK]
Hint: Feedback callback prints formatted progress value [OK]
Common Mistakes:
  • Printing variable name instead of value
  • Assuming feedback_cb is not called
  • Ignoring string formatting
4. What is wrong with this ROS Python action client code snippet?
client = actionlib.SimpleActionClient('task', TaskAction)
client.send_goal(TaskGoal(), feedback_cb=feedback_cb)
client.wait_for_server()
medium
A. wait_for_server() should be called before send_goal()
B. feedback_cb cannot be passed to send_goal()
C. TaskGoal() must be assigned to a variable before sending
D. SimpleActionClient requires a third argument for feedback

Solution

  1. Step 1: Check action client usage order

    wait_for_server() must be called before sending a goal to ensure server is ready.
  2. Step 2: Identify error in code order

    Here, send_goal() is called before wait_for_server(), which is incorrect.
  3. Final Answer:

    wait_for_server() should be called before send_goal() -> Option A
  4. Quick Check:

    wait_for_server() before send_goal() [OK]
Hint: Always wait for server before sending goal [OK]
Common Mistakes:
  • Calling send_goal before wait_for_server
  • Misunderstanding feedback_cb usage
  • Assuming feedback_cb is constructor argument
5. You want to implement an action client that sends multiple goals sequentially and prints feedback for each. Which approach correctly handles feedback for each goal without mixing updates?
hard
A. Ignore feedback and only wait for final results of each goal
B. Use a single global feedback callback for all goals without distinguishing them
C. Send all goals at once without waiting and use one feedback callback
D. Create a new feedback callback function for each goal that captures its goal ID

Solution

  1. Step 1: Understand feedback handling for multiple goals

    Each goal's feedback should be handled separately to avoid mixing progress updates.
  2. Step 2: Use closures or separate callbacks

    Creating a unique feedback callback per goal that captures its ID ensures correct feedback association.
  3. Final Answer:

    Create a new feedback callback function for each goal that captures its goal ID -> Option D
  4. Quick Check:

    Separate feedback callbacks per goal prevent mix-up [OK]
Hint: Use unique feedback callbacks per goal to track progress separately [OK]
Common Mistakes:
  • Using one callback for all goals causing mixed feedback
  • Sending all goals simultaneously without control
  • Ignoring feedback defeats purpose of action client
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