generated from wessel/boilerplate
chore: rebase
This commit is contained in:
@@ -22,6 +22,8 @@ find_package(rclcpp REQUIRED)
|
||||
find_package(rclcpp_action REQUIRED)
|
||||
find_package(std_msgs REQUIRED)
|
||||
find_package(sensor_msgs REQUIRED)
|
||||
find_package(rclcpp_lifecycle REQUIRED)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
|
||||
add_executable(g2_2025_imu_database_writer_node
|
||||
src/g2_2025_imu_database_writer_node/Main.cpp
|
||||
@@ -29,19 +31,45 @@ add_executable(g2_2025_imu_database_writer_node
|
||||
src/config/ConfigManager.cpp
|
||||
src/g2_2025_imu_database_writer_node/nodes/IMUDatabaseWriter.cpp
|
||||
)
|
||||
|
||||
target_include_directories(g2_2025_imu_database_writer_node PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/g2_2025_imu_database_writer_node
|
||||
)
|
||||
ament_target_dependencies(g2_2025_imu_database_writer_node rclcpp sensor_msgs)
|
||||
target_link_libraries(g2_2025_imu_database_writer_node pqxx pq tomlplusplus::tomlplusplus)
|
||||
ament_target_dependencies(g2_2025_imu_database_writer_node rclcpp sensor_msgs)
|
||||
target_link_libraries(g2_2025_imu_database_writer_node pqxx pq tomlplusplus::tomlplusplus)
|
||||
|
||||
|
||||
add_executable(g2_2025_lifecycle_node
|
||||
src/g2_2025_lifecycle_node/main.cpp
|
||||
src/g2_2025_lifecycle_node/nodes/HardwareInterface.cpp
|
||||
src/g2_2025_lifecycle_node/nodes/LifecycleManager.cpp
|
||||
src/config/serialib.cpp
|
||||
)
|
||||
|
||||
target_include_directories(g2_2025_lifecycle_node PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/g2_2025_lifecycle_node
|
||||
)
|
||||
ament_target_dependencies(g2_2025_lifecycle_node rclcpp rclcpp_lifecycle std_msgs sensor_msgs)
|
||||
|
||||
target_link_libraries(g2_2025_lifecycle_node
|
||||
paho-mqttpp3
|
||||
paho-mqtt3a
|
||||
nlohmann_json::nlohmann_json
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
g2_2025_imu_database_writer_node
|
||||
g2_2025_lifecycle_node
|
||||
DESTINATION lib/${PROJECT_NAME}
|
||||
)
|
||||
|
||||
set_target_properties(g2_2025_lifecycle_node PROPERTIES INSTALL_RPATH "/usr/local/lib")
|
||||
|
||||
if(BUILD_TESTING)
|
||||
find_package(ament_cmake_gtest REQUIRED)
|
||||
|
||||
@@ -95,6 +123,30 @@ if(BUILD_TESTING)
|
||||
pqxx pq tomlplusplus::tomlplusplus
|
||||
)
|
||||
|
||||
ament_add_gtest(${PROJECT_NAME}_test_lifecycle_manager
|
||||
test/LifecycleManager.test.cpp
|
||||
src/g2_2025_lifecycle_node/nodes/lifecycle_manager.cpp
|
||||
src/g2_2025_lifecycle_node/nodes/hardware_interface.cpp
|
||||
src/config/serialib.cpp
|
||||
)
|
||||
target_include_directories(${PROJECT_NAME}_test_lifecycle_manager PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/g2_2025_lifecycle_node
|
||||
)
|
||||
ament_target_dependencies(${PROJECT_NAME}_test_lifecycle_manager
|
||||
rclcpp
|
||||
rclcpp_lifecycle
|
||||
std_msgs
|
||||
sensor_msgs
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME}_test_lifecycle_manager
|
||||
paho-mqttpp3
|
||||
paho-mqtt3a
|
||||
nlohmann_json::nlohmann_json
|
||||
)
|
||||
set_target_properties(${PROJECT_NAME}_test_lifecycle_manager PROPERTIES INSTALL_RPATH "/usr/local/lib")
|
||||
|
||||
|
||||
# Add Python integration tests
|
||||
# find_package(ament_cmake_pytest REQUIRED)
|
||||
# ament_add_pytest_test(${PROJECT_NAME}_integration_test test/test_integration_system.py
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/* main.cpp
|
||||
* Entry point for lifecycle node
|
||||
*
|
||||
* Reviewed by: <x>
|
||||
* Changelog:
|
||||
* [23-09-2025] Wessel T: Simplified main.cpp to entry point only
|
||||
*/
|
||||
|
||||
#include "rclcpp/rclcpp.hpp"
|
||||
#include "nodes/hardware_interface.hpp"
|
||||
#include "nodes/lifecycle_manager.hpp"
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
rclcpp::init(argc, argv);
|
||||
|
||||
auto node = std::make_shared<assignments::two::g2_2025_lifecycle_node::LifecycleManager>();
|
||||
|
||||
rclcpp::spin(node->get_node_base_interface());
|
||||
rclcpp::shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "hardware_interface.hpp"
|
||||
|
||||
namespace assignments::two::g2_2025_lifecycle_node {
|
||||
|
||||
HardwareInterface::HardwareInterface() : Node("hardware_interface") {
|
||||
RCLCPP_INFO(this->get_logger(), "HardwareInterface node has been created");
|
||||
|
||||
}
|
||||
|
||||
void HardwareInterface::some_hardware_method() {
|
||||
RCLCPP_INFO(this->get_logger(), "Interacting with hardware...");
|
||||
}
|
||||
|
||||
} // namespace assignments::two::g2_2025_lifecycle_node
|
||||
@@ -0,0 +1,31 @@
|
||||
/* nodes/hardware_interface.hpp
|
||||
* Hardware interface implementation for the IMU reader system.
|
||||
*
|
||||
* Manages the serial communication with the IMU hardware, including initialization,
|
||||
* data acquisition, and shutdown procedures.
|
||||
*
|
||||
* Changelog:
|
||||
* [28-10-2025] M.khalaf: Implemented template.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
|
||||
#include "rclcpp/rclcpp.hpp"
|
||||
#include "rclcpp_lifecycle/lifecycle_node.hpp"
|
||||
|
||||
namespace assignments::two::g2_2025_lifecycle_node {
|
||||
|
||||
class HardwareInterface : public rclcpp::Node {
|
||||
|
||||
public:
|
||||
HardwareInterface();
|
||||
private:
|
||||
void some_hardware_method();
|
||||
|
||||
};
|
||||
} // namespace assignments::two::g2_2025_lifecycle_node
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "lifecycle_manager.hpp"
|
||||
|
||||
|
||||
namespace assignments::two::g2_2025_lifecycle_node {
|
||||
|
||||
LifecycleManager::LifecycleManager() : rclcpp_lifecycle::LifecycleNode("lifecycle_manager") {
|
||||
|
||||
|
||||
RCLCPP_INFO(this->get_logger(), "LifecycleManager node is ready");
|
||||
imu_publisher = this->create_publisher<std_msgs::msg::String>("imu_data", 10);
|
||||
RCLCPP_INFO(this->get_logger(), "IMU Publisher has been created");
|
||||
|
||||
|
||||
}
|
||||
|
||||
void LifecycleManager::publish_imu_data(const std::string & data) {
|
||||
auto message = std_msgs::msg::String();
|
||||
message.data = data;
|
||||
imu_publisher->publish(message);
|
||||
RCLCPP_INFO(this->get_logger(), "Published IMU data: %s", data.c_str());
|
||||
}
|
||||
|
||||
void LifecycleManager::Unconfigured() {
|
||||
RCLCPP_INFO(this->get_logger(), "Managing lifecycle...");
|
||||
|
||||
}
|
||||
|
||||
} // namespace assignments::two::g2_2025_lifecycle_node
|
||||
@@ -0,0 +1,33 @@
|
||||
/* nodes/lifecycle_manager.hpp
|
||||
* Lifecycle node implementation for managing the lifecycle of the IMU reader system.
|
||||
*
|
||||
* Manages the different states of the lifecycle node, including configuration,
|
||||
* and hardware interface management.
|
||||
*
|
||||
* Changelog:
|
||||
* [28-10-2025] M.khalaf: Implemented template.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
|
||||
#include "rclcpp/rclcpp.hpp"
|
||||
#include "rclcpp_lifecycle/lifecycle_node.hpp"
|
||||
#include "std_msgs/msg/string.hpp"
|
||||
|
||||
|
||||
namespace assignments::two::g2_2025_lifecycle_node {
|
||||
class LifecycleManager : public rclcpp_lifecycle::LifecycleNode {
|
||||
public:
|
||||
LifecycleManager();
|
||||
private:
|
||||
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr imu_publisher;
|
||||
void publish_imu_data(const std::string & data);
|
||||
void Unconfigured();
|
||||
|
||||
};
|
||||
} // namespace assignments::two::g2_2025_lifecycle_node
|
||||
Reference in New Issue
Block a user