rclcpp
master
C++ ROS Client Library API
|
Classes | |
class | AnyServiceCallback |
class | AnySubscriptionCallback |
class | AsyncParametersClient |
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 | GenericRate |
class | GenericTimer |
Generic timer. Periodically executes a user-specified callback. More... | |
class | InitOptions |
Encapsulation of options for initializing rclcpp. More... | |
class | JumpHandler |
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 |
class | TimerBase |
class | TimeSource |
class | Waitable |
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 | Rate = GenericRate< std::chrono::system_clock > |
using | WallRate = GenericRate< std::chrono::steady_clock > |
using | VoidCallbackType = std::function< void()> |
using | TimerCallbackType = std::function< void(TimerBase &)> |
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 | |
std::vector< Context::SharedPtr > | get_contexts () |
Return a copy of the list of context shared pointers. More... | |
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... | |
Logger | get_node_logger (const rcl_node_t *node) |
Return a named logger using an rcl_node_t. More... | |
std::string | _to_json_dict_entry (const Parameter ¶m) |
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 > ¶meters) |
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::ostream & | operator<< (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[], 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... | |
using rclcpp::ParameterMap = typedef std::unordered_map<std::string, std::vector<Parameter> > |
A map of fully qualified node names to a list of parameters.
using rclcpp::Rate = typedef GenericRate<std::chrono::system_clock> |
using rclcpp::WallRate = typedef GenericRate<std::chrono::steady_clock> |
using rclcpp::VoidCallbackType = typedef std::function<void ()> |
using rclcpp::TimerCallbackType = typedef std::function<void (TimerBase &)> |
std::vector<Context::SharedPtr> rclcpp::get_contexts | ( | ) |
Return a copy of the list of context shared pointers.
This function is thread-safe.
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 | ||
) |
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.
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 | ||
) |
void rclcpp::spin_some | ( | rclcpp::node_interfaces::NodeBaseInterface::SharedPtr | node_ptr | ) |
Create a default single-threaded executor and execute any immediately available work.
[in] | node_ptr | Shared pointer to the node to spin. |
void rclcpp::spin_some | ( | rclcpp::Node::SharedPtr | node_ptr | ) |
void rclcpp::spin | ( | rclcpp::node_interfaces::NodeBaseInterface::SharedPtr | node_ptr | ) |
Create a default single-threaded executor and spin the specified node.
[in] | node_ptr | Shared pointer to the node to spin. |
void rclcpp::spin | ( | rclcpp::Node::SharedPtr | node_ptr | ) |
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) |
||
) |
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) |
||
) |
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.
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 |
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 |
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.
[in] | name | the name of the 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.
[in] | node | the rcl node from which to get the logger name |
std::string rclcpp::_to_json_dict_entry | ( | const Parameter & | param | ) |
Return a json encoded version of the parameter intended for a dict.
std::ostream& rclcpp::operator<< | ( | std::ostream & | os, |
const rclcpp::Parameter & | pv | ||
) |
std::ostream& rclcpp::operator<< | ( | std::ostream & | os, |
const std::vector< Parameter > & | parameters | ||
) |
ParameterMap rclcpp::parameter_map_from | ( | const rcl_params_t *const | c_params | ) |
Convert parameters from rcl_yaml_param_parser into C++ class instances.
[in] | c_params | C structures containing parameters for multiple nodes. |
InvalidParametersException | if the rcl_params_t is inconsistent or invalid. |
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.
[in] | c_value | C structure containing a value of a parameter. |
InvalidParameterValueException | if the rcl_variant_t is inconsistent or invalid. |
std::string rclcpp::to_string | ( | const ParameterType | type | ) |
Return the name of a parameter type.
std::ostream& rclcpp::operator<< | ( | std::ostream & | os, |
const ParameterType | type | ||
) |
std::string rclcpp::to_string | ( | const ParameterValue & | type | ) |
Return the value of a parameter as a string.
PublisherFactory rclcpp::create_publisher_factory | ( | std::shared_ptr< Alloc > | allocator | ) |
Return a PublisherFactory with functions setup for creating a PublisherT<MessageT, Alloc>.
ScopeExit<Callable> rclcpp::make_scope_exit | ( | Callable | callable | ) |
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>.
Time rclcpp::operator+ | ( | const rclcpp::Duration & | lhs, |
const rclcpp::Time & | rhs | ||
) |
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::default_context::get_global_default_context(). Also, installs the global signal handlers with the function rclcpp::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.
bool rclcpp::signal_handlers_installed | ( | ) |
Return true if the signal handlers are installed, otherwise false.
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.
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.
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.
[in] | argc | Number of arguments. |
[in] | argv | Argument vector. |
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().
[in] | context | Check for shutdown of this Context. |
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().
[in] | context | Check for initialization of this Context. |
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.
[in] | context | to be 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.
[in] | callback | to be called when the given context is shutdown |
[in] | context | with which to associate the context |
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.
If nullptr is given for the context, then the global context is used, i.e. the context initialized by rclcpp::init().
[in] | nanoseconds | A std::chrono::duration representing how long to sleep for. |
[in] | context | which may interrupt this sleep |
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.
[in] | x | is the first addend. |
[in] | y | is the second addend. |
T | is type of the operands. |
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.
[in] | x | is the first addend. |
[in] | y | is the second addend. |
T | is type of the operands. |
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.
[in] | x | is the minuend. |
[in] | y | is the subtrahend. |
T | is type of the operands. |
x - y
sum is grater than T::max value. 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.
[in] | x | is the minuend. |
[in] | y | is the subtrahend. |
T | is type of the operands. |
x - y
sum is less than T::min value. 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.
[in] | string_in | is the string to be returned |
const char* rclcpp::get_c_string | ( | const std::string & | string_in | ) |
Return the C string from the given std::string.
[in] | string_in | is a std::string |