rclcpp  master
C++ ROS Client Library API
Namespaces | Classes | Typedefs | Enumerations | Functions
rclcpp Namespace Reference

Namespaces

 allocator
 
 callback_group
 
 contexts
 
 exceptions
 
 executor
 
 executors
 
 function_traits
 
 graph_listener
 
 intra_process_manager
 
 mapped_ring_buffer
 
 memory_strategies
 
 memory_strategy
 
 message_memory_strategy
 
 node_interfaces
 
 strategies
 
 subscription_traits
 
 type_support
 

Classes

class  AnyServiceCallback
 
class  AnySubscriptionCallback
 
class  AsyncParametersClient
 
class  Client
 
class  ClientBase
 
class  Clock
 
class  Context
 
class  Duration
 
class  Event
 
class  GenericRate
 
class  GenericTimer
 Generic timer templated on the clock type. Periodically executes a user-specified callback. More...
 
class  JumpHandler
 
class  JumpThreshold
 A class to store a threshold for a TimeJump. More...
 
class  Logger
 
class  Node
 Node is the single point of entry for creating publishers and subscribers. More...
 
class  Parameter
 Structure to store an arbitrary parameter with templated get/set methods. More...
 
class  ParameterEventsFilter
 
class  ParameterService
 
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  PublisherFactory
 Factory with functions used to create a MessageT specific PublisherT. More...
 
class  RateBase
 
struct  ScopeExit
 
class  Service
 
class  ServiceBase
 
class  Subscription
 Subscription implementation, templated on the type of message this subscription receives. More...
 
class  SubscriptionBase
 
struct  SubscriptionFactory
 Factory with functions used to create a Subscription<MessageT>. More...
 
class  SyncParametersClient
 
class  Time
 
struct  TimeJump
 A struct to represent a timejump. More...
 
class  TimerBase
 
class  TimeSource
 

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 Rate = GenericRate< std::chrono::system_clock >
 
using WallRate = GenericRate< std::chrono::steady_clock >
 
using VoidCallbackType = std::function< void()>
 
using TimerCallbackType = std::function< void(TimerBase &)>
 
template<typename CallbackType >
using WallTimer = GenericTimer< CallbackType, std::chrono::steady_clock >
 

Enumerations

enum  ParameterType {
  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
}
 

Functions

template<typename MessageT , typename AllocatorT , typename PublisherT >
std::shared_ptr< PublisherT > create_publisher (rclcpp::node_interfaces::NodeTopicsInterface *node_topics, const std::string &topic_name, const rmw_qos_profile_t &qos_profile, bool use_intra_process_comms, std::shared_ptr< AllocatorT > allocator)
 
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::callback_group::CallbackGroup::SharedPtr group)
 
template<typename MessageT , typename CallbackT , typename AllocatorT , typename CallbackMessageT , typename SubscriptionT = rclcpp::Subscription<CallbackMessageT, AllocatorT>>
std::shared_ptr< SubscriptionT > create_subscription (rclcpp::node_interfaces::NodeTopicsInterface *node_topics, const std::string &topic_name, CallbackT &&callback, const rmw_qos_profile_t &qos_profile, rclcpp::callback_group::CallbackGroup::SharedPtr group, bool ignore_local_publications, bool use_intra_process_comms, typename rclcpp::message_memory_strategy::MessageMemoryStrategy< CallbackMessageT, AllocatorT >::SharedPtr msg_mem_strat, typename std::shared_ptr< AllocatorT > allocator)
 
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 TimeT = std::milli>
rclcpp::executor::FutureReturnCode spin_until_future_complete (rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, std::shared_future< FutureT > &future, std::chrono::duration< int64_t, TimeT > timeout=std::chrono::duration< int64_t, TimeT >(-1))
 
