15 #include "rclcpp/node_options.hpp"
23 #include "rclcpp/detail/utilities.hpp"
24 #include "rclcpp/exceptions.hpp"
25 #include "rclcpp/logging.hpp"
26 #include "rclcpp/publisher_options.hpp"
27 #include "rclcpp/qos.hpp"
29 using rclcpp::exceptions::throw_from_rcl_error;
46 "failed to finalize rcl node options: %s", rcl_get_error_string().str);
51 node_options =
nullptr;
57 : node_options_(nullptr, detail::rcl_node_options_t_destructor), allocator_(allocator)
61 : node_options_(nullptr, detail::rcl_node_options_t_destructor)
70 this->node_options_.reset();
71 this->context_ = other.context_;
72 this->arguments_ = other.arguments_;
73 this->parameter_overrides_ = other.parameter_overrides_;
74 this->use_global_arguments_ = other.use_global_arguments_;
75 this->enable_rosout_ = other.enable_rosout_;
76 this->use_intra_process_comms_ = other.use_intra_process_comms_;
77 this->enable_topic_statistics_ = other.enable_topic_statistics_;
78 this->start_parameter_services_ = other.start_parameter_services_;
79 this->start_parameter_event_publisher_ = other.start_parameter_event_publisher_;
80 this->clock_qos_ = other.clock_qos_;
81 this->use_clock_thread_ = other.use_clock_thread_;
82 this->parameter_event_qos_ = other.parameter_event_qos_;
83 this->rosout_qos_ = other.rosout_qos_;
84 this->parameter_event_publisher_options_ = other.parameter_event_publisher_options_;
85 this->allow_undeclared_parameters_ = other.allow_undeclared_parameters_;
86 this->automatically_declare_parameters_from_overrides_ =
87 other.automatically_declare_parameters_from_overrides_;
88 this->allocator_ = other.allocator_;
100 node_options_->allocator = this->allocator_;
101 node_options_->use_global_arguments = this->use_global_arguments_;
102 node_options_->enable_rosout = this->enable_rosout_;
106 std::unique_ptr<const char *[]> c_argv;
107 if (!this->arguments_.empty()) {
108 if (this->arguments_.size() >
static_cast<size_t>(std::numeric_limits<int>::max())) {
112 c_argc =
static_cast<int>(this->arguments_.size());
113 c_argv.reset(
new const char *[c_argc]);
115 for (std::size_t i = 0; i < this->arguments_.size(); ++i) {
116 c_argv[i] = this->arguments_[i].c_str();
121 c_argc, c_argv.get(), this->allocator_, &(node_options_->arguments));
124 throw_from_rcl_error(ret,
"failed to parse arguments");
127 std::vector<std::string> unparsed_ros_arguments = detail::get_unparsed_ros_arguments(
128 c_argc, c_argv.get(), &(node_options_->arguments), this->allocator_);
129 if (!unparsed_ros_arguments.empty()) {
134 return node_options_.get();
137 rclcpp::Context::SharedPtr
140 return this->context_;
150 const std::vector<std::string> &
153 return this->arguments_;
159 this->node_options_.reset();
164 std::vector<rclcpp::Parameter> &
167 return this->parameter_overrides_;
170 const std::vector<rclcpp::Parameter> &
173 return this->parameter_overrides_;
186 return this->use_global_arguments_;
192 this->node_options_.reset();
200 return this->enable_rosout_;
206 this->node_options_.reset();
214 return this->use_intra_process_comms_;
227 return this->enable_topic_statistics_;
240 return this->start_parameter_services_;
253 return this->start_parameter_event_publisher_;
266 return this->clock_qos_;
279 return this->use_clock_thread_;
292 return this->parameter_event_qos_;
305 return this->rosout_qos_;
311 this->node_options_.reset();
319 return parameter_event_publisher_options_;
333 return this->allow_undeclared_parameters_;
346 return this->automatically_declare_parameters_from_overrides_;
351 bool automatically_declare_parameters_from_overrides)
353 this->automatically_declare_parameters_from_overrides_ =
361 return this->allocator_;
367 this->node_options_.reset();
rcutils_allocator_t rcl_allocator_t
Encapsulation of an allocator.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_parse_arguments(int argc, const char *const *argv, rcl_allocator_t allocator, rcl_arguments_t *args_output)
Parse command line arguments into a structure usable by code.
Encapsulation of options for node initialization.
RCLCPP_PUBLIC bool start_parameter_event_publisher() const
Return the start_parameter_event_publisher flag.
RCLCPP_PUBLIC const std::vector< std::string > & arguments() const
Return a reference to the list of arguments for the node.
RCLCPP_PUBLIC bool use_clock_thread() const
Return the use_clock_thread flag.
RCLCPP_PUBLIC bool use_global_arguments() const
Return the use_global_arguments flag.
RCLCPP_PUBLIC const rclcpp::QoS & parameter_event_qos() const
Return a reference to the parameter_event_qos QoS.
RCLCPP_PUBLIC const rclcpp::QoS & rosout_qos() const
Return a reference to the rosout QoS.
RCLCPP_PUBLIC bool enable_rosout() const
Return the enable_rosout flag.
RCLCPP_PUBLIC const rclcpp::PublisherOptionsBase & parameter_event_publisher_options() const
Return a reference to the parameter_event_publisher_options.
RCLCPP_PUBLIC bool allow_undeclared_parameters() const
Return the allow_undeclared_parameters flag.
RCLCPP_PUBLIC bool automatically_declare_parameters_from_overrides() const
Return the automatically_declare_parameters_from_overrides flag.
RCLCPP_PUBLIC const rclcpp::QoS & clock_qos() const
Return a reference to the clock QoS.
RCLCPP_PUBLIC NodeOptions(rcl_allocator_t allocator=rcl_get_default_allocator())
Create NodeOptions with default values, optionally specifying the allocator to use.
RCLCPP_PUBLIC bool start_parameter_services() const
Return the start_parameter_services flag.
RCLCPP_PUBLIC bool use_intra_process_comms() const
Return the use_intra_process_comms flag.
RCLCPP_PUBLIC std::vector< rclcpp::Parameter > & parameter_overrides()
Return a reference to the list of parameter overrides.
RCLCPP_PUBLIC const rcl_allocator_t & allocator() const
Return the rcl_allocator_t to be used.
RCLCPP_PUBLIC rclcpp::Context::SharedPtr context() const
Return the context to be used by the node.
RCLCPP_PUBLIC bool enable_topic_statistics() const
Return the enable_topic_statistics flag.
RCLCPP_PUBLIC const rcl_node_options_t * get_rcl_node_options() const
Return the rcl_node_options used by the node.
RCLCPP_PUBLIC NodeOptions & operator=(const NodeOptions &other)
Assignment operator.
Encapsulation of Quality of Service settings.
rmw_qos_profile_t & get_rmw_qos_profile()
Return the rmw qos profile.
Thrown when unparsed ROS specific arguments are found.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
RCLCPP_PUBLIC Logger get_logger(const std::string &name)
Return a named logger.
RCL_PUBLIC rcl_node_options_t rcl_node_get_default_options(void)
Return the default node options in a rcl_node_options_t.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_node_options_fini(rcl_node_options_t *options)
Finalize the given node_options.
Structure which encapsulates the options for creating a rcl_node_t.
Non-templated part of PublisherOptionsWithAllocator<Allocator>.
#define RCL_RET_OK
Success return code.
#define RCL_RET_INVALID_ARGUMENT
Invalid argument return code.
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.