ros2订阅esp32发布的电池电压数据


电池电压数据能订阅但是不显示,数据QoS不匹配,需要修改。

默认:

需要使用的是外部机器人通过wifi传递的数据,设置:

  // create publisherRCCHECK(rclc_publisher_init_best_effort(&publisher,&node,ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Float32),"robot_battery"));

best_effort,一般而言,ros2默认为reliable。

修改对应ros2的订阅节点:

#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/float32.hpp"std::shared_ptr<rclcpp::Node> node = nullptr;void TopicCallback(const std_msgs::msg::Float32::SharedPtr msg)
{RCLCPP_INFO(node->get_logger(), "Robot battery voltage : '%f'", msg->data);
}int main(int argc, char *argv[])
{rclcpp::init(argc, argv);node = std::make_shared<rclcpp::Node>("battery_sub");auto sub = node->create_subscription<std_msgs::msg::Float32>("/robot_battery", rclcpp::SensorDataQoS(), TopicCallback);rclcpp::spin(node);rclcpp::shutdown();return 0;
}

其中:

auto sub = node->create_subscription<std_msgs::msg::Float32>("/robot_battery", rclcpp::SensorDataQoS(), TopicCallback);


这样,一个由CoCube发布到ROS2,并实现订阅的功能就实现了。


效果如下:


可以在上位机监测每一个机器人的电量状态。降低机器人程序复杂度。


rclcpp  master
C++ ROS Client Library API
rclcpp Namespace Reference
This header provides the get_node_base_interface() template function. More...

Namespaces
     allocator
 
     callback_group
 
     contexts
 
     detail
 
     exceptions
 
     executor
 
     executors
 
     experimental
 
     function_traits
 
     graph_listener
 
     memory_strategies
 
     memory_strategy
 
     message_memory_strategy
 
     node_interfaces
 
     serialization_traits
 
     strategies
 
     subscription_traits
 
     topic_statistics
 
     type_support
 
     wait_set_policies
 
Classes
struct      AnyExecutable
 
class      AnyServiceCallback
 
class      AnySubscriptionCallback
 
class      AsyncParametersClient
 
class      CallbackGroup
 
class      Client
 
class      ClientBase
 
class      Clock
 
class      Context
     Context which encapsulates shared state between nodes and other similar entities. More...
 
class      ContextAlreadyInitialized
     Thrown when init is called on an already initialized context. More...
 
class      Duration
 
class      Event
 
class      Executor
     Coordinate the order and timing of available communication tasks. More...
 
struct      ExecutorOptions
     Options to be passed to the executor constructor. More...
 
class      GenericRate
 
class      GenericTimer
     Generic timer. Periodically executes a user-specified callback. More...
 
class      GuardCondition
     A condition that can be waited on in a single wait set and asynchronously triggered. More...
 
class      InitOptions
     Encapsulation of options for initializing rclcpp. More...
 
class      JumpHandler
 
struct      KeepAll
     Use to initialize the QoS with the keep_all history setting. More...
 
struct      KeepLast
     Use to initialize the QoS with the keep_last history setting and the given depth. More...
 
class      LoanedMessage
 
class      Logger
 
class      MessageInfo
     Additional meta data about messages taken from subscriptions. More...
 
class      Node
     Node is the single point of entry for creating publishers and subscribers. More...
 
class      NodeOptions
     Encapsulation of options for node initialization. More...
 
class      Parameter
     Structure to store an arbitrary parameter with templated get/set methods. More...
 
class      ParameterEventsFilter
 
class      ParameterEventsQoS
 
class      ParameterService
 
class      ParametersQoS
 
class      ParameterTypeException
     Indicate the parameter type does not match the expected type. More...
 
class      ParameterValue
     Store the type and value of a parameter. More...
 
class      Publisher
     A publisher publishes messages of any type to a topic. More...
 
class      PublisherBase
 
struct      PublisherEventCallbacks
     Contains callbacks for various types of events a Publisher can receive from the middleware. More...
 
struct      PublisherFactory
     Factory with functions used to create a MessageT specific PublisherT. More...
 
struct      PublisherOptionsBase
     Non-templated part of PublisherOptionsWithAllocator<Allocator>. More...
 
struct      PublisherOptionsWithAllocator
     Structure containing optional configuration for Publishers. More...
 
class      QoS
     Encapsulation of Quality of Service settings. More...
 
class      QOSEventHandler
 
class      QOSEventHandlerBase
 
struct      QoSInitialization
     QoS initialization values, cannot be created directly, use KeepAll or KeepLast instead. More...
 
class      RateBase
 
struct      ScopeExit
 
class      SensorDataQoS
 
class      Serialization
     Default implementation to (de)serialize a message by using rmw_(de)serialize. More...
 
class      SerializationBase
     Interface to (de)serialize a message. More...
 
class      SerializedMessage
     Object oriented version of rcl_serialized_message_t with destructor to avoid memory leaks. More...
 
class      Service
 
class      ServiceBase
 
class      ServicesQoS
 
class      Subscription
     Subscription implementation, templated on the type of message this subscription receives. More...
 
class      SubscriptionBase
 
struct      SubscriptionEventCallbacks
     Contains callbacks for non-message events that a Subscription can receive from the middleware. More...
 
struct      SubscriptionFactory
     Factory containing a function used to create a Subscription<MessageT>. More...
 
struct      SubscriptionOptionsBase
     Non-template base class for subscription options. More...
 
struct      SubscriptionOptionsWithAllocator
     Structure containing optional configuration for Subscriptions. More...
 
class      SubscriptionWaitSetMask
     Options used to determine what parts of a subscription get added to or removed from a wait set. More...
 
class      SyncParametersClient
 
class      SystemDefaultsQoS
 
class      Time
 
class      TimerBase
 
class      TimeSource
 
class      TopicEndpointInfo
 
class      UnsupportedEventTypeException
 
class      Waitable
 
class      WaitResult
     Interface for introspecting a wait set after waiting on it. More...
 
class      WaitSetTemplate
     Encapsulates sets of waitable items which can be waited on as a group. More...
 
class      WallTimer
 
Typedefs
using     ParameterMap = std::unordered_map< std::string, std::vector< Parameter > >
     A map of fully qualified node names to a list of parameters. More...
 
using     PublisherOptions = PublisherOptionsWithAllocator< std::allocator< void > >
 
using     QOSDeadlineRequestedInfo = rmw_requested_deadline_missed_status_t
 
using     QOSDeadlineOfferedInfo = rmw_offered_deadline_missed_status_t
 
using     QOSLivelinessChangedInfo = rmw_liveliness_changed_status_t
 
using     QOSLivelinessLostInfo = rmw_liveliness_lost_status_t
 
using     QOSOfferedIncompatibleQoSInfo = rmw_offered_qos_incompatible_event_status_t
 
using     QOSRequestedIncompatibleQoSInfo = rmw_requested_qos_incompatible_event_status_t
 
using     QOSDeadlineRequestedCallbackType = std::function< void(QOSDeadlineRequestedInfo &)>
 
using     QOSDeadlineOfferedCallbackType = std::function< void(QOSDeadlineOfferedInfo &)>
 
using     QOSLivelinessChangedCallbackType = std::function< void(QOSLivelinessChangedInfo &)>
 
using     QOSLivelinessLostCallbackType = std::function< void(QOSLivelinessLostInfo &)>
 
