mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
Loading...
Searching...
No Matches
node.h
1#pragma once
2
3#include <memory>
4#include <string>
5
6#include <rclcpp/rclcpp.hpp>
7
8namespace mrs_lib
9{
10
23 class Node
24 {
25
26 protected:
32 explicit Node(const std::string& node_name, const rclcpp::NodeOptions& options = rclcpp::NodeOptions())
33 : node_(std::make_shared<rclcpp::Node>(node_name, options))
34 {
35 }
36
42 explicit Node(const std::string& node_name, const std::string& namespace_, const rclcpp::NodeOptions& options = rclcpp::NodeOptions())
43 : node_(std::make_shared<rclcpp::Node>(node_name, namespace_, options))
44 {
45 }
46
47 ~Node() = default;
48 Node(const Node&) = delete;
49 Node& operator=(const Node&) = delete;
50 Node(Node&&) = delete;
51 Node& operator=(Node&&) = delete;
52
56 [[nodiscard]] rclcpp::Node& this_node() noexcept
57 {
58 return *node_;
59 }
63 [[nodiscard]] const rclcpp::Node& this_node() const noexcept
64 {
65 return *node_;
66 }
70 [[nodiscard]] rclcpp::Node::SharedPtr this_node_ptr() const noexcept
71 {
72 return node_;
73 }
74
75 public:
81 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_base_interface()
82 {
83 return node_->get_node_base_interface();
84 }
85
86 private:
87 rclcpp::Node::SharedPtr node_;
88 };
89
90} // namespace mrs_lib
Wrapper class around rclcpp::Node providing interface required for components.
Definition node.h:24
rclcpp::Node::SharedPtr this_node_ptr() const noexcept
Get shared pointer to the underlying rclcpp::Node.
Definition node.h:70
Node(const std::string &node_name, const rclcpp::NodeOptions &options=rclcpp::NodeOptions())
Constructs the underlying node with the given parameters.
Definition node.h:32
const rclcpp::Node & this_node() const noexcept
Get reference to the underlying rclcpp::Node.
Definition node.h:63
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_base_interface()
Definition node.h:81
rclcpp::Node & this_node() noexcept
Get reference to the underlying rclcpp::Node.
Definition node.h:56
Node(const std::string &node_name, const std::string &namespace_, const rclcpp::NodeOptions &options=rclcpp::NodeOptions())
Constructs the underlying node with the given parameters.
Definition node.h:42
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition attitude_converter.h:24