15 #ifndef RCLCPP__NODE_IMPL_HPP_ 16 #define RCLCPP__NODE_IMPL_HPP_ 36 #include "rcl_interfaces/msg/intra_process_message.hpp" 46 #ifndef RCLCPP__NODE_HPP_ 53 template<
typename MessageT,
typename Alloc,
typename PublisherT>
56 const std::string & topic_name,
size_t qos_history_depth,
60 allocator = std::make_shared<Alloc>();
63 qos.
depth = qos_history_depth;
64 return this->create_publisher<MessageT, Alloc, PublisherT>(topic_name, qos, allocator);
67 template<
typename MessageT,
typename Alloc,
typename PublisherT>
74 allocator = std::make_shared<Alloc>();
76 return rclcpp::create_publisher<MessageT, Alloc, PublisherT>(
77 this->node_topics_.get(),
80 use_intra_process_comms_,
84 template<
typename MessageT,
typename CallbackT,
typename Alloc,
typename SubscriptionT>
88 CallbackT && callback,
90 rclcpp::callback_group::CallbackGroup::SharedPtr group,
91 bool ignore_local_publications,
97 allocator = std::make_shared<Alloc>();
100 if (!msg_mem_strat) {
102 msg_mem_strat = MessageMemoryStrategy<MessageT, Alloc>::create_default();
105 return rclcpp::create_subscription<MessageT, CallbackT, Alloc, SubscriptionT>(
106 this->node_topics_.get(),
108 std::forward<CallbackT>(callback),
111 ignore_local_publications,
112 use_intra_process_comms_,
117 template<
typename MessageT,
typename CallbackT,
typename Alloc,
typename SubscriptionT>
121 size_t qos_history_depth,
122 CallbackT && callback,
123 rclcpp::callback_group::CallbackGroup::SharedPtr group,
124 bool ignore_local_publications,
130 qos.
depth = qos_history_depth;
131 return this->create_subscription<MessageT, CallbackT, Alloc, SubscriptionT>(
133 std::forward<CallbackT>(callback),
136 ignore_local_publications,
141 template<
typename DurationT,
typename CallbackT>
146 rclcpp::callback_group::CallbackGroup::SharedPtr group)
149 std::chrono::duration_cast<std::chrono::nanoseconds>(period),
151 node_timers_->add_timer(timer, group);
155 template<
typename ServiceT>
160 rclcpp::callback_group::CallbackGroup::SharedPtr group)
163 options.
qos = qos_profile;
175 node_services_->add_client(cli_base_ptr, group);
179 template<
typename ServiceT,
typename CallbackT>
183 CallbackT && callback,
185 rclcpp::callback_group::CallbackGroup::SharedPtr group)
188 any_service_callback.
set(std::forward<CallbackT>(callback));
191 service_options.
qos = qos_profile;
194 node_base_->get_shared_rcl_node_handle(),
195 service_name, any_service_callback, service_options);
197 node_services_->add_service(serv_base_ptr, group);
201 template<
typename CallbackT>
205 this->node_parameters_->register_param_change_callback(std::forward<CallbackT>(callback));
208 template<
typename ParameterT>
212 const ParameterT & value)
222 template<
typename ParameterT>
229 value = parameter_variant.
get_value<ParameterT>();
235 template<
typename ParameterT>
240 const ParameterT & alternative_value)
const 243 if (!got_parameter) {
244 value = alternative_value;
246 return got_parameter;
251 #endif // RCLCPP__NODE_IMPL_HPP_
Generic timer templated on the clock type. Periodically executes a user-specified callback...
Definition: timer.hpp:105
rclcpp::WallTimer< CallbackT >::SharedPtr create_wall_timer(std::chrono::duration< int64_t, DurationT > period, CallbackT callback, rclcpp::callback_group::CallbackGroup::SharedPtr group=nullptr)
Create a timer.
Definition: node_impl.hpp:143
std::shared_ptr< PublisherT > create_publisher(const std::string &topic_name, size_t qos_history_depth, std::shared_ptr< Alloc > allocator=nullptr)
Create and return a Publisher.
Definition: node_impl.hpp:55
Definition: client.hpp:118
Definition: allocator_common.hpp:24
bool get_parameter_or(const std::string &name, ParameterT &value, const ParameterT &alternative_value) const
Get the parameter value, or the "alternative value" if not set, and assign it to "value".
Definition: node_impl.hpp:237
void set_parameter_if_not_set(const std::string &name, const ParameterT &value)
Definition: node_impl.hpp:210
std::vector< rcl_interfaces::msg::SetParametersResult > set_parameters(const std::vector< rclcpp::parameter::ParameterVariant > ¶meters)
void register_param_change_callback(CallbackT &&callback)
Register the callback for parameter changes.
Definition: node_impl.hpp:203
std::enable_if< type==ParameterType::PARAMETER_INTEGER, int64_t >::type get_value() const
Definition: parameter.hpp:87
rclcpp::parameter::ParameterVariant get_parameter(const std::string &name) const
rcl_client_options_t rcl_client_get_default_options(void)
T dynamic_pointer_cast(T... args)
Definition: service.hpp:93
Default allocation strategy for messages received by subscriptions.
Definition: message_memory_strategy.hpp:33
std::shared_ptr< SubscriptionT > create_subscription(const std::string &topic_name, CallbackT &&callback, const rmw_qos_profile_t &qos_profile=rmw_qos_profile_default, rclcpp::callback_group::CallbackGroup::SharedPtr group=nullptr, bool ignore_local_publications=false, typename rclcpp::message_memory_strategy::MessageMemoryStrategy< MessageT, Alloc >::SharedPtr msg_mem_strat=nullptr, std::shared_ptr< Alloc > allocator=nullptr)
Create and return a Subscription.
Definition: node_impl.hpp:86
rclcpp::Client< ServiceT >::SharedPtr create_client(const std::string &service_name, const rmw_qos_profile_t &qos_profile=rmw_qos_profile_services_default, rclcpp::callback_group::CallbackGroup::SharedPtr group=nullptr)
rcl_service_options_t rcl_service_get_default_options(void)
rclcpp::Service< ServiceT >::SharedPtr create_service(const std::string &service_name, CallbackT &&callback, const rmw_qos_profile_t &qos_profile=rmw_qos_profile_services_default, rclcpp::callback_group::CallbackGroup::SharedPtr group=nullptr)
Definition: node_impl.hpp:181
Definition: client.hpp:50
Definition: service.hpp:39
Definition: any_service_callback.hpp:31
Definition: parameter.hpp:45
void set(CallbackT callback)
Definition: any_service_callback.hpp:65