15#ifndef CARMA_COOPERATIVE_PERCEPTION__SDSM_TO_DETECTION_LIST_COMPONENT_HPP_
16#define CARMA_COOPERATIVE_PERCEPTION__SDSM_TO_DETECTION_LIST_COMPONENT_HPP_
20#include <carma_cooperative_perception_interfaces/msg/detection_list.hpp>
21#include <carma_ros2_utils/carma_lifecycle_node.hpp>
22#include <carma_v2x_msgs/msg/sensor_data_sharing_message.hpp>
23#include <rclcpp/rclcpp.hpp>
24#include <rosgraph_msgs/msg/clock.hpp>
25#include <std_msgs/msg/string.hpp>
35 using output_msg_type = carma_cooperative_perception_interfaces::msg::DetectionList;
39 : CarmaLifecycleNode{options},
43 georeference_subscription_{create_subscription<std_msgs::msg::String>(
44 "input/georeference", 1,
45 [
this](std_msgs::msg::String::SharedPtr msg_ptr) { georeference_ = msg_ptr->data; })},
46 cdasim_clock_sub_{create_subscription<rosgraph_msgs::msg::Clock>(
47 "input/cdasim_clock", 1, [
this](rosgraph_msgs::msg::Clock::ConstSharedPtr msg_ptr) {
48 cdasim_time_ = msg_ptr->clock;
60 const auto time_delta{now() - cdasim_time_.value()};
62 for (
auto & detection : detection_list_msg.detections) {
63 detection.header.stamp = rclcpp::Time(detection.header.stamp) + time_delta;
67 publisher_->publish(detection_list_msg);
68 }
catch (
const std::runtime_error & e) {
69 RCLCPP_ERROR_STREAM(get_logger(),
"Failed to convert SDSM to detection list: " << e.what());
74 rclcpp::Publisher<output_msg_type>::SharedPtr
publisher_;
79 std::optional<rclcpp::Time> cdasim_time_{std::nullopt};
81 std::string georeference_{
""};
rclcpp::Subscription< input_msg_type >::SharedPtr subscription_
carma_cooperative_perception_interfaces::msg::DetectionList output_msg_type
carma_v2x_msgs::msg::SensorDataSharingMessage input_msg_type
rclcpp::Subscription< std_msgs::msg::String >::SharedPtr georeference_subscription_
SdsmToDetectionListNode(const rclcpp::NodeOptions &options)
rclcpp::Publisher< output_msg_type >::SharedPtr publisher_
rclcpp::Subscription< rosgraph_msgs::msg::Clock >::SharedPtr cdasim_clock_sub_
auto sdsm_msg_callback(const input_msg_type &msg) const -> void
typename input_msg_type::SharedPtr input_msg_shared_pointer
auto to_detection_list_msg(const carma_v2x_msgs::msg::SensorDataSharingMessage &sdsm, std::string_view georeference) -> carma_cooperative_perception_interfaces::msg::DetectionList