Provides examples for calling ROS 2 services asynchronously from python. For now the repository is focused on single-threaded python nodes.
delay_server: Offers a/delay (std_srvs/srv/Empty)service that delays for 3 seconds before returningdeadlock: This node calls/delayimproperly and deadlocksawait: This node uses python asyncio to wait for the service to completefuture: This node directly polls a future object after calling the service
- It is often useful to run the server and the experiment node in separate windows, to see how they interact:
ros2 run async_experiments delay_server # run the delay server ros2 run async_experiments <deadlock|await|future> # run the node of your choice
- A launchfile can also be used:
ros2 launch async_experiments experiment.launch.xml experiment:=<deadlock|await|future>
async_experiments/hand_async.pyoutlines an experiment that can be done to test a hand-rolled async implementation example.- The code expects a named pipe called
/tmp/fifoto exist: make it withmkfifo /tmp/fifo - Run the example with
python3 -m async_experiments.hand_async - Events can be sent by
echo "A" > /tmp/fifo(for example). Seeasync_experiments/hand_async.pyfor a detailed walkthrough.
- The code expects a named pipe called
See https://nu-msr.github.io/ros_notes/ros2/spin.html#walkthrough