liveBook · Manning

Future

As explained in Robotics for Programmers

A Python Future object represents the eventual result of an asynchronous computation.

A Python Future represents the eventual result of an asynchronous computation. In ROS 2, rclpy.call_async() returns one for a service request, allowing client code to continue without blocking. section 4.6

Register a callback with add_done_callback(). When the service call reaches the done state, the callback retrieves the response with future.result() and uses its fields. section 4.6

Asynchronous SetBool service call

A timer creates a SetBool request, calls self.cli.call_async(request), and registers self.response_callback. The callback obtains response_future.result() and logs the returned message.

How Robotics for Programmers covers it

How deep it goes
Explains creation, completion callbacks, and result extraction, but does not detail Future internals.
Examples
Uses a SetBool service client that logs the completed response from a timer-triggered request.
What it assumes
Assumes Python and basic ROS 2 service-client concepts while demonstrating the asynchronous call pattern.
What you can do after
Operate asynchronous rclpy service clients by registering completion callbacks and extracting returned responses.
How it connects
Connects asynchronous programming with ROS 2 service calls, callbacks, clients, and deadlock avoidance.

Also explained in

Compare how 9 books explain future →

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.