ROS 2 rclcpp + rcl - jazzy  jazzy
ROS 2 C++ Client Library with ROS Client Library
Public Member Functions | List of all members
rclcpp::NodeOptions Class Reference

Encapsulation of options for node initialization. More...

#include <rclcpp/node_options.hpp>

Public Member Functions

RCLCPP_PUBLIC NodeOptions (rcl_allocator_t allocator=rcl_get_default_allocator())
 Create NodeOptions with default values, optionally specifying the allocator to use. More...
 
virtual RCLCPP_PUBLIC ~NodeOptions ()=default
 Destructor.
 
RCLCPP_PUBLIC NodeOptions (const NodeOptions &other)
 Copy constructor.
 
RCLCPP_PUBLIC NodeOptionsoperator= (const NodeOptions &other)
 Assignment operator.
 
RCLCPP_PUBLIC const rcl_node_options_tget_rcl_node_options () const
 Return the rcl_node_options used by the node. More...
 
RCLCPP_PUBLIC rclcpp::Context::SharedPtr context () const
 Return the context to be used by the node.
 
RCLCPP_PUBLIC NodeOptionscontext (rclcpp::Context::SharedPtr context)
 Set the context, return this for parameter idiom.
 
RCLCPP_PUBLIC const std::vector< std::string > & arguments () const
 Return a reference to the list of arguments for the node.
 
RCLCPP_PUBLIC NodeOptionsarguments (const std::vector< std::string > &arguments)
 Set the arguments, return this for parameter idiom. More...
 
RCLCPP_PUBLIC std::vector< rclcpp::Parameter > & parameter_overrides ()
 Return a reference to the list of parameter overrides.
 
RCLCPP_PUBLIC const std::vector< rclcpp::Parameter > & parameter_overrides () const
 
RCLCPP_PUBLIC NodeOptionsparameter_overrides (const std::vector< rclcpp::Parameter > &parameter_overrides)
 Set the parameters overrides, return this for parameter idiom. More...
 
template<typename ParameterT >
NodeOptionsappend_parameter_override (const std::string &name, const ParameterT &value)
 Append a single parameter override, parameter idiom style.
 
NodeOptionsappend_parameter_override (const rclcpp::Parameter &param)
 Append a single parameter override, parameter idiom style.
 
RCLCPP_PUBLIC bool use_global_arguments () const
 Return the use_global_arguments flag.
 
RCLCPP_PUBLIC NodeOptionsuse_global_arguments (bool use_global_arguments)
 Set the use_global_arguments flag, return this for parameter idiom. More...
 
RCLCPP_PUBLIC bool enable_rosout () const
 Return the enable_rosout flag.
 
RCLCPP_PUBLIC NodeOptionsenable_rosout (bool enable_rosout)
 Set the enable_rosout flag, return this for parameter idiom. More...
 
RCLCPP_PUBLIC bool use_intra_process_comms () const
 Return the use_intra_process_comms flag.
 
RCLCPP_PUBLIC NodeOptionsuse_intra_process_comms (bool use_intra_process_comms)
 Set the use_intra_process_comms flag, return this for parameter idiom. More...
 
RCLCPP_PUBLIC bool enable_topic_statistics () const
 Return the enable_topic_statistics flag.
 
RCLCPP_PUBLIC NodeOptionsenable_topic_statistics (bool enable_topic_statistics)
 Set the enable_topic_statistics flag, return this for parameter idiom. More...
 
RCLCPP_PUBLIC bool start_parameter_services () const
 Return the start_parameter_services flag.
 
RCLCPP_PUBLIC NodeOptionsstart_parameter_services (bool start_parameter_services)
 Set the start_parameter_services flag, return this for parameter idiom. More...
 
RCLCPP_PUBLIC bool enable_logger_service () const
 Return the enable_logger_service flag.
 
RCLCPP_PUBLIC NodeOptionsenable_logger_service (bool enable_log_service)
 Set the enable_logger_service flag, return this for logger idiom. More...
 
RCLCPP_PUBLIC bool start_parameter_event_publisher () const
 Return the start_parameter_event_publisher flag.
 
RCLCPP_PUBLIC NodeOptionsstart_parameter_event_publisher (bool start_parameter_event_publisher)
 Set the start_parameter_event_publisher flag, return this for parameter idiom. More...
 
RCLCPP_PUBLIC const rcl_clock_type_tclock_type () const
 Return a reference to the clock type.
 