using     QOSOfferedIncompatibleQoSCallbackType = std::function< void(QOSOfferedIncompatibleQoSInfo &)>
 
using     QOSRequestedIncompatibleQoSCallbackType = std::function< void(QOSRequestedIncompatibleQoSInfo &)>
 
using     Rate = GenericRate< std::chrono::system_clock >
 
using     WallRate = GenericRate< std::chrono::steady_clock >
 
using     SubscriptionOptions = SubscriptionOptionsWithAllocator< std::allocator< void > >
 
using     VoidCallbackType = std::function< void()>
 
using     TimerCallbackType = std::function< void(TimerBase &)>
 
using     WaitSet = rclcpp::WaitSetTemplate< rclcpp::wait_set_policies::SequentialSynchronization, rclcpp::wait_set_policies::DynamicStorage >
     Most common user configuration of a WaitSet, which is dynamic but not thread-safe. More...
 
template<std::size_t NumberOfSubscriptions, std::size_t NumberOfGuardCondtions, std::size_t NumberOfTimers, std::size_t NumberOfClients, std::size_t NumberOfServices, std::size_t NumberOfWaitables>
using     StaticWaitSet = rclcpp::WaitSetTemplate< rclcpp::wait_set_policies::SequentialSynchronization, rclcpp::wait_set_policies::StaticStorage< NumberOfSubscriptions, NumberOfGuardCondtions, NumberOfTimers, NumberOfClients, NumberOfServices, NumberOfWaitables > >
     WaitSet configuration which does not allow changes after construction. More...
 
using     ThreadSafeWaitSet = rclcpp::WaitSetTemplate< rclcpp::wait_set_policies::ThreadSafeSynchronization, rclcpp::wait_set_policies::DynamicStorage >
     Like WaitSet, this configuration is dynamic, but is also thread-safe. More...
 
Enumerations
enum      CallbackGroupType { CallbackGroupType::MutuallyExclusive, CallbackGroupType::Reentrant }
 
enum      FutureReturnCode { FutureReturnCode::SUCCESS, FutureReturnCode::INTERRUPTED, FutureReturnCode::TIMEOUT }
     Return codes to be used with spin_until_future_complete. More...
 
enum      IntraProcessBufferType { IntraProcessBufferType::SharedPtr, IntraProcessBufferType::UniquePtr, IntraProcessBufferType::CallbackDefault }
 
enum      IntraProcessSetting { IntraProcessSetting::Enable, IntraProcessSetting::Disable, IntraProcessSetting::NodeDefault }
     Used as argument in create_publisher and create_subscriber. More...
 
enum      EndpointType { EndpointType::Invalid = RMW_ENDPOINT_INVALID, EndpointType::Publisher = RMW_ENDPOINT_PUBLISHER, EndpointType::Subscription = RMW_ENDPOINT_SUBSCRIPTION }
 
enum      ParameterType : uint8_t {
  PARAMETER_NOT_SET = rcl_interfaces::msg::ParameterType::PARAMETER_NOT_SET, PARAMETER_BOOL = rcl_interfaces::msg::ParameterType::PARAMETER_BOOL, PARAMETER_INTEGER = rcl_interfaces::msg::ParameterType::PARAMETER_INTEGER, PARAMETER_DOUBLE = rcl_interfaces::msg::ParameterType::PARAMETER_DOUBLE,
  PARAMETER_STRING = rcl_interfaces::msg::ParameterType::PARAMETER_STRING, PARAMETER_BYTE_ARRAY = rcl_interfaces::msg::ParameterType::PARAMETER_BYTE_ARRAY, PARAMETER_BOOL_ARRAY = rcl_interfaces::msg::ParameterType::PARAMETER_BOOL_ARRAY, PARAMETER_INTEGER_ARRAY = rcl_interfaces::msg::ParameterType::PARAMETER_INTEGER_ARRAY,
  PARAMETER_DOUBLE_ARRAY = rcl_interfaces::msg::ParameterType::PARAMETER_DOUBLE_ARRAY, PARAMETER_STRING_ARRAY = rcl_interfaces::msg::ParameterType::PARAMETER_STRING_ARRAY
}
 
enum      TopicStatisticsState { TopicStatisticsState::Enable, TopicStatisticsState::Disable, TopicStatisticsState::NodeDefault }
 
enum      WaitResultKind { Ready, Timeout, Empty }
     Represents the various kinds of results from waiting on a wait set. More...
 
Functions
std::vector< Context::SharedPtr >     get_contexts ()
     Return a copy of the list of context shared pointers. More...
 
template<typename ServiceT >
rclcpp::Client< ServiceT >::SharedPtr     create_client (std::shared_ptr< node_interfaces::NodeBaseInterface > node_base, std::shared_ptr< node_interfaces::NodeGraphInterface > node_graph, std::shared_ptr< node_interfaces::NodeServicesInterface > node_services, const std::string &service_name, const rmw_qos_profile_t &qos_profile, rclcpp::CallbackGroup::SharedPtr group)
 
template<typename MessageT , typename AllocatorT = std::allocator<void>, typename PublisherT = rclcpp::Publisher<MessageT, AllocatorT>, typename NodeT >
std::shared_ptr< PublisherT >     create_publisher (NodeT &node, const std::string &topic_name, const rclcpp::QoS &qos, const rclcpp::PublisherOptionsWithAllocator< AllocatorT > &options=(rclcpp::PublisherOptionsWithAllocator< AllocatorT >()))
     Create and return a publisher of the given MessageT type. More...
 
template<typename ServiceT , typename CallbackT >
rclcpp::Service< ServiceT >::SharedPtr     create_service (std::shared_ptr< node_interfaces::NodeBaseInterface > node_base, std::shared_ptr< node_interfaces::NodeServicesInterface > node_services, const std::string &service_name, CallbackT &&callback, const rmw_qos_profile_t &qos_profile, rclcpp::CallbackGroup::SharedPtr group)
 
template<typename MessageT , typename CallbackT , typename AllocatorT = std::allocator<void>, typename CallbackMessageT = typename rclcpp::subscription_traits::has_message_type<CallbackT>::type, typename SubscriptionT = rclcpp::Subscription<CallbackMessageT, AllocatorT>, typename MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy< CallbackMessageT, AllocatorT >, typename NodeT >
std::shared_ptr< SubscriptionT >     create_subscription (NodeT &&node, const std::string &topic_name, const rclcpp::QoS &qos, CallbackT &&callback, const rclcpp::SubscriptionOptionsWithAllocator< AllocatorT > &options=(rclcpp::SubscriptionOptionsWithAllocator< AllocatorT >()), typename MessageMemoryStrategyT::SharedPtr msg_mem_strat=(MessageMemoryStrategyT::create_default()))
     Create and return a subscription of the given MessageT type. More...
 
template<typename CallbackT >
rclcpp::TimerBase::SharedPtr     create_timer (std::shared_ptr< node_interfaces::NodeBaseInterface > node_base, std::shared_ptr< node_interfaces::NodeTimersInterface > node_timers, rclcpp::Clock::SharedPtr clock, rclcpp::Duration period, CallbackT &&callback, rclcpp::CallbackGroup::SharedPtr group=nullptr)
 
template<typename NodeT , typename CallbackT >
rclcpp::TimerBase::SharedPtr     create_timer (NodeT node, rclcpp::Clock::SharedPtr clock, rclcpp::Duration period, CallbackT &&callback, rclcpp::CallbackGroup::SharedPtr group=nullptr)
     Create a timer with a given clock. More...
 