template<typename NodeT = rclcpp::Node, typename FutureT , typename TimeT = std::milli>
rclcpp::executor::FutureReturnCode spin_until_future_complete (std::shared_ptr< NodeT > node_ptr, std::shared_future< FutureT > &future, std::chrono::duration< int64_t, TimeT > timeout=std::chrono::duration< int64_t, 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...
 
Logger get_logger (const std::string &name)
 Return a named logger. More...
 
std::string _to_json_dict_entry (const Parameter &param)
 Return a json encoded version of the parameter intended for a dict. More...
 
std::ostreamoperator<< (std::ostream &os, const rclcpp::Parameter &pv)
 
std::ostreamoperator<< (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 (const ParameterType type)
 Return the name of a parameter type. More...
 
std::ostreamoperator<< (std::ostream &os, const ParameterType type)
 
std::string to_string (const ParameterValue &type)
 Return the value of a parameter as a string. More...
 
template<typename MessageT , typename Alloc , typename PublisherT >
PublisherFactory create_publisher_factory (std::shared_ptr< Alloc > allocator)
 Return a PublisherFactory with functions setup for creating a PublisherT<MessageT, Alloc>. More...
 
template<typename Callable >
ScopeExit< Callable > make_scope_exit (Callable callable)
 
template<typename MessageT , typename CallbackT , typename Alloc , typename CallbackMessageT , typename SubscriptionT >
SubscriptionFactory create_subscription_factory (CallbackT &&callback, typename rclcpp::message_memory_strategy::MessageMemoryStrategy< CallbackMessageT, Alloc >::SharedPtr msg_mem_strat, std::shared_ptr< Alloc > allocator)
 Return a SubscriptionFactory with functions for creating a SubscriptionT<MessageT, Alloc>. More...
 
Time operator+ (const rclcpp::Duration &lhs, const rclcpp::Time &rhs)
 
void init (int argc, char const *const argv[])
 Initialize communications via the rmw implementation and set up a global signal handler. More...
 
std::vector< std::stringinit_and_remove_ros_arguments (int argc, char const *const argv[])
 Initialize communications via the rmw implementation and set up a global signal handler. More...
 
std::vector< std::stringremove_ros_arguments (int argc, char const *const argv[])
 Remove ROS-specific arguments from argument vector. More...
 
bool ok ()
 Check rclcpp's status. More...
 
void shutdown ()
 Notify the signal handler and rmw that rclcpp is shutting down. More...
 
void on_shutdown (std::function< void(void)> callback)
 Register a function to be called when shutdown is called. More...
 
rcl_guard_condition_tget_sigint_guard_condition (rcl_wait_set_t *wait_set)
 Get a handle to the rmw guard condition that manages the signal handler. More...
 
void release_sigint_guard_condition (rcl_wait_set_t *wait_set)
 Release the previously allocated guard condition that manages the signal handler. More...
 
bool sleep_for (const std::chrono::nanoseconds &nanoseconds)
 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...
 

Typedef Documentation

◆ ParameterMap

A map of fully qualified node names to a list of parameters.

◆ Rate

◆ WallRate

◆ VoidCallbackType

using rclcpp::VoidCallbackType = typedef std::function<void()>

◆ TimerCallbackType

◆ WallTimer

template<typename CallbackType >
using rclcpp::WallTimer = typedef GenericTimer<CallbackType, std::chrono::steady_clock>

Enumeration Type Documentation

◆ ParameterType

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 

Function Documentation

◆ create_publisher()

template<typename MessageT , typename AllocatorT , typename PublisherT >
std::shared_ptr<PublisherT> rclcpp::create_publisher ( rclcpp::node_interfaces::NodeTopicsInterface node_topics,
const std::string topic_name,
const rmw_qos_profile_t qos_profile,
bool  use_intra_process_comms,
std::shared_ptr< AllocatorT >  allocator 
)

◆ 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::callback_group::CallbackGroup::SharedPtr  group 
)

Create a service with a given type.

◆ create_subscription()

template<typename MessageT , typename CallbackT , typename AllocatorT , typename CallbackMessageT , typename SubscriptionT = rclcpp::Subscription<CallbackMessageT, AllocatorT>>
std::shared_ptr<SubscriptionT> rclcpp::create_subscription ( rclcpp::node_interfaces::NodeTopicsInterface node_topics,
const std::string topic_name,
CallbackT &&  callback,
const rmw_qos_profile_t qos_profile,
rclcpp::callback_group::CallbackGroup::SharedPtr  group,
bool  ignore_local_publications,
bool  use_intra_process_comms,
typename rclcpp::message_memory_strategy::MessageMemoryStrategy< CallbackMessageT, AllocatorT >::SharedPtr  msg_mem_strat,
typename std::shared_ptr< AllocatorT >  allocator 
)

◆ 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_ptrShared 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_ptrShared 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 TimeT = std::milli>
rclcpp::executor::FutureReturnCode rclcpp::spin_until_future_complete ( rclcpp::node_interfaces::NodeBaseInterface::SharedPtr  node_ptr,
std::shared_future< FutureT > &  future,
std::chrono::duration< int64_t, TimeT >  timeout = std::chrono::duration<int64_t, TimeT>(-1) 
)

◆ spin_until_future_complete() [2/2]

template<typename NodeT = rclcpp::Node, typename FutureT , typename TimeT = std::milli>
rclcpp::executor::FutureReturnCode rclcpp::spin_until_future_complete ( std::shared_ptr< NodeT >  node_ptr,
std::shared_future< FutureT > &  future,
std::chrono::duration< int64_t, TimeT >  timeout = std::chrono::duration<int64_t, 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
namethe topic or service name to be validated
node_namethe name of the node associated with the name
namespace_the namespace of the node associated with the name
is_serviceif true InvalidServiceNameError is thrown instead
Returns
expanded (and validated) topic name
Exceptions
InvalidTopicNameErrorif name is invalid and is_service is false
InvalidServiceNameErrorif name is invalid and is_service is true
std::bad_allocif memory cannot be allocated
RCLErrorif an unexpect error occurs

◆ 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]namethe name of the logger
Returns
a logger with the fully-qualified name including naming conventions, or
a dummy logger if logging is disabled.

◆ _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<<() [1/3]

std::ostream& rclcpp::operator<< ( std::ostream os,
const rclcpp::Parameter pv 
)

◆ operator<<() [2/3]

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_paramsC structures containing parameters for multiple nodes.
Returns
a map where the keys are fully qualified node names and values a list of parameters.
Exceptions
InvalidParametersExceptionif 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_valueC structure containing a value of a parameter.
Returns
an instance of a parameter value
Exceptions
InvalidParameterValueExceptionif the rcl_variant_t is inconsistent or invalid.

◆ to_string() [1/2]

std::string rclcpp::to_string ( const ParameterType  type)

Return the name of a parameter type.

◆ operator<<() [3/3]

std::ostream& rclcpp::operator<< ( std::ostream os,
const ParameterType  type 
)

◆ to_string() [2/2]

std::string rclcpp::to_string ( const ParameterValue type)

Return the value of a parameter as a string.

◆ create_publisher_factory()

template<typename MessageT , typename Alloc , typename PublisherT >
PublisherFactory rclcpp::create_publisher_factory ( std::shared_ptr< Alloc >  allocator)

Return a PublisherFactory with functions setup for creating a PublisherT<MessageT, Alloc>.

◆ make_scope_exit()

template<typename Callable >
ScopeExit<Callable> rclcpp::make_scope_exit ( Callable  callable)

◆ create_subscription_factory()

template<typename MessageT , typename CallbackT , typename Alloc , typename CallbackMessageT , typename SubscriptionT >
SubscriptionFactory rclcpp::create_subscription_factory ( CallbackT &&  callback,
typename rclcpp::message_memory_strategy::MessageMemoryStrategy< CallbackMessageT, Alloc >::SharedPtr  msg_mem_strat,
std::shared_ptr< Alloc >  allocator 
)

Return a SubscriptionFactory with functions for creating a SubscriptionT<MessageT, Alloc>.

◆ operator+()

Time rclcpp::operator+ ( const rclcpp::Duration lhs,
const rclcpp::Time rhs 
)

◆ init()

void rclcpp::init ( int  argc,
char const *const  argv[] 
)

Initialize communications via the rmw implementation and set up a global signal handler.

Parameters
[in]argcNumber of arguments.
[in]argvArgument vector. Will eventually be used for passing options to rclcpp.

◆ init_and_remove_ros_arguments()

std::vector<std::string> rclcpp::init_and_remove_ros_arguments ( int  argc,
char const *const  argv[] 
)

Initialize communications via the rmw implementation and set up a global signal handler.

Additionally removes ROS-specific arguments from the argument vector.

Parameters
[in]argcNumber of arguments.
[in]argvArgument vector.
Returns
Members of the argument vector that are not ROS arguments.

◆ 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 a the aruments 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]argcNumber of arguments.
[in]argvArgument vector.
Returns
Members of the argument vector that are not ROS arguments.

