Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
detection_list_viz_component.cpp
Go to the documentation of this file.
1// Copyright 2024 Leidos
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
16
17#include <rclcpp_components/register_node_macro.hpp>
18
20{
21
22DetectionListVizNode::DetectionListVizNode(const rclcpp::NodeOptions & options)
23: Node("detection_list_viz_node", options)
24{
26 create_subscription<carma_cooperative_perception_interfaces::msg::DetectionList>(
27 "input/detections_lists", 1,
28 [this](carma_cooperative_perception_interfaces::msg::DetectionList::ConstSharedPtr msg_ptr) {
29 visualization_msgs::msg::MarkerArray markers;
30
31 for (const auto detection : msg_ptr->detections) {
32 visualization_msgs::msg::Marker marker;
33
34 marker.header = detection.header;
35 marker.ns = detection.id;
36 marker.type = marker.CUBE;
37 marker.action = marker.MODIFY; // equivalent to ADD if marker does not exist
38 marker.pose = detection.pose.pose;
39 marker.scale.x = 2.0;
40 marker.scale.y = 2.0;
41 marker.scale.z = 2.0;
42
43 markers.markers.push_back(marker);
44 }
45
46 marker_pub_->publish(markers);
47 });
48
49 marker_pub_ = create_publisher<visualization_msgs::msg::MarkerArray>("output/markers", 1);
50}
51
52} // namespace carma_cooperative_perception
53
54// This is not our macro, so we should not worry about linting it.
55// clang-tidy added support for ignoring system macros in release 14.0.0 (see the release notes
56// here: https://releases.llvm.org/14.0.0/tools/clang/tools/extra/docs/ReleaseNotes.html), but
57// ament_clang_tidy for ROS 2 Foxy specifically looks for clang-tidy-6.0.
58RCLCPP_COMPONENTS_REGISTER_NODE(carma_cooperative_perception::DetectionListVizNode) // NOLINT
rclcpp::Publisher< visualization_msgs::msg::MarkerArray >::SharedPtr marker_pub_
rclcpp::Subscription< carma_cooperative_perception_interfaces::msg::DetectionList >::SharedPtr detection_list_sub_