|
nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
|
#include <publisher.hpp>
Classes | |
| class | Loan |
Public Member Functions | |
| Result | assert_liveliness () |
| const char * | get_topic_name () const |
| Get the topic name. | |
| bool | is_valid () const |
| Check if the publisher is initialized and valid. | |
| Expected< Loan > | loan (size_t requested_len) |
| Result | on_liveliness_lost (nros_cpp_publisher_count_cb_t cb, void *user_context=nullptr) |
| Register a callback for liveliness-lost events on this publisher. | |
| Result | on_offered_deadline_missed (uint32_t deadline_ms, nros_cpp_publisher_count_cb_t cb, void *user_context=nullptr) |
| Publisher & | operator= (Publisher &&other) |
| Result | publish (const M &msg) |
| Result | publish_raw (const uint8_t *data, size_t len) |
| Publish raw CDR bytes. | |
| template<typename W > | |
| Result | publish_streamed (size_t total_len, W &&writer) |
| Publisher () | |
| Publisher (Publisher &&other) | |
| ~Publisher () | |
| Destructor — releases publisher resources. | |
Friends | |
| class | Node |
Typed publisher for a ROS 2 topic.
Mirrors rclcpp::Publisher<M>. The message type M must provide TYPE_NAME, TYPE_HASH, and ffi_publish() (generated by codegen).
Raw CDR publishing is always available via publish_raw().
Inline storage holds the runtime publisher handle directly (NROS_PUBLISHER_SIZE bytes; size auto-derived from the runtime). Topic name metadata lives C++-side in topic_name_, avoiding a runtime hop for get_topic_name().
Usage:
|
inline |
Destructor — releases publisher resources.
|
inline |
Default constructor — creates an uninitialized publisher. Use Node::create_publisher() to initialize.
|
inline |
Phase 108.B.7 — manually assert liveliness. Required for publishers configured with LivelinessManualByTopic / ManualByNode; no-op for Automatic / None.
Get the topic name.
|
inline |
Check if the publisher is initialized and valid.
|
inline |
Register a callback for liveliness-lost events on this publisher.
|
inline |
Register a callback for offered-deadline-missed events on this publisher.
Publish a typed message.
Calls the codegen-generated M::ffi_publish() which serializes the message to CDR and publishes it.
Publish raw CDR bytes.
|
inline |
Phase 124.E.1 — streamed publish.
total_len declares the full payload size; writer is invoked one or more times with a writable chunk and must return the bytes written. The runtime/backend allocates total_len bytes (in the outbound buffer when the backend natively streams, otherwise in a stack staging buffer capped at ~4 KiB) and drains the closure until full.
writer signature: size_t(uint8_t* chunk, size_t cap).