RCLCPP_PUBLIC NodeOptionsclock_type (const rcl_clock_type_t &clock_type)
 Set the clock type. More...
 
RCLCPP_PUBLIC const rclcpp::QoSclock_qos () const
 Return a reference to the clock QoS.
 
RCLCPP_PUBLIC NodeOptionsclock_qos (const rclcpp::QoS &clock_qos)
 Set the clock QoS. More...
 
RCLCPP_PUBLIC bool use_clock_thread () const
 Return the use_clock_thread flag.
 
RCLCPP_PUBLIC NodeOptionsuse_clock_thread (bool use_clock_thread)
 Set the use_clock_thread flag, return this for parameter idiom. More...
 
RCLCPP_PUBLIC const rclcpp::QoSparameter_event_qos () const
 Return a reference to the parameter_event_qos QoS.
 
RCLCPP_PUBLIC NodeOptionsparameter_event_qos (const rclcpp::QoS &parameter_event_qos)
 Set the parameter_event_qos QoS, return this for parameter idiom. More...
 
RCLCPP_PUBLIC const rclcpp::QoSrosout_qos () const
 Return a reference to the rosout QoS.
 
RCLCPP_PUBLIC NodeOptionsrosout_qos (const rclcpp::QoS &rosout_qos)
 Set the rosout QoS. More...
 
RCLCPP_PUBLIC const rclcpp::PublisherOptionsBaseparameter_event_publisher_options () const
 Return a reference to the parameter_event_publisher_options.
 
RCLCPP_PUBLIC NodeOptionsparameter_event_publisher_options (const rclcpp::PublisherOptionsBase &parameter_event_publisher_options)
 Set the parameter_event_publisher_options, return this for parameter idiom. More...
 
RCLCPP_PUBLIC bool allow_undeclared_parameters () const
 Return the allow_undeclared_parameters flag.
 
RCLCPP_PUBLIC NodeOptionsallow_undeclared_parameters (bool allow_undeclared_parameters)
 Set the allow_undeclared_parameters, return this for parameter idiom. More...
 
RCLCPP_PUBLIC bool automatically_declare_parameters_from_overrides () const
 Return the automatically_declare_parameters_from_overrides flag.
 
RCLCPP_PUBLIC NodeOptionsautomatically_declare_parameters_from_overrides (bool automatically_declare_parameters_from_overrides)
 Set the automatically_declare_parameters_from_overrides, return this. More...
 
RCLCPP_PUBLIC const rcl_allocator_tallocator () const
 Return the rcl_allocator_t to be used.
 
RCLCPP_PUBLIC NodeOptionsallocator (rcl_allocator_t allocator)
 Set the rcl_allocator_t to be used, may cause deallocation of existing rcl_node_options_t. More...
 

Detailed Description

Encapsulation of options for node initialization.

Definition at line 35 of file node_options.hpp.

Constructor & Destructor Documentation

◆ NodeOptions()

rclcpp::NodeOptions::NodeOptions ( rcl_allocator_t  allocator = rcl_get_default_allocator())
explicit

Create NodeOptions with default values, optionally specifying the allocator to use.

Default values for the node options:

  • context = rclcpp::contexts::get_global_default_context()
  • arguments = {}
  • parameter_overrides = {}
  • use_global_arguments = true
  • enable_rosout = true
  • use_intra_process_comms = false
  • enable_topic_statistics = false
  • start_parameter_services = true
  • start_parameter_event_publisher = true
  • clock_type = RCL_ROS_TIME
  • clock_qos = rclcpp::ClockQoS()
  • use_clock_thread = true
  • enable_logger_service = false
  • rosout_qos = rclcpp::RosoutQoS()
  • parameter_event_qos = rclcpp::ParameterEventQoS
    • with history setting and depth from rmw_qos_profile_parameter_events
  • parameter_event_publisher_options = rclcpp::PublisherOptionsBase
  • allow_undeclared_parameters = false
  • automatically_declare_parameters_from_overrides = false
  • allocator = rcl_get_default_allocator()
Parameters
[in]allocatorallocator to use in construction of NodeOptions.

Definition at line 56 of file node_options.cpp.

Member Function Documentation

◆ allocator()

NodeOptions & rclcpp::NodeOptions::allocator ( rcl_allocator_t  allocator)

Set the rcl_allocator_t to be used, may cause deallocation of existing rcl_node_options_t.

This will cause the internal rcl_node_options_t struct to be invalidated.

