CORESENSE4home_Architecture
|
#include <optional>
#include "sensor_msgs/msg/image.hpp"
#include "vision_msgs/msg/detection2_d_array.hpp"
#include "lifecycle_msgs/msg/state.hpp"
#include "ament_index_cpp/get_package_share_directory.hpp"
#include "cs4home_core/Afferent.hpp"
#include "cs4home_core/CognitiveModule.hpp"
#include "gtest/gtest.h"
Functions | |
template<class T> | |
std::tuple< typename T::SharedPtr, std::string > | load_component (const std::string &name, rclcpp_lifecycle::LifecycleNode::SharedPtr parent) |
Loads a ROS 2 component dynamically. | |
int | main (int argc, char **argv) |
TEST (cognitive_module_test, afferent_on_demand) | |
TEST (cognitive_module_test, afferent_on_subscription) | |
TEST (cognitive_module_test, core) | |
TEST (cognitive_module_test, core_cb) | |
TEST (cognitive_module_test, efferent) | |
TEST (cognitive_module_test, startup_simple) | |
std::tuple< typename T::SharedPtr, std::string > load_component | ( | const std::string & | name, |
rclcpp_lifecycle::LifecycleNode::SharedPtr | parent ) |
Loads a ROS 2 component dynamically.
T | Component type. |
name | Component library name. |
parent | Lifecycle node parent for the component. |
int main | ( | int | argc, |
char ** | argv ) |
TEST | ( | cognitive_module_test | , |
afferent_on_demand | ) |
This test sets up an afferent component to operate in "on demand" mode, where it retrieves messages from a queue rather than processing them immediately via a callback. Messages are published to a topic, and the afferent component is configured to pull messages from this queue as needed. The test ensures that the messages are correctly retrieved in order and that once the queue is empty, further retrievals return nullptr
.
TEST | ( | cognitive_module_test | , |
afferent_on_subscription | ) |
This test sets up an afferent component to operate in callback mode, where it subscribes to a topic and processes incoming messages by storing them in a vector for verification. The component listens to /image
messages and ensures that all received messages are processed and accessible through the callback mechanism.
TEST | ( | cognitive_module_test | , |
core | ) |
This test sets up an afferent component to receive messages, a core component to process them by doubling the frame_id
in each message header, and an efferent component to republish the processed messages. The test publishes a series of messages, each with a sequential frame_id
, and verifies that the processed messages in the efferent component have doubled frame_id
values.
TEST | ( | cognitive_module_test | , |
core_cb | ) |
frame_id
values.This test sets up an afferent component in callback mode to receive messages, a core component with a callback (core_cb
) to process the messages by doubling the frame_id
in each message header, and an efferent component to republish the processed messages. The test publishes a sequence of messages and verifies that the processed messages have doubled frame_id
values.
TEST | ( | cognitive_module_test | , |
efferent | ) |
This test sets up an efferent component to publish messages on a specified topic. It publishes a series of messages with sequential frame_id
values and verifies that these messages are received correctly by a subscriber on the same topic. The test ensures that the efferent component is able to correctly configure its publishers and transmit messages to external listeners.
TEST | ( | cognitive_module_test | , |
startup_simple | ) |
This test verifies that the CognitiveModule initializes correctly from a configuration file and transitions through the ROS 2 lifecycle states (configure, activate, deactivate). It sets up publishers and subscribers to check that messages are processed with expected modifications (doubling of frame_id
) and are received correctly after processing.