Bird
Raised Fist0
ROSframework~10 mins

Action client with feedback in ROS - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Action client with feedback
Create Action Client
↓
Send Goal to Server
↓
Wait for Feedback
↓
Receive Feedback
↓
Process Feedback
↓
Receive Result
↓
Handle Result
↓
End
The client creates an action client, sends a goal, listens for feedback repeatedly, then receives and handles the final result.
Execution Sample
ROS
client = actionlib.SimpleActionClient('do_something', DoSomethingAction)
client.wait_for_server()
goal = DoSomethingGoal()
client.send_goal(goal, feedback_cb=feedback_cb)
client.wait_for_result()
result = client.get_result()
This code creates an action client, sends a goal with a feedback callback, waits for the result, and then gets the result.
Execution Table
StepActionClient StateFeedback ReceivedResult ReceivedOutput
1Create Action ClientInitialized, not connectedNoneNoneClient ready
2Wait for ServerConnected to serverNoneNoneServer available
3Send GoalGoal sentNoneNoneGoal sent to server
4Wait for FeedbackWaitingNoneNoneWaiting for feedback...
5Receive Feedback #1WaitingProgress 10%NoneFeedback callback called with 10%
6Receive Feedback #2WaitingProgress 50%NoneFeedback callback called with 50%
7Receive Feedback #3WaitingProgress 90%NoneFeedback callback called with 90%
8Receive ResultDoneProgress 90%SuccessResult received: Success
9Handle ResultDoneProgress 90%SuccessProcess final result
10EndIdleProgress 90%SuccessAction complete
💡 Result received and processed, action client ends.
Variable Tracker
VariableStartAfter Step 3After Step 5After Step 8Final
client.stateNot connectedGoal sentWaitingDoneIdle
feedbackNoneNoneProgress 10%Progress 90%Progress 90%
resultNoneNoneNoneSuccessSuccess
Key Moments - 3 Insights
Why does the client keep waiting after sending the goal?
Because the client waits for feedback and the final result from the server before proceeding, as shown in steps 4 to 7 in the execution_table.
How does the client receive progress updates?
The client uses a feedback callback function that is called each time the server sends feedback, shown in steps 5, 6, and 7.
What happens when the result is received?
The client changes state to done and processes the final result, as shown in steps 8 and 9.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the client state after sending the goal (Step 3)?
AWaiting
BGoal sent
CDone
DNot connected
💡 Hint
Check the 'Client State' column at Step 3 in the execution_table.
At which step does the client receive the final result?
AStep 5
BStep 7
CStep 8
DStep 10
💡 Hint
Look for 'Result Received' column showing 'Success' in the execution_table.
If the feedback callback was never called, what would change in the execution_table?
AFeedback Received column would remain 'None' in all steps
BClient state would never be 'Waiting'
CResult would never be received
DGoal would not be sent
💡 Hint
Check the 'Feedback Received' column in the execution_table for feedback callback calls.
Concept Snapshot
Action Client with Feedback in ROS:
- Create client and wait for server
- Send goal with feedback callback
- Feedback callback runs on updates
- Wait for and get final result
- Process result and finish
Use feedback_cb param to handle progress updates.
Full Transcript
In ROS, an action client connects to an action server to request a task. First, the client is created and waits until the server is ready. Then, it sends a goal to the server. After sending, the client waits for feedback messages that tell how the task is progressing. Each feedback triggers a callback function to handle updates. When the server finishes, it sends a result. The client receives this result, processes it, and ends the action. This flow helps the client track progress and know when the task is done.

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