add_two_ints_client_async

This file is ai generated. Do not edit this file directly. Instead, edit the node source code and run the generate-node-docs command to update this file.

Description

A ROS2 service client node that demonstrates asynchronous service calling pattern. It calls the add_two_ints service with two integers (2 and 3) and polls for the result using spin_once rather than blocking. This shows how to handle service responses asynchronously.

Services

  • Service Client: /add_two_ints

    • Type: example_interfaces/srv/AddTwoInts

    • Description: Asynchronously calls the add_two_ints service

Example Usage

# Run the async client (requires add_two_ints_server to be running)
ros2 run demo_nodes_py add_two_ints_client_async

The client will output:

service not available, waiting again...  # (if server not ready)
[INFO] [add_two_ints_client]: Result of add_two_ints: 5

Complete example:

# Terminal 1: Run the server
ros2 run demo_nodes_py add_two_ints_server

# Terminal 2: Run the async client
ros2 run demo_nodes_py add_two_ints_client_async