27{
28 RCLCPP_INFO(get_logger(), "Lifecycle transition: configuring");
29
31 carma_cooperative_perception_interfaces::msg::DetectionList>(
32 "input/detection_list", 1,
33 [this](const carma_cooperative_perception_interfaces::msg::DetectionList::SharedPtr msg_ptr) {
34 if (const auto current_state{this->get_current_state().label()}; current_state == "active") {
36 } else {
37 RCLCPP_WARN(
38 this->get_logger(),
39 "Trying to receive message on the topic '%s', but the containing node is not activated. "
40 "Current node state: '%s'",
42 }
43 });
44
46 "input/host_vehicle_pose", 1, [this](const geometry_msgs::msg::PoseStamped::SharedPtr msg_ptr) {
47 if (const auto current_state{this->get_current_state().label()}; current_state == "active") {
49 } else {
50 RCLCPP_WARN(
51 this->get_logger(),
52 "Trying to receive message on the topic '%s', but the containing node is not activated. "
53 "Current node state: '%s'",
55 }
56 });
57
59 create_publisher<carma_cooperative_perception_interfaces::msg::DetectionList>(
60 "output/detection_list", 1);
61
62 RCLCPP_INFO(get_logger(), "Lifecycle transition: successfully configured");
63
65 add_on_set_parameters_callback([this](const std::vector<rclcpp::Parameter> & parameters) {
66 rcl_interfaces::msg::SetParametersResult result;
67 result.successful = true;
68 result.reason = "success";
69
70 for (const auto & parameter : parameters) {
71 if (parameter.get_name() == "distance_threshold_meters") {
72 if (this->get_current_state().label() == "active") {
73 result.successful = false;
74 result.reason = "parameter is read-only while node is in 'Active' state";
75
76 RCLCPP_ERROR(
77 get_logger(),
78 "Cannot change parameter 'distance_threshold_meters': " + result.reason);
79
80 break;
81 }
82
83 if (const auto value{parameter.as_double()}; value < 0) {
84 result.successful = false;
85 result.reason = "parameter must be nonnegative";
86
87 RCLCPP_ERROR(
88 get_logger(),
89 "Cannot change parameter 'distance_threshold_meters': " + result.reason);
90
91 break;
92 } else {
94 }
95 } else {
96 result.successful = false;
97 result.reason = "Unexpected parameter name '" + parameter.get_name() + '\'';
98 break;
99 }
100 }
101
102 return result;
103 });
104
105 declare_parameter("distance_threshold_meters", 0.0);
106
107 return carma_ros2_utils::CallbackReturn::SUCCESS;
108}
OnSetParametersCallbackHandle::SharedPtr on_set_parameters_callback_
auto attempt_filter_and_republish(carma_cooperative_perception_interfaces::msg::DetectionList msg) -> void
auto update_host_vehicle_pose(const geometry_msgs::msg::PoseStamped &msg) -> void