C++ YASMIN (Yet Another State MachINe)
Loading...
Searching...
No Matches
yasmin_node.hpp
Go to the documentation of this file.
1// Copyright (C) 2024 Miguel Ángel González Santamarta
2//
3// This program is free software: you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16#ifndef YASMIN_ROS__YASMIN_NODE_HPP
17#define YASMIN_ROS__YASMIN_NODE_HPP
18
19#include <memory>
20#include <string>
21#include <thread>
22
23#include "rclcpp/rclcpp.hpp"
24
26#include "yasmin/state.hpp"
28
29namespace yasmin_ros {
30
38class YasminNode : public rclcpp::Node {
39
40public:
44 explicit YasminNode();
45
52 YasminNode(YasminNode &other) = delete;
53
59 void operator=(const YasminNode &) = delete;
60
65
73 static std::shared_ptr<YasminNode> get_instance() {
74 static std::shared_ptr<YasminNode> instance =
75 std::make_shared<YasminNode>();
76 return instance;
77 }
78
79private:
81 rclcpp::executors::MultiThreadedExecutor executor;
83 std::unique_ptr<std::thread> spin_thread;
84};
85
86} // namespace yasmin_ros
87
88#endif // YASMIN_ROS__YASMIN_NODE_HPP
A ROS 2 node for managing and handling YASMIN-based applications.
Definition yasmin_node.hpp:38
static std::shared_ptr< YasminNode > get_instance()
Provides access to the singleton instance of YasminNode.
Definition yasmin_node.hpp:73
YasminNode()
Default constructor. Initializes the node with a unique name.
Definition yasmin_node.cpp:49
std::unique_ptr< std::thread > spin_thread
Thread for spinning the node.
Definition yasmin_node.hpp:83
YasminNode(YasminNode &other)=delete
Deleted copy constructor to prevent copying of the singleton instance.
~YasminNode()
Destructor. Cleans up resources.
Definition yasmin_node.hpp:64
rclcpp::executors::MultiThreadedExecutor executor
Executor for managing multiple threads.
Definition yasmin_node.hpp:81
void operator=(const YasminNode &)=delete
Deleted assignment operator to enforce singleton pattern.
Definition action_state.hpp:35