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
23class Node {
24
25protected:
31 explicit Node(const std::string& node_name, const rclcpp::NodeOptions& options = rclcpp::NodeOptions()) : node_(std::make_shared<rclcpp::Node>(node_name, options)) {
32 }
33
39 explicit Node(const std::string& node_name, const std::string& namespace_, const rclcpp::NodeOptions& options = rclcpp::NodeOptions())
40 : node_(std::make_shared<rclcpp::Node>(node_name, namespace_, options)) {
41 }
42
43 ~Node() = default;
44 Node(const Node&) = delete;
45 Node& operator=(const Node&) = delete;
46 Node(Node&&) = delete;
47 Node& operator=(Node&&) = delete;
48
52 [[nodiscard]] rclcpp::Node& this_node() noexcept {
53 return *node_;
54 }
58 [[nodiscard]] const rclcpp::Node& this_node() const noexcept {
59 return *node_;
60 }
64 [[nodiscard]] rclcpp::Node::SharedPtr this_node_ptr() const noexcept {
65 return node_;
66 }
67
68public:
74 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_base_interface() {
75 return node_->get_node_base_interface();
76 }
77
78private:
79 rclcpp::Node::SharedPtr node_;
80};
81
82} // namespace mrs_lib
Wrapper class around rclcpp::Node providing interface required for components.
Definition node.h:23
rclcpp::Node::SharedPtr this_node_ptr() const noexcept
Get shared pointer to the underlying rclcpp::Node.
Definition node.h:64
Node(const std::string &node_name, const rclcpp::NodeOptions &options=rclcpp::NodeOptions())
Constructs the underlying node with the given parameters.
Definition node.h:31
const rclcpp::Node & this_node() const noexcept
Get reference to the underlying rclcpp::Node.
Definition node.h:58
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_base_interface()
Definition node.h:74
rclcpp::Node & this_node() noexcept
Get reference to the underlying rclcpp::Node.
Definition node.h:52
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:39
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition attitude_converter.h:24