Definition at line 393 of file node_options.cpp.

References allocator().

Here is the call graph for this function:

◆ allow_undeclared_parameters()

NodeOptions & rclcpp::NodeOptions::allow_undeclared_parameters ( bool  allow_undeclared_parameters)

Set the allow_undeclared_parameters, return this for parameter idiom.

If true, allow any parameter name to be set on the node without first being declared. Otherwise, setting an undeclared parameter will raise an exception.

This option being true does not affect parameter_overrides, as the first set action will implicitly declare the parameter and therefore consider any parameter overrides.

Definition at line 365 of file node_options.cpp.

References allow_undeclared_parameters().

Here is the call graph for this function:

◆ arguments()

NodeOptions & rclcpp::NodeOptions::arguments ( const std::vector< std::string > &  arguments)

Set the arguments, return this for parameter idiom.

These arguments are used to extract remappings used by the node and other ROS specific settings, as well as user defined non-ROS arguments.

This will cause the internal rcl_node_options_t struct to be invalidated.

Definition at line 159 of file node_options.cpp.

References arguments().

Here is the call graph for this function:

◆ automatically_declare_parameters_from_overrides()

NodeOptions & rclcpp::NodeOptions::automatically_declare_parameters_from_overrides ( bool  automatically_declare_parameters_from_overrides)

Set the automatically_declare_parameters_from_overrides, return this.

If true, automatically iterate through the node's parameter overrides and implicitly declare any that have not already been declared. Otherwise, parameters passed to the node's parameter_overrides, and/or the global arguments (e.g. parameter overrides from a YAML file), which are not explicitly declared will not appear on the node at all, even if allow_undeclared_parameters is true. Parameter declaration from overrides is done in the node's base constructor, so the user must take care to check if the parameter is already (e.g. automatically) declared before declaring it themselves. Already declared parameters will not be re-declared, and parameters declared in this way will use the default constructed ParameterDescriptor.

Definition at line 378 of file node_options.cpp.

References automatically_declare_parameters_from_overrides().

Here is the call graph for this function:

◆ clock_qos()

NodeOptions & rclcpp::NodeOptions::clock_qos ( const rclcpp::QoS clock_qos)

Set the clock QoS.

The QoS settings to be used for the publisher on /clock topic, if enabled.

Definition at line 298 of file node_options.cpp.

References clock_qos().

Here is the call graph for this function:

◆ clock_type()

NodeOptions & rclcpp::NodeOptions::clock_type ( const rcl_clock_type_t clock_type)

Set the clock type.

The clock type to be used by the node.

Definition at line 285 of file node_options.cpp.

References clock_type().

Here is the call graph for this function:

◆ enable_logger_service()

NodeOptions & rclcpp::NodeOptions::enable_logger_service ( bool  enable_log_service)

Set the enable_logger_service flag, return this for logger idiom.

If true, ROS services are created to allow external nodes to get and set logger levels of this node.

If false, loggers will still be configured and set logger levels locally, but logger levels cannot be changed remotely .

Definition at line 259 of file node_options.cpp.

References enable_logger_service().

Referenced by enable_logger_service().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enable_rosout()

NodeOptions & rclcpp::NodeOptions::enable_rosout ( bool  enable_rosout)

Set the enable_rosout flag, return this for parameter idiom.

If false this will cause the node not to use rosout logging.

Defaults to true for now, as there are still some cases where it is desirable.

Definition at line 206 of file node_options.cpp.

References enable_rosout().

Here is the call graph for this function:

◆ enable_topic_statistics()

NodeOptions & rclcpp::NodeOptions::enable_topic_statistics ( bool  enable_topic_statistics)

Set the enable_topic_statistics flag, return this for parameter idiom.

If true, topic statistics collection and publication will be enabled for all subscriptions. This can be used to override the global topic statistics setting.

Defaults to false.

Definition at line 233 of file node_options.cpp.

References enable_topic_statistics().

Here is the call graph for this function:

◆ get_rcl_node_options()

const rcl_node_options_t * rclcpp::NodeOptions::get_rcl_node_options ( ) const

Return the rcl_node_options used by the node.

This data structure is created lazily, on the first call to this function. Repeated calls will not regenerate it unless one of the input settings changed, like arguments, use_global_arguments, or the rcl allocator.

Returns
a const rcl_node_options_t structure used by the node
Exceptions
exceptions::UnknownROSArgsErrorif there are unknown ROS arguments

Definition at line 96 of file node_options.cpp.