◆ ok()

bool rclcpp::ok ( )

Check rclcpp's status.

Returns
True if SIGINT hasn't fired yet, false otherwise.

◆ shutdown()

void rclcpp::shutdown ( )

Notify the signal handler and rmw that rclcpp is shutting down.

◆ on_shutdown()

void rclcpp::on_shutdown ( std::function< void(void)>  callback)

Register a function to be called when shutdown is called.

Calling the callbacks is the last thing shutdown() does.

◆ get_sigint_guard_condition()

rcl_guard_condition_t* rclcpp::get_sigint_guard_condition ( rcl_wait_set_t wait_set)

Get a handle to the rmw guard condition that manages the signal handler.

The first time that this function is called for a given wait set a new guard condition will be created and returned; thereafter the same guard condition will be returned for the same wait set. This mechanism is designed to ensure that the same guard condition is not reused across wait sets (e.g., when using multiple executors in the same process). Will throw an exception if initialization of the guard condition fails.

Parameters
wait_setPointer to the rcl_wait_set_t that will be using the resulting guard condition.
Returns
Pointer to the guard condition.

◆ release_sigint_guard_condition()

void rclcpp::release_sigint_guard_condition ( rcl_wait_set_t wait_set)

Release the previously allocated guard condition that manages the signal handler.

If you previously called get_sigint_guard_condition() for a given wait set to get a sigint guard condition, then you should call release_sigint_guard_condition() when you're done, to free that condition. Will throw an exception if get_sigint_guard_condition() wasn't previously called for the given wait set.

Parameters
wait_setPointer to the rcl_wait_set_t that was using the resulting guard condition.

◆ sleep_for()

bool rclcpp::sleep_for ( const std::chrono::nanoseconds nanoseconds)

Use the global condition variable to block for the specified amount of time.

Parameters
[in]nanosecondsA std::chrono::duration representing how long to sleep for.
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]xis the first addend.
[in]yis the second addend.
Template Parameters
Tis 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]xis the first addend.
[in]yis the second addend.
Template Parameters
Tis 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]xis the minuend.
[in]yis the subtrahend.
Template Parameters
Tis 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]xis the minuend.
[in]yis the subtrahend.
Template Parameters
Tis type of the operands.
Returns
True if the difference x - y sum is less than T::min value.