nros C API
Lightweight ROS 2 client for embedded real-time systems
Loading...
Searching...
No Matches
Functions
subscription.h File Reference

Topic subscription API. More...

#include "rclc/types.h"
#include "rclc/detail/declared_qos.h"
#include "rclc/rclc.h"
Include dependency graph for subscription.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static rcl_ret_t rclc_subscription_init_best_effort (struct rcl_subscription_t *subscription, const struct rcl_node_t *node, const struct rclc_message_type_t *type_info, const char *topic_name)
 rclc's best-effort preset constructor for a subscription.
 

Detailed Description

Topic subscription API.

Create a subscription with rclc_subscription_init_default() (or rclc_subscription_init_with_qos()) and add it to an executor, which owns its subscriber and its callback: rclc_executor_add_subscription_with_context() delivers deserialised messages (rclc's own six arguments), rclc_executor_add_subscription_raw() CDR bytes.

For manual polling with no executor, use the separate type rclc_polling_subscription_t: create it with rclc_polling_subscription_init() and drain it with rclc_polling_subscription_take() (deserialised, the rcl_take analog) or rclc_polling_subscription_take_serialized() — or rclc_polling_subscription_take_sequence() for a batch and rclc_polling_subscription_take_validated() for the E2E-safety variant. The two types are separate since phase-487: a dispatched subscription's storage is in the executor arena, a polled one's is in the struct.

Function Documentation

◆ rclc_subscription_init_best_effort()

static rcl_ret_t rclc_subscription_init_best_effort ( struct rcl_subscription_t *  subscription,
const struct rcl_node_t *  node,
const struct rclc_message_type_t *  type_info,
const char *  topic_name 
)
inlinestatic

rclc's best-effort preset constructor for a subscription.

phase-417 W5.d; the sibling of rclc_publisher_init_best_effort() and the same argument. rclc's body (rclc/src/rclc/subscription.c @ 10eadcc) is rclc_subscription_init(..., &rmw_qos_profile_sensor_data) — best-effort, volatile, KEEP_LAST(5) — which RCLC_QOS_SENSOR_DATA mirrors.

Takes no callback, at rclc's arity: the callback is supplied at registration by rclc_executor_add_subscription_raw(), exactly where rclc supplies it (rclc_executor_add_subscription). That is the same split rclc_subscription_init_default already makes, so the two presets differ only in the profile they pass.

static inline: no symbol, no writable data.

Parameters
[out]subscriptionZero-initialised subscription to fill in.
[in]nodeAn initialised node.
[in]type_infoGenerated message type descriptor.
[in]topic_nameTopic name, null-terminated.
Returns
Whatever rclc_subscription_init_with_qos() returns.