template<typename DurationRepT , typename DurationT , typename CallbackT >
rclcpp::WallTimer< CallbackT >::SharedPtr     create_wall_timer (std::chrono::duration< DurationRepT, DurationT > period, CallbackT callback, rclcpp::CallbackGroup::SharedPtr group, node_interfaces::NodeBaseInterface *node_base, node_interfaces::NodeTimersInterface *node_timers)
     Convenience method to create a timer with node resources. More...
 
void     spin_some (rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr)
     Create a default single-threaded executor and execute any immediately available work. More...
 
void     spin_some (rclcpp::Node::SharedPtr node_ptr)
 
void     spin (rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr)
     Create a default single-threaded executor and spin the specified node. More...
 
void     spin (rclcpp::Node::SharedPtr node_ptr)
 
template<typename FutureT , typename TimeRepT = int64_t, typename TimeT = std::milli>
rclcpp::FutureReturnCode     spin_until_future_complete (rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, const std::shared_future< FutureT > &future, std::chrono::duration< TimeRepT, TimeT > timeout=std::chrono::duration< TimeRepT, TimeT >(-1))
 
template<typename NodeT = rclcpp::Node, typename FutureT , typename TimeRepT = int64_t, typename TimeT = std::milli>
rclcpp::FutureReturnCode     spin_until_future_complete (std::shared_ptr< NodeT > node_ptr, const std::shared_future< FutureT > &future, std::chrono::duration< TimeRepT, TimeT > timeout=std::chrono::duration< TimeRepT, TimeT >(-1))
 
std::string     expand_topic_or_service_name (const std::string &name, const std::string &node_name, const std::string &namespace_, bool is_service=false)
     Expand a topic or service name and throw if it is not valid. More...
 
std::ostream &     operator<< (std::ostream &os, const FutureReturnCode &future_return_code)
     Stream operator for FutureReturnCode. More...
 
std::string     to_string (const FutureReturnCode &future_return_code)
     String conversion function for FutureReturnCode. More...
 
Logger     get_logger (const std::string &name)
     Return a named logger. More...
 
Logger     get_node_logger (const rcl_node_t *node)
     Return a named logger using an rcl_node_t. More...
 
RCLCPP_LOCAL std::string     extend_name_with_sub_namespace (const std::string &name, const std::string &sub_namespace)
 
std::string     _to_json_dict_entry (const Parameter &param)
     Return a json encoded version of the parameter intended for a dict. More...
 
std::ostream &     operator<< (std::ostream &os, const rclcpp::Parameter &pv)
 
std::ostream &     operator<< (std::ostream &os, const std::vector< Parameter > &parameters)
 
ParameterMap     parameter_map_from (const rcl_params_t *const c_params)
 
ParameterValue     parameter_value_from (const rcl_variant_t *const c_value)
 
std::string     to_string (ParameterType type)
     Return the name of a parameter type. More...
 
std::ostream &     operator<< (std::ostream &os, ParameterType type)
 
std::string     to_string (const ParameterValue &type)
     Return the value of a parameter as a string. More...
 
template<typename MessageT , typename AllocatorT , typename PublisherT >
PublisherFactory     create_publisher_factory (const rclcpp::PublisherOptionsWithAllocator< AllocatorT > &options)
     Return a PublisherFactory with functions setup for creating a PublisherT<MessageT, AllocatorT>. More...
 
std::string     qos_policy_name_from_kind (rmw_qos_policy_kind_t policy_kind)
 
bool     operator== (const QoS &left, const QoS &right)
     Check if two QoS profiles are exactly equal in all policy values. More...
 
bool     operator!= (const QoS &left, const QoS &right)
 
template<typename Callable >
ScopeExit< Callable >     make_scope_exit (Callable callable)
 
template<typename MessageT , typename CallbackT , typename AllocatorT , typename CallbackMessageT = typename rclcpp::subscription_traits::has_message_type<CallbackT>::type, typename SubscriptionT = rclcpp::Subscription<CallbackMessageT, AllocatorT>, typename MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy< CallbackMessageT, AllocatorT >>
SubscriptionFactory     create_subscription_factory (CallbackT &&callback, const rclcpp::SubscriptionOptionsWithAllocator< AllocatorT > &options, typename MessageMemoryStrategyT::SharedPtr msg_mem_strat, std::shared_ptr< rclcpp::topic_statistics::SubscriptionTopicStatistics< CallbackMessageT >> subscription_topic_stats=nullptr)
     Return a SubscriptionFactory setup to create a SubscriptionT<MessageT, AllocatorT>. More...
 
Time     operator+ (const rclcpp::Duration &lhs, const rclcpp::Time &rhs)
 
void     init (int argc, char const *const argv[], const InitOptions &init_options=InitOptions())
     Initialize communications via the rmw implementation and set up a global signal handler. More...
 
bool     install_signal_handlers ()
     Install the global signal handler for rclcpp. More...
 
bool     signal_handlers_installed ()
     Return true if the signal handlers are installed, otherwise false. More...
 
bool     uninstall_signal_handlers ()
     Uninstall the global signal handler for rclcpp. More...
 
std::vector< std::string >     init_and_remove_ros_arguments (int argc, char const *const argv[], const InitOptions &init_options=InitOptions())
     Initialize communications via the rmw implementation and set up a global signal handler. More...
 
std::vector< std::string >     remove_ros_arguments (int argc, char const *const argv[])
     Remove ROS-specific arguments from argument vector. More...
 
bool     ok (rclcpp::Context::SharedPtr context=nullptr)
     Check rclcpp's status. More...
 
bool     is_initialized (rclcpp::Context::SharedPtr context=nullptr)
     Return true if init() has already been called for the given context. More...
 
bool     shutdown (rclcpp::Context::SharedPtr context=nullptr, const std::string &reason="user called rclcpp::shutdown()")
     Shutdown rclcpp context, invalidating it for derived entities. More...
 
void     on_shutdown (std::function< void()> callback, rclcpp::Context::SharedPtr context=nullptr)
     Register a function to be called when shutdown is called on the context. More...
 
bool     sleep_for (const std::chrono::nanoseconds &nanoseconds, rclcpp::Context::SharedPtr context=nullptr)
     Use the global condition variable to block for the specified amount of time. More...
 
template<typename T >
bool     add_will_overflow (const T x, const T y)
     Safely check if addition will overflow. More...
 
template<typename T >
bool     add_will_underflow (const T x, const T y)
     Safely check if addition will underflow. More...
 
template<typename T >
bool     sub_will_overflow (const T x, const T y)
     Safely check if subtraction will overflow. More...
 
template<typename T >
bool     sub_will_underflow (const T x, const T y)
     Safely check if subtraction will underflow. More...
 
const char *     get_c_string (const char *string_in)
     Return the given string. More...
 
const char *     get_c_string (const std::string &string_in)
     Return the C string from the given std::string. More...
 
Detailed Description
This header provides the get_node_base_interface() template function.

This header provides the get_node_waitables_interface() template function.

This header provides the get_node_topics_interface() template function.

This header provides the get_node_timers_interface() template function.

This header provides the get_node_time_source_interface() template function.

This header provides the get_node_services_interface() template function.

This header provides the get_node_parameters_interface() template function.

