nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
rclcpp::NodeWithTimers< MaxTimers > Class Template Reference

#include <node.hpp>

Inheritance diagram for rclcpp::NodeWithTimers< MaxTimers >:
Inheritance graph
[legend]
Collaboration diagram for rclcpp::NodeWithTimers< MaxTimers >:
Collaboration graph
[legend]

Public Member Functions

template<class C , void(C::*)() Method>
void create_timer_in_group (const CallbackGroup &group, uint64_t period_ms)
 
void create_timer_in_group (const CallbackGroup &group, uint64_t period_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
 The plain C callback + ctx form, in a group, parked in the pool.
 
template<class C , void(C::*)() Method>
void create_wall_timer_in (uint64_t period_ms)
 
void create_wall_timer_in (uint64_t period_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
 The plain C callback + ctx escape hatch, parked in the pool.
 
- Public Member Functions inherited from rclcpp::Node
Result add_on_set_parameters_callback (OnSetParametersCallbackType callback, void *context, ParameterCallbackHandle &out_handle)
 
bool check_declared_depth (const char *type_name, const char *topic, const ::rclcpp::QoS &qos)
 
bool check_declared_param (const char *name, int passed_type)
 
bool check_declared_qos (const char *type_name, const char *topic, const ::rclcpp::QoS &qos)
 
Result count_publishers (const char *topic_name, size_t *out_count) const
 
Result count_subscribers (const char *topic_name, size_t *out_count) const
 
template<typename A >
Result create_action_client (::rclcpp_action::Client< A > &out, const char *action_name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
 
template<typename A >
Result create_action_server (::rclcpp_action::Server< A > &out, const char *action_name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services(), const ::rclcpp::ActionServerOptions &options={})
 
::rclcpp::CallbackGroup create_callback_group (const char *name)
 
template<typename S , typename F , typename = typename std::enable_if< std::is_convertible<F, void (*)(const typename S::Response&)>::value>::type>
Result create_client (::rclcpp::Client< S > &out, const char *service_name, F callback, const ::rclcpp::QoS &qos=::rclcpp::QoS::services(), const ::rclcpp::ClientOptions &options={})
 
template<typename S >
Result create_client (::rclcpp::PollClient< S > &out, const char *service_name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
 
template<typename S , typename F , typename , typename >
Client< S >::SharedPtr create_client (const char *, F, const ::rclcpp::QoS &)
 
template<typename S , typename F , typename = typename ::rclcpp::tr::enable_if< !::rclcpp::detail::is_qos_arg<F>::value && !::rclcpp::tr::is_convertible<F, void (*)(const typename S::Response&)>::value>::type, typename = void>
typename::rclcpp::Client< S >::SharedPtr create_client (const char *, F, const ::rclcpp::QoS &=::rclcpp::QoS::services())
 REFUSED — upstream's shared_ptr handler shape.
 
template<typename S >
inline ::rclcpp::Owned<::rclcpp::PollClient< S > > create_client (const char *name, const ::rclcpp::QoS &qos)
 
template<typename S >
::rclcpp::Owned<::rclcpp::PollClient< S > > create_client (const char *name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
 
template<typename S , typename F , typename >
Client< S >::SharedPtr create_client (const char *name, F callback, const ::rclcpp::QoS &qos)
 
template<typename S , typename F , typename = typename ::rclcpp::tr::enable_if<::rclcpp::tr::is_convertible< F, void (*)(const typename S::Response&)>::value>::type>
typename::rclcpp::Client< S >::SharedPtr create_client (const char *name, F callback, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
 Callback-style service client (void(const S::Response&)).
 
Result create_guard_condition (::rclcpp::GuardCondition &out, nros_cpp_guard_callback_t callback, void *context=nullptr)
 
template<typename A >
Result create_polling_action_client (::rclcpp::PollingActionClient< A > &out, const char *action_name)
 Phase 122.3.d.b — Create an L1 polling-mode action client.
 
template<typename A >
Result create_polling_action_server (::rclcpp::PollingActionServer< A > &out, const char *action_name)
 
template<typename M >
Result create_polling_subscription (::rclcpp::PollingSubscription< M > &out, const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
 
template<typename M >
Result create_publisher (::rclcpp::Publisher< M > &out, const char *topic, const ::rclcpp::QoS &qos, const ::rclcpp::PublisherOptions &options)
 
template<typename M >
Result create_publisher (::rclcpp::Publisher< M > &out, const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
 
template<typename M >
typename::rclcpp::Publisher< M >::SharedPtr create_publisher (const char *topic, ::size_t depth)
 create_publisher<M>(topic, depth) — the integer-depth spelling.
 
template<typename M >
Publisher< M >::SharedPtr create_publisher (const char *topic, ::size_t depth)
 
template<typename M >
Publisher< M >::SharedPtr create_publisher (const char *topic, const ::rclcpp::QoS &qos)
 
template<typename M >
typename::rclcpp::Publisher< M >::SharedPtr create_publisher (const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
 create_publisher<M>(topic, qos) — available on every target.
 
template<typename M >
::rclcpp::Publisher< M > create_publisher_in (const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
 
template<typename M >
Result create_publisher_in_group (const ::rclcpp::CallbackGroup &, ::rclcpp::Publisher< M > &out, const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
 
template<typename S >
Result create_service (::rclcpp::PollService< S > &out, const char *service_name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
 
template<typename S , typename F , typename = typename std::enable_if<std::is_convertible< F, void (*)(const typename S::Request&, typename S::Response&)>::value>::type>
Result create_service (::rclcpp::Service< S > &out, const char *service_name, F callback, const ::rclcpp::QoS &qos=::rclcpp::QoS::services(), const ::rclcpp::ServiceOptions &options={})
 
template<typename S , typename F , typename , typename >
Service< S >::SharedPtr create_service (const char *, F, const ::rclcpp::QoS &)
 
template<typename S , typename F , typename = typename ::rclcpp::tr::enable_if< !::rclcpp::detail::is_qos_arg<F>::value && !::rclcpp::tr::is_convertible<F, void (*)(const typename S::Request&, typename S::Response&)>::value>::type, typename = void>
typename::rclcpp::Service< S >::SharedPtr create_service (const char *, F, const ::rclcpp::QoS &=::rclcpp::QoS::services())
 
template<typename S >
inline ::rclcpp::Owned<::rclcpp::PollService< S > > create_service (const char *name, const ::rclcpp::QoS &qos)
 
template<typename S >
::rclcpp::Owned<::rclcpp::PollService< S > > create_service (const char *name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
 
template<typename S , typename F , typename >
Service< S >::SharedPtr create_service (const char *name, F callback, const ::rclcpp::QoS &qos)
 
template<typename S , typename F , typename = typename ::rclcpp::tr::enable_if<::rclcpp::tr::is_convertible< F, void (*)(const typename S::Request&, typename S::Response&)>::value>::type>
typename::rclcpp::Service< S >::SharedPtr create_service (const char *name, F callback, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
 Callback-style service server (void(const S::Request&, S::Response&)).
 
template<typename M >
Result create_subscription (::rclcpp::PollSubscription< M > &out, const char *topic, const ::rclcpp::QoS &qos, const ::rclcpp::SubscriptionOptions &options)
 
template<typename M >
Result create_subscription (::rclcpp::PollSubscription< M > &out, const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
 
template<typename M , typename F , typename = typename std::enable_if<std::is_convertible<F, void (*)(const M&)>::value>::type>
Result create_subscription (::rclcpp::Subscription< M > &out, const char *topic, const ::rclcpp::QoS &qos, F callback, const ::rclcpp::SubscriptionOptions &options={})
 
template<typename M , typename Cb >
typename::rclcpp::Subscription< M >::SharedPtr create_subscription (const char *topic, ::size_t depth, Cb cb)
 create_subscription<M>(topic, depth, callback).
 
template<typename M , typename Cb >
Subscription< M >::SharedPtr create_subscription (const char *topic, ::size_t depth, Cb cb)
 
template<typename M , typename Cb >
typename::rclcpp::Subscription< M >::SharedPtr create_subscription (const char *topic, const ::rclcpp::QoS &qos, Cb cb)
 
template<typename M , typename Cb >
Subscription< M >::SharedPtr create_subscription (const char *topic, const ::rclcpp::QoS &qos, Cb cb)
 
template<typename M , class C , void(C::*)(const M &msg) Method>
void create_subscription_in (const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
 
template<typename M , typename F , typename = typename std::enable_if<std::is_convertible<F, void (*)(const M&)>::value>::type>
Result create_subscription_in_group (const ::rclcpp::CallbackGroup &group, ::rclcpp::Subscription< M > &out, const char *topic, const ::rclcpp::QoS &qos, F callback, const ::rclcpp::SubscriptionOptions &options={})
 
template<typename M , class C , void(C::*)(const M &msg) Method>
void create_subscription_in_group (const ::rclcpp::CallbackGroup &group, const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
 
template<typename M , typename F , typename = typename std::enable_if< std::is_convertible<F, void (*)(const M&, const uint8_t*, size_t)>::value>::type>
Result create_subscription_with_info (::rclcpp::Subscription< M > &out, const char *topic, const ::rclcpp::QoS &qos, F callback, const ::rclcpp::SubscriptionOptions &options={})
 
template<class C , void(C::*)() Method>
Result create_timer (Timer &out, const Clock &clock, uint64_t period_ms, C *self)
 
Result create_timer (Timer &out, const Clock &clock, uint64_t period_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
 
template<class C , void(C::*)() Method>
Result create_timer_in_group (const ::rclcpp::CallbackGroup &group, Timer &out, uint64_t period_ms, C *self)
 
Result create_timer_in_group (const ::rclcpp::CallbackGroup &group, Timer &out, uint64_t period_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
 
Result create_timer_oneshot (Timer &out, uint64_t delay_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
 
template<typename Cb >
::rclcpp::TimerHandle create_wall_timer (::rclcpp::Duration period, Cb cb)
 
template<typename Cb >
inline ::rclcpp::TimerHandle create_wall_timer (::rclcpp::Duration period, Cb cb)
 
template<class C , void(C::*)() Method>
Result create_wall_timer (Timer &out, uint64_t period_ms, C *self)
 
Result create_wall_timer (Timer &out, uint64_t period_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
 
template<typename T >
T declare_parameter (const char *name, T default_value, const ParameterDescriptor &descriptor)
 
template<typename T >
T declare_parameter (const char *name, T default_value=T())
 rclcpp::Node::declare_parameter<T>(name, default).
 
Result describe_parameter (const char *name, ParameterDescriptor &out, char *text, ::size_t text_len) const
 
int32_t error_code () const
 The raw error code of the first latched failure, or 0.
 
const char * error_what () const
 
void * executor_handle () const
 
const nros_cpp_node_t * ffi_handle () const
 
Result get_client_names_and_types_by_node (const char *node_name, const char *node_namespace, nros_cpp_names_and_types_visit_fn visit, void *ctx) const
 
Clock * get_clock ()
 
const Clock * get_clock () const
 Const overload of get_clock().
 
Result get_fully_qualified_name (char *buf, size_t buf_len, size_t *out_len=nullptr) const
 
::rclcpp::Logger get_logger () const
 
const char * get_name () const
 Get the node name.
 
const char * get_namespace () const
 Get the node namespace.
 
Result get_node_names (nros_cpp_node_visit_fn visit, void *ctx) const
 
const ::rclcpp::NodeOptions & get_node_options () const
 
template<typename T >
T get_parameter (const char *name) const
 Value-returning read; T() when the name is undeclared.
 
template<typename T >
bool get_parameter (const char *name, T &out) const
 
template<typename T >
bool get_parameter_or (const char *name, T &out, T fallback) const
 
ParameterType get_parameter_type (const char *name) const
 
Result get_parameter_types (const char *const *names, ::size_t count, ParameterType *out) const
 
Result get_publisher_names_and_types_by_node (const char *node_name, const char *node_namespace, nros_cpp_names_and_types_visit_fn visit, void *ctx) const
 
Result get_publishers_info_by_topic (const char *topic_name, ::rclcpp::TopicEndpointInfoVisitFn visit, void *ctx) const
 
Result get_publishers_info_by_topic (const char *topic_name, nros_cpp_endpoint_info_visit_fn visit, void *ctx) const
 
Result get_service_names_and_types (nros_cpp_names_and_types_visit_fn visit, void *ctx) const
 
Result get_service_names_and_types_by_node (const char *node_name, const char *node_namespace, nros_cpp_names_and_types_visit_fn visit, void *ctx) const
 
Result get_subscription_names_and_types_by_node (const char *node_name, const char *node_namespace, nros_cpp_names_and_types_visit_fn visit, void *ctx) const
 
Result get_subscriptions_info_by_topic (const char *topic_name, ::rclcpp::TopicEndpointInfoVisitFn visit, void *ctx) const
 
Result get_subscriptions_info_by_topic (const char *topic_name, nros_cpp_endpoint_info_visit_fn visit, void *ctx) const
 
Result get_topic_names_and_types (nros_cpp_names_and_types_visit_fn visit, void *ctx) const
 
bool has_parameter (const char *name) const
 rclcpp::Node::has_parameter(name).
 
Result init (const char *name, const char *ns=nullptr)
 
Result init_on (void *executor_handle, const char *name, const char *ns=nullptr)
 
bool initialized () const
 
bool is_valid () const
 Check if the node is initialized and valid.
 
Result list_parameters (const char *prefix, char *out_names, ::size_t name_stride, ::size_t max_names, ::size_t &count) const
 
 Node ()
 
 Node (::rclcpp::NodeHandle handle, const char *name, const char *ns=nullptr)
 
 Node (const char *name, const ::rclcpp::NodeOptions &options)
 
 Node (const char *name, const char *ns, const ::rclcpp::NodeOptions &options)
 
 Node (const char *name, const char *ns=nullptr)
 
 Node (Node &&other)
 
Time now () const
 
Node & nros_node ()
 
const Node & nros_node () const
 Const overload of [nros_node].
 
bool ok () const
 
Node & operator= (Node &&other)
 
Result remove_on_set_parameters_callback (ParameterCallbackHandle handle)
 rclcpp::Node::remove_on_set_parameters_callback(handle).
 
const char * serialization_format () const
 
void set_error (const char *what, int32_t code)
 
template<typename T >
Result set_parameter (const char *name, T value)
 
Result set_parameters_atomically (const ParameterWrite *writes, ::size_t count)
 
void set_qos_overrides (const nros_cpp_qos_override_t *overrides, size_t len)
 
SharedPtr shared_from_this ()
 
ConstSharedPtr shared_from_this () const
 Const overload of [shared_from_this].
 
Result start_parameter_services ()
 
Result undeclare_parameter (const char *name)
 
 ~Node ()
 

Additional Inherited Members

- Public Types inherited from rclcpp::Node
using ConstSharedPtr = ::rclcpp::Handle< const Node >
 rclcpp::Node::ConstSharedPtr.
 
using SharedPtr = ::rclcpp::Handle< Node >
 
- Static Public Member Functions inherited from rclcpp::Node
static Result create (Node &out, const char *name, const char *ns=nullptr)
 

Detailed Description

template<::size_t MaxTimers = 8>
class rclcpp::NodeWithTimers< MaxTimers >

Issue 1131 — the pool is a fixed inline C array, and zero is not a smaller one: Timer timers_[0] is not ISO C++ (GCC/Clang accept it only as the zero-length-array extension). A node that owns no timer does not derive this template at all, which is the real zero.

Below the #ifndef, never above it: an undefined identifier reads as 0 in #if, so a guard above its own default fires on every build (issue 1167). A Node plus an inline pool of MaxTimers rclcpp::Timer slots.

rclcpp::Timer's destructor cancels its timer, so a timer created in a constructor must outlive the call. The out-ref create_wall_timer(Timer&, …) / create_timer_in_group(group, Timer&, …) family on Node makes that the caller's problem, which is the right default. This template is for the component shape, where the storage-free spelling is the ergonomic one:

class Talker : public rclcpp::NodeWithTimers<1> {
public:
explicit Talker(rclcpp::NodeHandle h) : rclcpp::NodeWithTimers<1>(h, "talker") {
pub_ = create_publisher_in<Int32>("/chatter");
}
void on_tick();
};
Definition client.hpp:129
Definition node.hpp:2695
Definition rclcpp.hpp:75
Definition node.hpp:259

Member Function Documentation

◆ create_timer_in_group() [1/2]

template<::size_t MaxTimers = 8>
template<class C , void(C::*)() Method>
void rclcpp::NodeWithTimers< MaxTimers >::create_timer_in_group ( const CallbackGroup &  group,
uint64_t  period_ms 
)
inline

A typed member repeating timer in a callback group (RFC-0047), parked in the pool. Was ComponentNode::create_timer_in<C, Method>.

◆ create_timer_in_group() [2/2]

template<::size_t MaxTimers = 8>
void rclcpp::NodeWithTimers< MaxTimers >::create_timer_in_group ( const CallbackGroup &  group,
uint64_t  period_ms,
nros_cpp_timer_callback_t  callback,
void *  context = nullptr 
)
inline

The plain C callback + ctx form, in a group, parked in the pool.

◆ create_wall_timer_in() [1/2]

template<::size_t MaxTimers = 8>
template<class C , void(C::*)() Method>
void rclcpp::NodeWithTimers< MaxTimers >::create_wall_timer_in ( uint64_t  period_ms)
inline

Create a typed member repeating wall timer parked in the pool.

Was ComponentNode::create_wall_timer<C, Method>(period_ms); _in because upstream's create_wall_timer(duration, callback) is a different shape on the same type and a signature-only difference is resolved silently. Latches ok()=false on failure or pool exhaustion.

◆ create_wall_timer_in() [2/2]

template<::size_t MaxTimers = 8>
void rclcpp::NodeWithTimers< MaxTimers >::create_wall_timer_in ( uint64_t  period_ms,
nros_cpp_timer_callback_t  callback,
void *  context = nullptr 
)
inline

The plain C callback + ctx escape hatch, parked in the pool.


The documentation for this class was generated from the following file: