CORESENSE4home_Architecture
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CognitiveModule.hpp
Go to the documentation of this file.
1// Copyright 2024 Intelligent Robotics Lab
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef CS4HOME_CORE__COGNITIVEMODULE_HPP_
16#define CS4HOME_CORE__COGNITIVEMODULE_HPP_
17
18#include <dlfcn.h>
19#include <tuple>
20#include <string>
21
23#include "cs4home_core/Core.hpp"
26#include "cs4home_core/Meta.hpp"
27
28#include "rclcpp/macros.hpp"
29#include "rclcpp/rclcpp.hpp"
30#include "rclcpp_lifecycle/lifecycle_node.hpp"
31
32namespace cs4home_core
33{
34
40class CognitiveModule : public rclcpp_lifecycle::LifecycleNode
41{
42public:
43 RCLCPP_SMART_PTR_DEFINITIONS(CognitiveModule)
44 using CallbackReturnT = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;
45
46
51 explicit CognitiveModule(
52 const std::string & name,
53 const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
54
55
61 CallbackReturnT on_configure(const rclcpp_lifecycle::State & state);
62
68 CallbackReturnT on_activate(const rclcpp_lifecycle::State & state);
69
75 CallbackReturnT on_deactivate(const rclcpp_lifecycle::State & state);
76
82 CallbackReturnT on_cleanup(const rclcpp_lifecycle::State & state);
83
89 CallbackReturnT on_shutdown(const rclcpp_lifecycle::State & state);
90
96 CallbackReturnT on_error(const rclcpp_lifecycle::State & state);
97
98protected:
99 Afferent::SharedPtr afferent_;
100 Efferent::SharedPtr efferent_;
101 Core::SharedPtr core_;
102 Meta::SharedPtr meta_;
103 Coupling::SharedPtr coupling_;
104
105 std::string core_name_;
106 std::string afferent_name_;
107 std::string efferent_name_;
108 std::string meta_name_;
109 std::string coupling_name_;
110
118 template<class T>
119 std::tuple<typename T::SharedPtr, std::string> load_component(
120 const std::string & name, rclcpp_lifecycle::LifecycleNode::SharedPtr parent);
121};
122
123} // namespace cs4home_core
124
125#endif // CS4HOME_CORE__COGNITIVEMODULE_HPP_
126
127// #include "rclcpp_components/register_node_macro.hpp"
128//
129// // Register the component with class_loader.
130// // This acts as a sort of entry point, allowing the component to be discoverable when its library
131// // is being loaded into a running process.
132// RCLCPP_COMPONENTS_REGISTER_NODE(cs4home_core::CognitiveModule)
Manages afferent processing in robotic nodes, including message handling, subscriptions,...
Definition Afferent.hpp:40
std::string coupling_name_
Name of the Coupling component.
Definition CognitiveModule.hpp:109
std::string efferent_name_
Name of the Efferent component.
Definition CognitiveModule.hpp:107
Coupling::SharedPtr coupling_
Pointer to the Coupling component.
Definition CognitiveModule.hpp:103
CallbackReturnT on_activate(const rclcpp_lifecycle::State &state)
Lifecycle transition callback for activation.
Definition CognitiveModule.cpp:115
Efferent::SharedPtr efferent_
Pointer to the Efferent component.
Definition CognitiveModule.hpp:100
Core::SharedPtr core_
Pointer to the Core component.
Definition CognitiveModule.hpp:101
CallbackReturnT on_configure(const rclcpp_lifecycle::State &state)
Lifecycle transition callback for configuration.
Definition CognitiveModule.cpp:44
CallbackReturnT on_shutdown(const rclcpp_lifecycle::State &state)
Lifecycle transition callback for shutdown.
Definition CognitiveModule.cpp:161
CallbackReturnT on_cleanup(const rclcpp_lifecycle::State &state)
Lifecycle transition callback for cleanup.
Definition CognitiveModule.cpp:149
std::string afferent_name_
Name of the Afferent component.
Definition CognitiveModule.hpp:106
std::string core_name_
Name of the Core component.
Definition CognitiveModule.hpp:105
Meta::SharedPtr meta_
Pointer to the Meta component.
Definition CognitiveModule.hpp:102
CallbackReturnT on_error(const rclcpp_lifecycle::State &state)
Lifecycle transition callback for error handling.
Definition CognitiveModule.cpp:173
Afferent::SharedPtr afferent_
Pointer to the Afferent component.
Definition CognitiveModule.hpp:99
std::string meta_name_
Name of the Meta component.
Definition CognitiveModule.hpp:108
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn CallbackReturnT
Definition CognitiveModule.hpp:44
std::tuple< typename T::SharedPtr, std::string > load_component(const std::string &name, rclcpp_lifecycle::LifecycleNode::SharedPtr parent)
Loads a specified component by name and returns a shared pointer to it.
Definition CognitiveModule.cpp:191
CallbackReturnT on_deactivate(const rclcpp_lifecycle::State &state)
Lifecycle transition callback for deactivation.
Definition CognitiveModule.cpp:132
CognitiveModule(const std::string &name, const rclcpp::NodeOptions &options=rclcpp::NodeOptions())
Constructs a CognitiveModule with the specified node options.
Definition CognitiveModule.cpp:25
Manages core functionality for a robotic component, including lifecycle transitions and connections t...
Definition Core.hpp:35
Manages coupling operations within a robotic system, providing lifecycle-aware configuration.
Definition Coupling.hpp:30
Manages efferent operations in the robotic system, including the configuration of publishers and mess...
Definition Efferent.hpp:35
Provides a meta-component for managing additional lifecycle functions within a robotic system,...
Definition Meta.hpp:30
Definition Afferent.hpp:32