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.
bounding_box_to_detected_object_node.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 LEIDOS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
17#include <geometry/bounding_box/bounding_box_common.hpp>
18
20
21 using std::placeholders::_1;
22 using std::placeholders::_2;
23 using std::placeholders::_3;
24
25 Node::Node(const rclcpp::NodeOptions& options)
26 : carma_ros2_utils::CarmaLifecycleNode(options)
27 {
28 }
29
30 carma_ros2_utils::CallbackReturn Node::handle_on_configure(const rclcpp_lifecycle::State &) {
31
32 // Setup pub/sub
33 bbox_sub_= create_subscription<autoware_auto_msgs::msg::BoundingBoxArray>("bounding_boxes",10,
34 std::bind(&Node::bbox_callback, this, _1)
35 );
36
37 object_pub_= create_publisher<autoware_auto_msgs::msg::DetectedObjects>("lidar_detected_objects", 10);
38
39 return CallbackReturn::SUCCESS;
40 }
41
42 autoware_auto_msgs::msg::DetectedObject detected_obj_from_bounding_box(const autoware_auto_msgs::msg::BoundingBox& box) {
43
44 autoware_auto_msgs::msg::DetectedObject obj;
45
46 // The following method currently does not properly set the orientation
47 // so that will be set manually following this call
48 obj = autoware::common::geometry::bounding_box::details::make_detected_object(box);
49
50 obj.kinematics.orientation.x = box.orientation.x;
51 obj.kinematics.orientation.y = box.orientation.y;
52 obj.kinematics.orientation.z = box.orientation.z;
53 obj.kinematics.orientation.w = box.orientation.w;
54 obj.kinematics.orientation_availability = autoware_auto_msgs::msg::DetectedObjectKinematics::SIGN_UNKNOWN;
55
56 return obj;
57
58 }
59
60 void Node::bbox_callback(autoware_auto_msgs::msg::BoundingBoxArray::UniquePtr msg) {
61 autoware_auto_msgs::msg::DetectedObjects objects;
62
63 objects.header = msg->header;
64 objects.objects.reserve(msg->boxes.size());
65
66 for (const auto& bb : msg->boxes) {
67 objects.objects.emplace_back(detected_obj_from_bounding_box(bb));
68 }
69
70 object_pub_->publish(objects);
71
72 }
73
74
75}//bounding_box_to_detected_object
76
77#include "rclcpp_components/register_node_macro.hpp"
78
79// Register the component with class_loader
80RCLCPP_COMPONENTS_REGISTER_NODE(bounding_box_to_detected_object::Node)
void bbox_callback(autoware_auto_msgs::msg::BoundingBoxArray::UniquePtr msg)
Callback for bounding box data to be converted. Publishes a DetectedObjects message from the bounding...
carma_ros2_utils::PubPtr< autoware_auto_msgs::msg::DetectedObjects > object_pub_
carma_ros2_utils::SubPtr< autoware_auto_msgs::msg::BoundingBoxArray > bbox_sub_
carma_ros2_utils::CallbackReturn handle_on_configure(const rclcpp_lifecycle::State &)
autoware_auto_msgs::msg::DetectedObject detected_obj_from_bounding_box(const autoware_auto_msgs::msg::BoundingBox &box)