This header provides the get_node_logging_interface() template function.

This header provides the get_node_graph_interface() template function.

This header provides the get_node_clock_interface() template function.

This function is useful for getting the NodeBaseInterface pointer from various kinds of Node-like classes.

It's able to get a std::shared_ptr to a NodeBaseInterface so long as the class has a method called get_node_base_interface() which returns one.

This function is useful for getting the NodeClockInterface pointer from various kinds of Node-like classes.

It's able to get a std::shared_ptr to a NodeClockInterface so long as the class has a method called get_node_clock_interface() which returns one.

This function is useful for getting the NodeGraphInterface pointer from various kinds of Node-like classes.

It's able to get a std::shared_ptr to a NodeGraphInterface so long as the class has a method called get_node_graph_interface() which returns one.

This function is useful for getting the NodeLoggingInterface pointer from various kinds of Node-like classes.

It's able to get a std::shared_ptr to a NodeLoggingInterface so long as the class has a method called get_node_logging_interface() which returns one.

This function is useful for getting the NodeParametersInterface pointer from various kinds of Node-like classes.

It's able to get a std::shared_ptr to a NodeParametersInterface so long as the class has a method called get_node_parameters_interface() which returns one.

This function is useful for getting the NodeServicesInterface pointer from various kinds of Node-like classes.

It's able to get a std::shared_ptr to a NodeServicesInterface so long as the class has a method called get_node_services_interface() which returns one.

This function is useful for getting the NodeTimeSourceInterface pointer from various kinds of Node-like classes.

It's able to get a std::shared_ptr to a NodeTimeSourceInterface so long as the class has a method called get_node_time_source_interface() which returns one.

This function is useful for getting the NodeTimersInterface pointer from various kinds of Node-like classes.

It's able to get a std::shared_ptr to a NodeTimersInterface so long as the class has a method called get_node_timers_interface() which returns one.

This function is useful for getting the NodeTopicsInterface pointer from various kinds of Node-like classes.

It's able to get a std::shared_ptr to a NodeTopicsInterface so long as the class has a method called get_node_topics_interface() which returns one.

This function is useful for getting the NodeWaitablesInterface pointer from various kinds of Node-like classes.

It's able to get a std::shared_ptr to a NodeWaitablesInterface so long as the class has a method called get_node_waitables_interface() which returns one.

Typedef Documentation
◆ ParameterMap
using rclcpp::ParameterMap = typedef std::unordered_map<std::string, std::vector<Parameter> >
A map of fully qualified node names to a list of parameters.

◆ PublisherOptions
using rclcpp::PublisherOptions = typedef PublisherOptionsWithAllocator<std::allocator<void> >
◆ QOSDeadlineRequestedInfo
using rclcpp::QOSDeadlineRequestedInfo = typedef rmw_requested_deadline_missed_status_t
◆ QOSDeadlineOfferedInfo
using rclcpp::QOSDeadlineOfferedInfo = typedef rmw_offered_deadline_missed_status_t
◆ QOSLivelinessChangedInfo
using rclcpp::QOSLivelinessChangedInfo = typedef rmw_liveliness_changed_status_t
◆ QOSLivelinessLostInfo
using rclcpp::QOSLivelinessLostInfo = typedef rmw_liveliness_lost_status_t
◆ QOSOfferedIncompatibleQoSInfo
using rclcpp::QOSOfferedIncompatibleQoSInfo = typedef rmw_offered_qos_incompatible_event_status_t
◆ QOSRequestedIncompatibleQoSInfo
using rclcpp::QOSRequestedIncompatibleQoSInfo = typedef rmw_requested_qos_incompatible_event_status_t
◆ QOSDeadlineRequestedCallbackType
using rclcpp::QOSDeadlineRequestedCallbackType = typedef std::function<void (QOSDeadlineRequestedInfo &)>
◆ QOSDeadlineOfferedCallbackType
using rclcpp::QOSDeadlineOfferedCallbackType = typedef std::function<void (QOSDeadlineOfferedInfo &)>
◆ QOSLivelinessChangedCallbackType
using rclcpp::QOSLivelinessChangedCallbackType = typedef std::function<void (QOSLivelinessChangedInfo &)>
◆ QOSLivelinessLostCallbackType
using rclcpp::QOSLivelinessLostCallbackType = typedef std::function<void (QOSLivelinessLostInfo &)>
◆ QOSOfferedIncompatibleQoSCallbackType
using rclcpp::QOSOfferedIncompatibleQoSCallbackType = typedef std::function<void (QOSOfferedIncompatibleQoSInfo &)>
◆ QOSRequestedIncompatibleQoSCallbackType
using rclcpp::QOSRequestedIncompatibleQoSCallbackType = typedef std::function<void (QOSRequestedIncompatibleQoSInfo &)>
◆ Rate
using rclcpp::Rate = typedef GenericRate<std::chrono::system_clock>
◆ WallRate
using rclcpp::WallRate = typedef GenericRate<std::chrono::steady_clock>
◆ SubscriptionOptions
using rclcpp::SubscriptionOptions = typedef SubscriptionOptionsWithAllocator<std::allocator<void> >
◆ VoidCallbackType
using rclcpp::VoidCallbackType = typedef std::function<void ()>
◆ TimerCallbackType
using rclcpp::TimerCallbackType = typedef std::function<void (TimerBase &)>
◆ WaitSet
using rclcpp::WaitSet = typedef rclcpp::WaitSetTemplate< rclcpp::wait_set_policies::SequentialSynchronization, rclcpp::wait_set_policies::DynamicStorage >
Most common user configuration of a WaitSet, which is dynamic but not thread-safe.

This wait set allows you to add and remove items dynamically, and it will automatically remove items that are let out of scope each time wait() or prune_destroyed_entities() is called.

It will not, however, provide thread-safety for adding and removing entities while waiting.

See also
rclcpp::WaitSetTemplate for API documentation
◆ StaticWaitSet
template<std::size_t NumberOfSubscriptions, std::size_t NumberOfGuardCondtions, std::size_t NumberOfTimers, std::size_t NumberOfClients, std::size_t NumberOfServices, std::size_t NumberOfWaitables>
using rclcpp::StaticWaitSet = typedef rclcpp::WaitSetTemplate< rclcpp::wait_set_policies::SequentialSynchronization, rclcpp::wait_set_policies::StaticStorage< NumberOfSubscriptions, NumberOfGuardCondtions, NumberOfTimers, NumberOfClients, NumberOfServices, NumberOfWaitables > >
WaitSet configuration which does not allow changes after construction.

This wait set requires that you specify all entities at construction, and prevents you from calling the typical add and remove functions. It also requires that you specify how many of each item there will be as a template argument.

It will share ownership of the entities until destroyed, therefore it will prevent the destruction of entities so long as the wait set exists, even if the user lets their copy of the shared pointer to the entity go out of scope.

Since the wait set cannot be mutated, it does not need to be thread-safe.

See also
rclcpp::WaitSetTemplate for API documentation
◆ ThreadSafeWaitSet
using rclcpp::ThreadSafeWaitSet = typedef rclcpp::WaitSetTemplate< rclcpp::wait_set_policies::ThreadSafeSynchronization, rclcpp::wait_set_policies::DynamicStorage >
Like WaitSet, this configuration is dynamic, but is also thread-safe.

This wait set allows you to add and remove items dynamically, and it will automatically remove items that are let out of scope each time wait() or prune_destroyed_entities() is called.

It will also ensure that adding and removing items explicitly from the wait set is done in a thread-safe way, protecting against concurrent add and deletes, as well as add and deletes during a wait(). This thread-safety comes at some overhead and the use of thread synchronization primitives.

See also
rclcpp::WaitSetTemplate for API documentation
Enumeration Type Documentation
◆ CallbackGroupType
enum rclcpp::CallbackGroupType
strong
Enumerator
MutuallyExclusive     
Reentrant     
◆ FutureReturnCode
enum rclcpp::FutureReturnCode
strong
Return codes to be used with spin_until_future_complete.

SUCCESS: The future is complete and can be accessed with "get" without blocking. This does not indicate that the operation succeeded; "get" may still throw an exception. INTERRUPTED: The future is not complete, spinning was interrupted by Ctrl-C or another error. TIMEOUT: Spinning timed out.

Enumerator
SUCCESS     
INTERRUPTED     
TIMEOUT     
◆ IntraProcessBufferType
enum rclcpp::IntraProcessBufferType
strong
Used as argument in create_publisher and create_subscriber when intra-process communication is enabled

Enumerator
SharedPtr     
Set the data type used in the intra-process buffer as std::shared_ptr<MessageT>

UniquePtr     
Set the data type used in the intra-process buffer as std::unique_ptr<MessageT>

CallbackDefault     
Set the data type used in the intra-process buffer as the same used in the callback.

◆ IntraProcessSetting
enum rclcpp::IntraProcessSetting
strong
Used as argument in create_publisher and create_subscriber.

Enumerator
Enable     
Explicitly enable intraprocess comm at publisher/subscription level.

Disable     
Explicitly disable intraprocess comm at publisher/subscription level.

NodeDefault     
Take intraprocess configuration from the node.

◆ EndpointType
enum rclcpp::EndpointType
strong
Enumerator
Invalid     
Publisher     
Subscription     
◆ ParameterType
enum rclcpp::ParameterType : uint8_t
Enumerator
PARAMETER_NOT_SET     
PARAMETER_BOOL     
PARAMETER_INTEGER     
PARAMETER_DOUBLE     
PARAMETER_STRING     
PARAMETER_BYTE_ARRAY     
PARAMETER_BOOL_ARRAY     
PARAMETER_INTEGER_ARRAY     
PARAMETER_DOUBLE_ARRAY     
PARAMETER_STRING_ARRAY     
◆ TopicStatisticsState
enum rclcpp::TopicStatisticsState
strong
Represent the state of topic statistics collector. Used as argument in create_subscriber.

Enumerator
Enable     
Explicitly enable topic statistics at subscription level.

Disable     
Explicitly disable topic statistics at subscription level.

NodeDefault     
Take topic statistics state from the node.

◆ WaitResultKind
enum rclcpp::WaitResultKind
Represents the various kinds of results from waiting on a wait set.

Enumerator
Ready     
Timeout     
Empty     
Function Documentation
◆ get_contexts()
std::vector<Context::SharedPtr> rclcpp::get_contexts    (        )    
Return a copy of the list of context shared pointers.

This function is thread-safe.

◆ create_client()
template<typename ServiceT >
rclcpp::Client<ServiceT>::SharedPtr rclcpp::create_client    (    std::shared_ptr< node_interfaces::NodeBaseInterface >     node_base,
std::shared_ptr< node_interfaces::NodeGraphInterface >     node_graph,
std::shared_ptr< node_interfaces::NodeServicesInterface >     node_services,
const std::string &     service_name,
const rmw_qos_profile_t &     qos_profile,
rclcpp::CallbackGroup::SharedPtr     group 
)        
Create a service client with a given type.

◆ create_publisher()
template<typename MessageT , typename AllocatorT = std::allocator<void>, typename PublisherT = rclcpp::Publisher<MessageT, AllocatorT>, typename NodeT >
std::shared_ptr<PublisherT> rclcpp::create_publisher    (    NodeT &     node,
const std::string &     topic_name,
const rclcpp::QoS &     qos,
const rclcpp::PublisherOptionsWithAllocator< AllocatorT > &     options = (    rclcpp::PublisherOptionsWithAllocator<AllocatorT>()  ) 
)        
Create and return a publisher of the given MessageT type.

The NodeT type only needs to have a method called get_node_topics_interface() which returns a shared_ptr to a NodeTopicsInterface.

◆ create_service()
template<typename ServiceT , typename CallbackT >
rclcpp::Service<ServiceT>::SharedPtr rclcpp::create_service    (    std::shared_ptr< node_interfaces::NodeBaseInterface >     node_base,
std::shared_ptr< node_interfaces::NodeServicesInterface >     node_services,
const std::string &     service_name,
CallbackT &&     callback,
const rmw_qos_profile_t &     qos_profile,
rclcpp::CallbackGroup::SharedPtr     group 
)        
Create a service with a given type.

◆ create_subscription()
template<typename MessageT , typename CallbackT , typename AllocatorT = std::allocator<void>, typename CallbackMessageT = typename rclcpp::subscription_traits::has_message_type<CallbackT>::type, typename SubscriptionT = rclcpp::Subscription<CallbackMessageT, AllocatorT>, typename MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy< CallbackMessageT, AllocatorT >, typename NodeT >
std::shared_ptr<SubscriptionT> rclcpp::create_subscription    (    NodeT &&     node,
const std::string &     topic_name,
const rclcpp::QoS &     qos,
CallbackT &&     callback,
const rclcpp::SubscriptionOptionsWithAllocator< AllocatorT > &     options = (    rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>()  ),
typename MessageMemoryStrategyT::SharedPtr     msg_mem_strat = (    MessageMemoryStrategyT::create_default()  ) 
)        
Create and return a subscription of the given MessageT type.

The NodeT type only needs to have a method called get_node_topics_interface() which returns a shared_ptr to a NodeTopicsInterface, or be a NodeTopicsInterface pointer itself.

Template Parameters
MessageT    
CallbackT    
AllocatorT    
CallbackMessageT    
SubscriptionT    
MessageMemoryStrategyT    
NodeT    
Parameters
node    
topic_name    
qos    
callback    
options    
msg_mem_strat    
Returns
the created subscription
Exceptions
std::invalid_argument    if topic statistics is enabled and the publish period is less than or equal to zero.
◆ create_timer() [1/2]
template<typename CallbackT >
rclcpp::TimerBase::SharedPtr rclcpp::create_timer    (    std::shared_ptr< node_interfaces::NodeBaseInterface >     node_base,
std::shared_ptr< node_interfaces::NodeTimersInterface >     node_timers,
rclcpp::Clock::SharedPtr     clock,
rclcpp::Duration     period,
CallbackT &&     callback,
rclcpp::CallbackGroup::SharedPtr     group = nullptr 
)        
Create a timer with a given clock

◆ create_timer() [2/2]
template<typename NodeT , typename CallbackT >
rclcpp::TimerBase::SharedPtr rclcpp::create_timer    (    NodeT     node,
rclcpp::Clock::SharedPtr     clock,
rclcpp::Duration     period,
CallbackT &&     callback,
rclcpp::CallbackGroup::SharedPtr     group = nullptr 
)        
Create a timer with a given clock.

◆ create_wall_timer()
template<typename DurationRepT , typename DurationT , typename CallbackT >
rclcpp::WallTimer<CallbackT>::SharedPtr rclcpp::create_wall_timer    (    std::chrono::duration< DurationRepT, DurationT >     period,
CallbackT     callback,
rclcpp::CallbackGroup::SharedPtr     group,
node_interfaces::NodeBaseInterface *     node_base,
node_interfaces::NodeTimersInterface *     node_timers 
)        
Convenience method to create a timer with node resources.

Template Parameters
DurationRepT    
DurationT    
CallbackT    
Parameters
period    period to exectute callback
callback    callback to execute via the timer period
group    
node_base    
node_timers    
Returns
Exceptions
std::invalid    argument if either node_base or node_timers are null
◆ spin_some() [1/2]
void rclcpp::spin_some    (    rclcpp::node_interfaces::NodeBaseInterface::SharedPtr     node_ptr    )    
Create a default single-threaded executor and execute any immediately available work.

Parameters
[in]    node_ptr    Shared pointer to the node to spin.
◆ spin_some() [2/2]
void rclcpp::spin_some    (    rclcpp::Node::SharedPtr     node_ptr    )    
◆ spin() [1/2]
void rclcpp::spin    (    rclcpp::node_interfaces::NodeBaseInterface::SharedPtr     node_ptr    )    
Create a default single-threaded executor and spin the specified node.

Parameters
[in]    node_ptr    Shared pointer to the node to spin.
◆ spin() [2/2]
void rclcpp::spin    (    rclcpp::Node::SharedPtr     node_ptr    )    
◆ spin_until_future_complete() [1/2]
template<typename FutureT , typename TimeRepT = int64_t, typename TimeT = std::milli>
rclcpp::FutureReturnCode rclcpp::spin_until_future_complete    (    rclcpp::node_interfaces::NodeBaseInterface::SharedPtr     node_ptr,
const std::shared_future< FutureT > &     future,
std::chrono::duration< TimeRepT, TimeT >     timeout = std::chrono::duration<TimeRepT, TimeT>(-1) 
)        
◆ spin_until_future_complete() [2/2]
template<typename NodeT = rclcpp::Node, typename FutureT , typename TimeRepT = int64_t, typename TimeT = std::milli>
rclcpp::FutureReturnCode rclcpp::spin_until_future_complete    (    std::shared_ptr< NodeT >     node_ptr,
const std::shared_future< FutureT > &     future,
std::chrono::duration< TimeRepT, TimeT >     timeout = std::chrono::duration<TimeRepT, TimeT>(-1) 
)        
◆ expand_topic_or_service_name()
std::string rclcpp::expand_topic_or_service_name    (    const std::string &     name,
const std::string &     node_name,
const std::string &     namespace_,
bool     is_service = false 
)        
Expand a topic or service name and throw if it is not valid.

This function can be used to "just" validate a topic or service name too, since expanding the topic name is required to fully validate a name.

If the name is invalid, then InvalidTopicNameError is thrown or InvalidServiceNameError if is_service is true.

This function can take any form of a topic or service name, i.e. it does not have to be a fully qualified name. The node name and namespace are used to expand it if necessary while validating it.

Expansion is done with rcl_expand_topic_name. The validation is doen with rcl_validate_topic_name and rmw_validate_full_topic_name, so details about failures can be found in the documentation for those functions.

Parameters
name    the topic or service name to be validated
node_name    the name of the node associated with the name
namespace_    the namespace of the node associated with the name
is_service    if true InvalidServiceNameError is thrown instead
Returns
expanded (and validated) topic name
Exceptions
InvalidTopicNameError    if name is invalid and is_service is false
InvalidServiceNameError    if name is invalid and is_service is true
std::bad_alloc    if memory cannot be allocated
RCLError    if an unexpect error occurs
std::runtime_error    if the topic name is unexpectedly valid or, if the rcl name is invalid or if the rcl namespace is invalid
◆ operator<<() [1/4]
std::ostream& rclcpp::operator<<    (    std::ostream &     os,
const FutureReturnCode &     future_return_code 
)        
Stream operator for FutureReturnCode.

◆ to_string() [1/3]
std::string rclcpp::to_string    (    const FutureReturnCode &     future_return_code    )    
inline
String conversion function for FutureReturnCode.

◆ get_logger()
Logger rclcpp::get_logger    (    const std::string &     name    )    
Return a named logger.

The returned logger's name will include any naming conventions, such as a name prefix. Currently there are no such naming conventions but they may be introduced in the future.

Parameters
[in]    name    the name of the logger
Returns
a logger with the fully-qualified name including naming conventions, or
a dummy logger if logging is disabled.
◆ get_node_logger()
Logger rclcpp::get_node_logger    (    const rcl_node_t *     node    )    
Return a named logger using an rcl_node_t.

This is a convenience function that does error checking and returns the node logger name, or "rclcpp" if it is unable to get the node name.

Parameters
[in]    node    the rcl node from which to get the logger name
Returns
a logger based on the node name, or "rclcpp" if there's an error
◆ extend_name_with_sub_namespace()
RCLCPP_LOCAL std::string rclcpp::extend_name_with_sub_namespace    (    const std::string &     name,
const std::string &     sub_namespace 
)        
inline
◆ _to_json_dict_entry()
std::string rclcpp::_to_json_dict_entry    (    const Parameter &     param    )    
Return a json encoded version of the parameter intended for a dict.

◆ operator<<() [2/4]
std::ostream& rclcpp::operator<<    (    std::ostream &     os,
const rclcpp::Parameter &     pv 
)        
◆ operator<<() [3/4]
std::ostream& rclcpp::operator<<    (    std::ostream &     os,
const std::vector< Parameter > &     parameters 
)        
◆ parameter_map_from()
ParameterMap rclcpp::parameter_map_from    (    const rcl_params_t *const     c_params    )    
Convert parameters from rcl_yaml_param_parser into C++ class instances.

Parameters
[in]    c_params    C structures containing parameters for multiple nodes.
Returns
a map where the keys are fully qualified node names and values a list of parameters.
Exceptions
InvalidParametersException    if the rcl_params_t is inconsistent or invalid.
◆ parameter_value_from()
ParameterValue rclcpp::parameter_value_from    (    const rcl_variant_t *const     c_value    )    
Convert parameter value from rcl_yaml_param_parser into a C++ class instance.

Parameters
[in]    c_value    C structure containing a value of a parameter.
Returns
an instance of a parameter value
Exceptions
InvalidParameterValueException    if the rcl_variant_t is inconsistent or invalid.
◆ to_string() [2/3]
std::string rclcpp::to_string    (    ParameterType     type    )    
Return the name of a parameter type.

◆ operator<<() [4/4]
std::ostream& rclcpp::operator<<    (    std::ostream &     os,
ParameterType     type 
)        
◆ to_string() [3/3]
std::string rclcpp::to_string    (    const ParameterValue &     type    )    
Return the value of a parameter as a string.

◆ create_publisher_factory()
template<typename MessageT , typename AllocatorT , typename PublisherT >
PublisherFactory rclcpp::create_publisher_factory    (    const rclcpp::PublisherOptionsWithAllocator< AllocatorT > &     options    )    
Return a PublisherFactory with functions setup for creating a PublisherT<MessageT, AllocatorT>.

◆ qos_policy_name_from_kind()
std::string rclcpp::qos_policy_name_from_kind    (    rmw_qos_policy_kind_t     policy_kind    )    
◆ operator==()
bool rclcpp::operator==    (    const QoS &     left,
const QoS &     right 
)        
Check if two QoS profiles are exactly equal in all policy values.

◆ operator!=()
bool rclcpp::operator!=    (    const QoS &     left,
const QoS &     right 
)        
◆ make_scope_exit()
template<typename Callable >
ScopeExit<Callable> rclcpp::make_scope_exit    (    Callable     callable    )    
◆ create_subscription_factory()
template<typename MessageT , typename CallbackT , typename AllocatorT , typename CallbackMessageT = typename rclcpp::subscription_traits::has_message_type<CallbackT>::type, typename SubscriptionT = rclcpp::Subscription<CallbackMessageT, AllocatorT>, typename MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy< CallbackMessageT, AllocatorT >>
SubscriptionFactory rclcpp::create_subscription_factory    (    CallbackT &&     callback,
const rclcpp::SubscriptionOptionsWithAllocator< AllocatorT > &     options,
typename MessageMemoryStrategyT::SharedPtr     msg_mem_strat,
std::shared_ptr< rclcpp::topic_statistics::SubscriptionTopicStatistics< CallbackMessageT >>     subscription_topic_stats = nullptr 
)        
Return a SubscriptionFactory setup to create a SubscriptionT<MessageT, AllocatorT>.

Parameters
[in]    callback    The user-defined callback function to receive a message
[in]    options    Additional options for the creation of the Subscription.
[in]    msg_mem_strat    The message memory strategy to use for allocating messages.
[in]    subscription_topic_stats    Optional stats callback for topic_statistics
◆ operator+()
Time rclcpp::operator+    (    const rclcpp::Duration &     lhs,
const rclcpp::Time &     rhs 
)        
Exceptions
std::overflow_error    if addition leads to overflow
◆ init()
void rclcpp::init    (    int     argc,
char const *const     argv[],
const InitOptions &     init_options = InitOptions() 
)        
Initialize communications via the rmw implementation and set up a global signal handler.

Initializes the global context which is accessible via the function rclcpp::contexts::get_global_default_context(). Also, installs the global signal handlers with the function rclcpp::install_signal_handlers().

See also
rclcpp::Context::init() for more details on arguments and possible exceptions
◆ install_signal_handlers()
bool rclcpp::install_signal_handlers    (        )    
Install the global signal handler for rclcpp.

This function should only need to be run one time per process. It is implicitly run by rclcpp::init(), and therefore this function does not need to be run manually if rclcpp::init() has already been run.

The signal handler will shutdown all initialized context. It will also interrupt any blocking functions in ROS allowing them react to any changes in the state of the system (like shutdown).

This function is thread-safe.

Returns
true if signal handler was installed by this function, false if already installed.
◆ signal_handlers_installed()
bool rclcpp::signal_handlers_installed    (        )    
Return true if the signal handlers are installed, otherwise false.

◆ uninstall_signal_handlers()
bool rclcpp::uninstall_signal_handlers    (        )    
Uninstall the global signal handler for rclcpp.

This function does not necessarily need to be called, but can be used to undo what rclcpp::install_signal_handlers() or rclcpp::init() do with respect to signal handling. If you choose to use it, this function only needs to be run one time. It is implicitly run by rclcpp::shutdown(), and therefore this function does not need to be run manually if rclcpp::shutdown() has already been run.

This function is thread-safe.

Returns
true if signal handler was uninstalled by this function, false if was not installed.
◆ init_and_remove_ros_arguments()
std::vector<std::string> rclcpp::init_and_remove_ros_arguments    (    int     argc,
char const *const     argv[],
const InitOptions &     init_options = InitOptions() 
)        
Initialize communications via the rmw implementation and set up a global signal handler.

Additionally removes ROS-specific arguments from the argument vector.

See also
rclcpp::Context::init() for more details on arguments and possible exceptions
Returns
Members of the argument vector that are not ROS arguments.
Exceptions
anything    remove_ros_arguments can throw
◆ remove_ros_arguments()
std::vector<std::string> rclcpp::remove_ros_arguments    (    int     argc,
char const *const     argv[] 
)        
Remove ROS-specific arguments from argument vector.

Some arguments may not have been intended as ROS arguments. This function populates the arguments in a vector. Since the first argument is always assumed to be a process name, the vector will always contain the process name.

Parameters
[in]    argc    Number of arguments.
[in]    argv    Argument vector.
Returns
Members of the argument vector that are not ROS arguments.
Exceptions
anything    throw_from_rcl_error can throw
rclcpp::exceptions::RCLError    if the parsing fails
◆ ok()
bool rclcpp::ok    (    rclcpp::Context::SharedPtr     context = nullptr    )    
Check rclcpp's status.

This may return false for a context which has been shutdown, or for a context that was shutdown due to SIGINT being received by the rclcpp signal handler.

If nullptr is given for the context, then the global context is used, i.e. the context initialized by rclcpp::init().

Parameters
[in]    context    Optional check for shutdown of this Context.
Returns
true if shutdown has been called, false otherwise
◆ is_initialized()
bool rclcpp::is_initialized    (    rclcpp::Context::SharedPtr     context = nullptr    )    
Return true if init() has already been called for the given context.

If nullptr is given for the context, then the global context is used, i.e. the context initialized by rclcpp::init().

Deprecated, as it is no longer different from rcl_ok().

Parameters
[in]    context    Optional check for initialization of this Context.
Returns
true if the context is initialized, and false otherwise
◆ shutdown()
bool rclcpp::shutdown    (    rclcpp::Context::SharedPtr     context = nullptr,
const std::string &     reason = "user called rclcpp::shutdown()" 
)        
Shutdown rclcpp context, invalidating it for derived entities.

If nullptr is given for the context, then the global context is used, i.e. the context initialized by rclcpp::init().

If the global context is used, then the signal handlers are also uninstalled.

This will also cause the "on_shutdown" callbacks to be called.

See also
rclcpp::Context::shutdown()
Parameters
[in]    context    Optional to be shutdown
[in]    reason    Optional string passed to the context shutdown method
Returns
true if shutdown was successful, false if context was already shutdown
◆ on_shutdown()
void rclcpp::on_shutdown    (    std::function< void()>     callback,
rclcpp::Context::SharedPtr     context = nullptr 
)        
Register a function to be called when shutdown is called on the context.

If nullptr is given for the context, then the global context is used, i.e. the context initialized by rclcpp::init().

These callbacks are called when the associated Context is shutdown with the Context::shutdown() method. When shutdown by the SIGINT handler, shutdown, and therefore these callbacks, is called asynchronously from the dedicated signal handling thread, at some point after the SIGINT signal is received.

See also
rclcpp::Context::on_shutdown()
Parameters
[in]    callback    to be called when the given context is shutdown
[in]    context    with which to associate the context
◆ sleep_for()
bool rclcpp::sleep_for    (    const std::chrono::nanoseconds &     nanoseconds,
rclcpp::Context::SharedPtr     context = nullptr 
)        
Use the global condition variable to block for the specified amount of time.

This function can be interrupted early if the associated context becomes invalid due to shutdown() or the signal handler.

See also
rclcpp::Context::sleep_for
If nullptr is given for the context, then the global context is used, i.e. the context initialized by rclcpp::init().