References rclcpp::QoS::get_rmw_qos_profile(), rcl_node_get_default_options(), rcl_parse_arguments(), RCL_RET_INVALID_ARGUMENT, and RCL_RET_OK.

Here is the call graph for this function:

◆ parameter_event_publisher_options()

NodeOptions & rclcpp::NodeOptions::parameter_event_publisher_options ( const rclcpp::PublisherOptionsBase parameter_event_publisher_options)

Set the parameter_event_publisher_options, return this for parameter idiom.

The QoS settings to be used for the parameter event publisher, if enabled.

Todo:
(wjwwood): make this take/store an instance of rclcpp::PublisherOptionsWithAllocator<Allocator>, but to do that requires NodeOptions to also be templated based on the Allocator type.

Definition at line 351 of file node_options.cpp.

References parameter_event_publisher_options().

Here is the call graph for this function:

◆ parameter_event_qos()

NodeOptions & rclcpp::NodeOptions::parameter_event_qos ( const rclcpp::QoS parameter_event_qos)

Set the parameter_event_qos QoS, return this for parameter idiom.

The QoS settings to be used for the parameter event publisher, if enabled.

Definition at line 324 of file node_options.cpp.

References parameter_event_qos().

Here is the call graph for this function:

◆ parameter_overrides()

NodeOptions & rclcpp::NodeOptions::parameter_overrides ( const std::vector< rclcpp::Parameter > &  parameter_overrides)

Set the parameters overrides, return this for parameter idiom.

These parameter overrides are used to change the initial value of declared parameters within the node, overriding hard coded default values if necessary.

Definition at line 179 of file node_options.cpp.

References parameter_overrides().

Here is the call graph for this function:

◆ rosout_qos()

NodeOptions & rclcpp::NodeOptions::rosout_qos ( const rclcpp::QoS rosout_qos)

Set the rosout QoS.

The QoS settings to be used for the publisher on /rosout topic, if enabled.

Definition at line 337 of file node_options.cpp.

References rosout_qos().

Here is the call graph for this function:

◆ start_parameter_event_publisher()

NodeOptions & rclcpp::NodeOptions::start_parameter_event_publisher ( bool  start_parameter_event_publisher)

Set the start_parameter_event_publisher flag, return this for parameter idiom.

If true, a publisher is created on which an event message is published each time a parameter's state changes. This is used for recording and introspection, but is configurable separately from the other parameter services.

Definition at line 272 of file node_options.cpp.

References start_parameter_event_publisher().

Here is the call graph for this function:

◆ start_parameter_services()

NodeOptions & rclcpp::NodeOptions::start_parameter_services ( bool  start_parameter_services)

Set the start_parameter_services flag, return this for parameter idiom.

If true, ROS services are created to allow external nodes to list, get, and request to set parameters of this node.

If false, parameters will still work locally, but will not be accessible remotely.

See also
start_parameter_event_publisher()

Definition at line 246 of file node_options.cpp.

References start_parameter_services().

Here is the call graph for this function:

◆ use_clock_thread()

NodeOptions & rclcpp::NodeOptions::use_clock_thread ( bool  use_clock_thread)

Set the use_clock_thread flag, return this for parameter idiom.

If true, a dedicated thread will be used to subscribe to "/clock" topic.

Definition at line 311 of file node_options.cpp.

References use_clock_thread().

Here is the call graph for this function:

◆ use_global_arguments()

NodeOptions & rclcpp::NodeOptions::use_global_arguments ( bool  use_global_arguments)

Set the use_global_arguments flag, return this for parameter idiom.

If true this will cause the node's behavior to be influenced by "global" arguments, i.e. arguments not targeted at specific nodes, as well as the arguments targeted at the current node.

This will cause the internal rcl_node_options_t struct to be invalidated.

Definition at line 192 of file node_options.cpp.

References use_global_arguments().

Here is the call graph for this function:

◆ use_intra_process_comms()

NodeOptions & rclcpp::NodeOptions::use_intra_process_comms ( bool  use_intra_process_comms)

Set the use_intra_process_comms flag, return this for parameter idiom.

If true, messages on topics which are published and subscribed to within this context will go through a special intra-process communication code code path which can avoid serialization and deserialization, unnecessary copies, and achieve lower latencies in some cases.

Defaults to false for now, as there are still some cases where it is not desirable.

Definition at line 220 of file node_options.cpp.

References use_intra_process_comms().

Here is the call graph for this function:

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