15 #ifndef RCLCPP__NODE_IMPL_HPP_ 16 #define RCLCPP__NODE_IMPL_HPP_ 36 #include "rcl_interfaces/msg/intra_process_message.hpp" 47 #ifndef RCLCPP__NODE_HPP_ 54 template<
typename MessageT,
typename Alloc,
typename PublisherT>
57 const std::string & topic_name,
size_t qos_history_depth,
61 allocator = std::make_shared<Alloc>();
64 qos.
depth = qos_history_depth;
65 return this->create_publisher<MessageT, Alloc, PublisherT>(topic_name, qos, allocator);
68 template<
typename MessageT,
typename Alloc,
typename PublisherT>
75 allocator = std::make_shared<Alloc>();
77 return rclcpp::create_publisher<MessageT, Alloc, PublisherT>(
78 this->node_topics_.get(),
81 use_intra_process_comms_,
89 typename SubscriptionT>
93 CallbackT && callback,
95 rclcpp::callback_group::CallbackGroup::SharedPtr group,
96 bool ignore_local_publications,
105 allocator = std::make_shared<Alloc>();
108 if (!msg_mem_strat) {
113 return rclcpp::create_subscription<MessageT, CallbackT, Alloc, CallbackMessageT, SubscriptionT>(
114 this->node_topics_.get(),
116 std::forward<CallbackT>(callback),
119 ignore_local_publications,
120 use_intra_process_comms_,
129 typename SubscriptionT>
133 CallbackT && callback,
134 size_t qos_history_depth,
135 rclcpp::callback_group::CallbackGroup::SharedPtr group,
136 bool ignore_local_publications,
143 qos.
depth = qos_history_depth;
144 return this->create_subscription<MessageT>(
146 std::forward<CallbackT>(callback),
149 ignore_local_publications,
154 template<
typename DurationT,
typename CallbackT>
159 rclcpp::callback_group::CallbackGroup::SharedPtr group)
162 std::chrono::duration_cast<std::chrono::nanoseconds>(period),
164 node_timers_->add_timer(timer, group);
168 template<
typename ServiceT>
173 rclcpp::callback_group::CallbackGroup::SharedPtr group)
176 options.
qos = qos_profile;
188 node_services_->add_client(cli_base_ptr, group);
192 template<
typename ServiceT,
typename CallbackT>
196 CallbackT && callback,
198 rclcpp::callback_group::CallbackGroup::SharedPtr group)
200 return rclcpp::create_service<ServiceT, CallbackT>(
201 node_base_, node_services_,
202 service_name, std::forward<CallbackT>(callback), qos_profile, group);
205 template<
typename CallbackT>
209 this->node_parameters_->register_param_change_callback(std::forward<CallbackT>(callback));
212 template<
typename ParameterT>
216 const ParameterT & value)
226 template<
typename ParameterT>
233 value = parameter.
get_value<ParameterT>();
239 template<
typename ParameterT>
244 const ParameterT & alternative_value)
const 247 if (!got_parameter) {
248 value = alternative_value;
250 return got_parameter;
255 #endif // RCLCPP__NODE_IMPL_HPP_ decltype(auto) get_value() const
Get value of parameter using rclcpp::ParameterType as template argument.
Definition: parameter.hpp:66
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:156
static SharedPtr create_default()
Default factory method.
Definition: message_memory_strategy.hpp:73
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:56
Definition: client.hpp:118
Definition: allocator_common.hpp:24
Structure to store an arbitrary parameter with templated get/set methods.
Definition: parameter.hpp:32
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:241
void set_parameter_if_not_set(const std::string &name, const ParameterT &value)
Definition: node_impl.hpp:214
void register_param_change_callback(CallbackT &&callback)
Register the callback for parameter changes.
Definition: node_impl.hpp:207
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< typename rclcpp::subscription_traits::has_message_type< CallbackT >::type, Alloc >::SharedPtr msg_mem_strat=nullptr, std::shared_ptr< Alloc > allocator=nullptr)
Create and return a Subscription.
Definition: node_impl.hpp:91
rcl_client_options_t rcl_client_get_default_options(void)
T dynamic_pointer_cast(T... args)
Definition: service.hpp:88
Default allocation strategy for messages received by subscriptions.
Definition: message_memory_strategy.hpp:38
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)
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:194
rclcpp::Parameter get_parameter(const std::string &name) const
Definition: client.hpp:52
std::vector< rcl_interfaces::msg::SetParametersResult > set_parameters(const std::vector< rclcpp::Parameter > ¶meters)