5.1 ROS 2 Interface Usage Guide
This page explains how to inspect the service interfaces installed on the robot and the QoS settings required when creating topic publishers or subscribers.
5.1.1 Inspect Service Interfaces
Use a service type to inspect its request and response fields:
ros2 interface show aimdk_msgs/srv/GetVolume # Show GetVolume request and response fields
In this command, aimdk_msgs/srv/GetVolume is the service type, not the runtime service name. In the output, --- separates the request from the response:
# Request fields
CommonRequest request
---
# Response fields
CommonResponse reponse
uint32 audio_volume
The reponse Field
Some legacy service interfaces name the common response field reponse. This is the actual field name in those interfaces, so client code must use that exact spelling and must not change it to response.
result->reponse // C++ access
result.reponse # Python access
Different services may use reponse, response, or another response structure. Follow the ros2 interface show output and the corresponding interface page.
If the full interface cannot be expanded, inspect the generated response type:
python3 -c "from aimdk_msgs.srv import GetVolume as S; print(S.Response.get_fields_and_field_types())" # S is the GetVolume service type; Response is its response type; print field names and types
These commands only read locally installed interface definitions; they do not call a service or change the robot state. Refer to the corresponding interface page to determine whether reponse is enabled and whether its header.code and status fields represent the operation result.
5.1.2 Topic QoS
QoS (Quality of Service) is a communication policy provided by ROS 2. AimDK uses ROS 2 QoS without introducing a custom configuration protocol.
Different topics may use different QoS settings. When creating a publisher or subscriber, use the QoS settings on the corresponding interface page and ensure that both endpoints are compatible. Otherwise, the topic may be visible while no messages are received.
5.1.3 Common Policies
Policy |
Value |
Description |
|---|---|---|
|
|
Attempts to deliver messages reliably and can retransmit lost messages |
|
|
Sends on a best-effort basis without guaranteed retransmission; suitable for continuous, high-rate data |
|
|
Receives only new messages after the subscription is established |
|
|
Allows the publisher to retain some historical messages for compatible late-joining subscribers |
|
|
Keeps only the most recent messages |
|
|
Keeps all messages within resource limits |
|
Positive integer |
Queue length when using |
Interface tables usually list only reliability and durability, which have the greatest effect on communication compatibility. Unless an interface page states otherwise, do not infer the system-side history, depth, deadline, lifespan, or liveliness settings from these values.
5.1.4 Compatibility
QoS parameters do not need to be identical, but the capabilities offered by the publisher must satisfy the subscriber’s request.
Reliability
Publisher |
Subscriber: |
Subscriber: |
|---|---|---|
|
Compatible |
Incompatible |
|
Compatible |
Compatible |
Durability
Publisher |
Subscriber: |
Subscriber: |
|---|---|---|
|
Compatible |
Incompatible |
|
Compatible; receives only new messages after connection |
Compatible; can receive historical messages retained by the publisher |
TRANSIENT_LOCAL does not mean permanent storage. The number of historical messages available also depends on the publisher’s history and depth settings and whether the publisher is still running.
5.1.5 View Topic QoS
You can use the following read-only command to view a topic’s type and the actual QoS of every publisher and subscriber (--no-daemon --spin-time 6 skips the CLI background daemon’s cold-start wait, see the FAQ; the same applies to node list and service list):
ros2 topic info <topic> --verbose --no-daemon --spin-time 6
Check these fields in the output:
Reliability
Durability
History
Depth
Example:
ros2 topic info /aima/sm/system_state --verbose --no-daemon --spin-time 6
Interface pages record the QoS used by the corresponding AimDK version. When troubleshooting communication, compare the interface page, the current robot topic information, and the settings in the user program.
5.1.6 QoS Configuration Examples
The following examples configure BEST_EFFORT + TRANSIENT_LOCAL + KEEP_LAST(10). In an application, replace these values with the settings required by the target topic’s interface page.
C++
auto qos = rclcpp::QoS(rclcpp::KeepLast(10))
.best_effort()
.transient_local();
Python
from rclpy.qos import (
QoSDurabilityPolicy,
QoSHistoryPolicy,
QoSProfile,
QoSReliabilityPolicy,
)
qos = QoSProfile(
history=QoSHistoryPolicy.KEEP_LAST,
depth=10,
reliability=QoSReliabilityPolicy.BEST_EFFORT,
durability=QoSDurabilityPolicy.TRANSIENT_LOCAL,
)
The depth=10 setting in these examples is the local queue configuration of the user node. It does not mean that every AimDK system topic has a queue length of 10.