liveBook · Manning

Callback

As explained in Robotics for Programmers

A callback function is a function supplied to another component for invocation when a specified event or operation completes.

A callback is a function supplied to another component for invocation when a specified operation completes. In a ROS service, the server invokes its callback for each client request; the callback reads the request, fills the response, and returns it. section 4.6

In an asynchronous ROS service client, callbacks separate request submission from response handling:

  • Create a request and call the service asynchronously with call_async(). section 4.6

ROS service callbacks

A service server connects set_bool_callback to my_set_bool_service. A client submits SetBool.Request(data=True), then response_callback receives the completed Future and reads its result.

How Robotics for Programmers covers it

How deep it goes
Defines callback inputs and outputs through working server and client code, but does not explain callback internals beyond invocation and completion.
Examples
Uses SetBool service requests, set_bool_callback, response_callback, command-line calls, and the rqt Service Caller.
What it assumes
Assumes familiarity with Python classes, ROS nodes, service types, requests, responses, and asynchronous calls.
What you can do after
Apply it via rclpy to process ROS service requests and handle asynchronous results when their Futures complete.
How it connects
Links ROS services, service clients, asynchronous calls, Python Futures, and request-response interfaces.

Also explained in

Compare how 23 books explain callback →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Robotics for Programmers. The section links point to the parts of the book it draws on.