Parameters
[in]    nanoseconds    A std::chrono::duration representing how long to sleep for.
[in]    context    Optional which may interrupt this sleep
Returns
true if the condition variable did not timeout.
◆ add_will_overflow()
template<typename T >
bool rclcpp::add_will_overflow    (    const T     x,
const T     y 
)        
Safely check if addition will overflow.

The type of the operands, T, should have defined std::numeric_limits<T>::max(), >, < and - operators.

Parameters
[in]    x    is the first addend.
[in]    y    is the second addend.
Template Parameters
T    is type of the operands.
Returns
True if the x + y sum is greater than T::max value.
◆ add_will_underflow()
template<typename T >
bool rclcpp::add_will_underflow    (    const T     x,
const T     y 
)        
Safely check if addition will underflow.

The type of the operands, T, should have defined std::numeric_limits<T>::min(), >, < and - operators.

Parameters
[in]    x    is the first addend.
[in]    y    is the second addend.
Template Parameters
T    is type of the operands.
Returns
True if the x + y sum is less than T::min value.
◆ sub_will_overflow()
template<typename T >
bool rclcpp::sub_will_overflow    (    const T     x,
const T     y 
)        
Safely check if subtraction will overflow.

The type of the operands, T, should have defined std::numeric_limits<T>::max(), >, < and + operators.

Parameters
[in]    x    is the minuend.
[in]    y    is the subtrahend.
Template Parameters
T    is type of the operands.
Returns
True if the difference x - y sum is grater than T::max value.
◆ sub_will_underflow()
template<typename T >
bool rclcpp::sub_will_underflow    (    const T     x,
const T     y 
)        
Safely check if subtraction will underflow.

The type of the operands, T, should have defined std::numeric_limits<T>::min(), >, < and + operators.

Parameters
[in]    x    is the minuend.
[in]    y    is the subtrahend.
Template Parameters
T    is type of the operands.
Returns
True if the difference x - y sum is less than T::min value.
◆ get_c_string() [1/2]
const char* rclcpp::get_c_string    (    const char *     string_in    )    
Return the given string.

This function is overloaded to transform any string to C-style string.

Parameters
[in]    string_in    is the string to be returned
Returns
the given string
◆ get_c_string() [2/2]
const char* rclcpp::get_c_string    (    const std::string &     string_in    )    
Return the C string from the given std::string.

Parameters
[in]    string_in    is a std::string
Returns
the C string from the std::string
Generated by   doxygen 1.8.17

ros2订阅esp32发布的电池电压数据-补充相关推荐

  1. ros先订阅后发布 无法收到消息的解决办法

    现象 今天遇到的问题是: 使用的是Ros1, 在先订阅后发布时, 会导致订阅者无法收到订阅的消息, 除非在发布者发布后重新订阅. 思考 以前使用的是Ros2似乎并不关心订阅和发布的先后顺序,  似乎都 ...

  2. ESP32的MQTT AT固件烧录+STM32以ESP32的MQTT AT固件的AT指令连接EMQX下mqtt服务器实现消息订阅和发布

    目录 写在前面 三种方案(利用ESP32连接EMQX下的MQTT) 步骤 ESP32烧录固件并AT指令进行测试. 下载固件 烧录工具下载 烧录固件(选择ESP32) 关于AT 指令与MQTT服务器断开 ...

  3. sqlserver2008基于发布/订阅功能实现主从数据库数据实时同步

    网上关于sqlserver基于发布/订阅实现数据同步的文章很多,大多介绍不详细,各种copy.为实现发布服务器.订阅服务器数据库实时同步,近期花了几天时间认真研究了一下,并实践验证通过,希望本文能帮助 ...

  4. Node-RED订阅MQTT主题并调试数据

    场景 Node-RED简介与Windows上安装.启动和运行示例: Node-RED简介与Windows上安装.启动和运行示例_BADAO_LIUMANG_QIZHI的博客-CSDN博客 根据上面将N ...

  5. Redis源码剖析(五)订阅与发布

    Redis提供了订阅和发布的功能,允许客户端订阅一个或多个频道,当其他客户端向某个频道发送消息时,服务器会将消息转发给所有订阅该频道的客户端 这一点有点像群聊的功能,一个客户端将消息发往群中(向某个频 ...

  6. tp5和微信小程序联接mqtt订阅及发布

    前文已经在啊里云宝塔中搭建好mqtt服务器,这里就在tp5及小程序中实现订阅及发布 一.tp5实现 1.先上网下载phpMQTT.php文件 https://github.com/bluerhinos ...

  7. redis操作订阅和发布

    redis中订阅和发布,可以理解为java设计模式中的生产者和消费者模式,一个生产数据,一个消费数据,消费数据的呢,开启一个阻塞线程,等待生产数据,接下来我们看看redis怎样操作,我们需要开启两个终 ...

  8. 切换上下首音乐功能的实现(消息订阅与发布的使用)

    切换上下首音乐 思路: 切换歌曲,实际上是切换歌曲的id,歌曲的详情页只有当前播放歌曲的id,所以要想更新音乐的id得去每日推荐的列表页更新,切换歌曲有两种情况,一个是上一首,一个是下一首,可以绑定在 ...

  9. 微信小程序开发笔记 进阶篇③——onfire.js事件订阅和发布在微信小程序中的使用

    文章目录 一.前言 二.onfire.js介绍 三.API介绍 四.实例应用 五.onfire源码 六.实例源码 一.前言 微信小程序开发笔记--导读 二.onfire.js介绍 一个简单实用的事件订 ...

最新文章

  1. 将图片的二进制序列转为numpy且有shape
  2. ASP.NET用户登录模块代码
  3. 《作业控制系列》-“linux命令五分钟系列”之十
  4. Retrofit+RxJava
  5. 空间句法软件_【特训营2:空间句法高阶班】GIS中的空间句法运用 丨城市数据派...
  6. python-语言播报
  7. Mybatis参数传递及返回类型
  8. 5b计算机联锁系统_力控科技油库调度管理系统应用案例
  9. 利用操作系统提供的API编写防火墙
  10. 2009年3月全球程序设计语言排名(强烈推荐!)
  11. 好用的文本编辑器推荐
  12. Talib技术因子详解(八)
  13. 【SqlServer】不允许保存更改。您所做的更改要求删除并重新创建以下表。您对无法重新创建的表进行了更改或者启用了“阻止保存要求重新创建表的更改”选项
  14. 基于stc8a的ad9833模块的例程的使用
  15. 大数据下的图片类别以及图片爬取详细的过程(一)
  16. VM虚拟机安装WindowsXp_SP3全过程
  17. Android夜间模式原理
  18. MSRA提出学习实例和分布式视觉表示的极端掩蔽模型ExtreMA
  19. 掌上生活显示服务器忙,掌上生活服务端
  20. AS400 - DB2 for i的加密、解密

热门文章

  1. 使用node的Hapi框架搭建后台(一)——搭建项目
  2. 【从Java转C#】第八章:委托、lambda、事件
  3. Java 通过SMTP实现发送QQ邮件
  4. Python进行Excel数据统计
  5. 绿幕背景视频抠图替换
  6. ACCESS备件库管理数据库
  7. 平面设计入门新手需看技巧
  8. 4ARM-PEG-DA 4Arm-PEG-ACRL 四臂PEG丙烯酸酯
  9. python爬虫_网易音乐歌单
  10. 支付宝生活号h5网页--蚂蚁认证