forked from autowarefoundation/autoware.universe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lidar_centerpoint): single inference lidar centerpoint node (aut…
…owarefoundation#1926) * Eliminating the tf dependence when using single frame detection. Untested Signed-off-by: Kenzo Lobos-Tsunekawa <kenzo.lobos@tier4.jp> * Implemented a node to run single inferences with lidar centerpoint Signed-off-by: Kenzo Lobos-Tsunekawa <kenzo.lobos@tier4.jp> * feat(lidar_centerpoint): single inference lidar centerpoint node Signed-off-by: Kenzo Lobos-Tsunekawa <kenzo.lobos@tier4.jp> * Exiting program after the single inference Added the visualization script Addded a small section in the documentation Signed-off-by: Kenzo Lobos-Tsunekawa <kenzo.lobos@tier4.jp> * Updated the node to reflect recent changes in the main branch Signed-off-by: Kenzo Lobos-Tsunekawa <kenzo.lobos@tier4.jp> * Update perception/lidar_centerpoint/scripts/visualize_resuls.py Co-authored-by: Yusuke Muramatsu <yukke42@users.noreply.github.com> * Update perception/lidar_centerpoint/scripts/visualize_resuls.py Co-authored-by: Yusuke Muramatsu <yukke42@users.noreply.github.com> * Update perception/lidar_centerpoint/scripts/visualize_resuls.py Co-authored-by: Yusuke Muramatsu <yukke42@users.noreply.github.com> * Moved the viz script into the launcher and it is now executed automatically Signed-off-by: Kenzo Lobos-Tsunekawa <kenzo.lobos@tier4.jp> * Update perception/lidar_centerpoint/src/single_inference_node.cpp Co-authored-by: Yusuke Muramatsu <yukke42@users.noreply.github.com> * Update perception/lidar_centerpoint/src/single_inference_node.cpp Co-authored-by: Yusuke Muramatsu <yukke42@users.noreply.github.com> * Update perception/lidar_centerpoint/scripts/lidar_centerpoint_visualizer.py Co-authored-by: Yusuke Muramatsu <yukke42@users.noreply.github.com> * Update perception/lidar_centerpoint/README.md Co-authored-by: Yusuke Muramatsu <yukke42@users.noreply.github.com> * Added documentation for the new visualization script Signed-off-by: Kenzo Lobos-Tsunekawa <kenzo.lobos@tier4.jp> * Updating license Signed-off-by: Kenzo Lobos-Tsunekawa <kenzo.lobos@tier4.jp> * Update perception/lidar_centerpoint/scripts/lidar_centerpoint_visualizer.py Co-authored-by: Yusuke Muramatsu <yukke42@users.noreply.github.com> * Apply suggestions from code review Signed-off-by: Kenzo Lobos-Tsunekawa <kenzo.lobos@tier4.jp> Co-authored-by: Yusuke Muramatsu <yukke42@users.noreply.github.com> Signed-off-by: Kotaro Yoshimoto <pythagora.yoshimoto@gmail.com>
- Loading branch information
Showing
7 changed files
with
438 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
perception/lidar_centerpoint/include/lidar_centerpoint/single_inference_node.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2022 TIER IV, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef LIDAR_CENTERPOINT__SINGLE_INFERENCE_NODE_HPP_ | ||
#define LIDAR_CENTERPOINT__SINGLE_INFERENCE_NODE_HPP_ | ||
|
||
#include <Eigen/Core> | ||
#include <lidar_centerpoint/centerpoint_trt.hpp> | ||
#include <lidar_centerpoint/detection_class_remapper.hpp> | ||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <autoware_auto_perception_msgs/msg/detected_object_kinematics.hpp> | ||
#include <autoware_auto_perception_msgs/msg/detected_objects.hpp> | ||
#include <autoware_auto_perception_msgs/msg/object_classification.hpp> | ||
#include <autoware_auto_perception_msgs/msg/shape.hpp> | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace centerpoint | ||
{ | ||
|
||
class SingleInferenceLidarCenterPointNode : public rclcpp::Node | ||
{ | ||
public: | ||
explicit SingleInferenceLidarCenterPointNode(const rclcpp::NodeOptions & node_options); | ||
|
||
private: | ||
void detect(const std::string & pcd_path, const std::string & detections_path); | ||
std::vector<Eigen::Vector3d> getVertices( | ||
const autoware_auto_perception_msgs::msg::Shape & shape, const Eigen::Affine3d & pose) const; | ||
void dumpDetectionsAsMesh( | ||
const autoware_auto_perception_msgs::msg::DetectedObjects & objects_msg, | ||
const std::string & output_path) const; | ||
|
||
tf2_ros::Buffer tf_buffer_; | ||
tf2_ros::TransformListener tf_listener_{tf_buffer_}; | ||
|
||
float score_threshold_{0.0}; | ||
std::vector<std::string> class_names_; | ||
bool rename_car_to_truck_and_bus_{false}; | ||
bool has_twist_{false}; | ||
|
||
DetectionClassRemapper detection_class_remapper_; | ||
|
||
std::unique_ptr<CenterPointTRT> detector_ptr_{nullptr}; | ||
}; | ||
|
||
} // namespace centerpoint | ||
|
||
#endif // LIDAR_CENTERPOINT__SINGLE_INFERENCE_NODE_HPP_ |
35 changes: 35 additions & 0 deletions
35
perception/lidar_centerpoint/launch/single_inference_lidar_centerpoint.launch.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0"?> | ||
<launch> | ||
<arg name="model_name" default="centerpoint_tiny" description="options: `centerpoint` or `centerpoint_tiny`"/> | ||
<arg name="model_path" default="$(find-pkg-share lidar_centerpoint)/data"/> | ||
<arg name="model_param_path" default="$(find-pkg-share lidar_centerpoint)/config/$(var model_name).param.yaml"/> | ||
<arg name="class_remapper_param_path" default="$(find-pkg-share lidar_centerpoint)/config/detection_class_remapper.param.yaml"/> | ||
<arg name="score_threshold" default="0.35"/> | ||
<arg name="yaw_norm_threshold" default="0.0"/> | ||
<arg name="has_twist" default="false"/> | ||
<arg name="pcd_path" default="test.pcd"/> | ||
<arg name="detections_path" default="test.ply"/> | ||
|
||
<node pkg="lidar_centerpoint" exec="single_inference_lidar_centerpoint_node" name="lidar_centerpoint" output="screen"> | ||
<param name="score_threshold" value="$(var score_threshold)"/> | ||
<param name="yaw_norm_threshold" value="$(var yaw_norm_threshold)"/> | ||
<param name="densification_world_frame_id" value="map"/> | ||
<param name="densification_num_past_frames" value="0"/> | ||
<param name="trt_precision" value="fp16"/> | ||
<param name="has_twist" value="$(var has_twist)"/> | ||
<param name="encoder_onnx_path" value="$(var model_path)/pts_voxel_encoder_$(var model_name).onnx"/> | ||
<param name="encoder_engine_path" value="$(var model_path)/pts_voxel_encoder_$(var model_name).engine"/> | ||
<param name="head_onnx_path" value="$(var model_path)/pts_backbone_neck_head_$(var model_name).onnx"/> | ||
<param name="head_engine_path" value="$(var model_path)/pts_backbone_neck_head_$(var model_name).engine"/> | ||
<param from="$(var model_param_path)"/> | ||
<param from="$(var class_remapper_param_path)"/> | ||
|
||
<param name="pcd_path" value="$(var pcd_path)"/> | ||
<param name="detections_path" value="$(var detections_path)"/> | ||
</node> | ||
|
||
<node pkg="lidar_centerpoint" exec="lidar_centerpoint_visualizer.py" name="lidar_centerpoint_visualizer" output="screen"> | ||
<param name="pcd_path" value="$(var pcd_path)"/> | ||
<param name="detections_path" value="$(var detections_path)"/> | ||
</node> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
perception/lidar_centerpoint/scripts/lidar_centerpoint_visualizer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python | ||
# Copyright 2022 TIER IV, Inc. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
import time | ||
|
||
import open3d as o3d | ||
import rclpy | ||
from rclpy.node import Node | ||
|
||
|
||
def main(args=None): | ||
|
||
rclpy.init(args=args) | ||
|
||
node = Node("lidar_centerpoint_visualizer") | ||
node.declare_parameter("pcd_path", rclpy.Parameter.Type.STRING) | ||
node.declare_parameter("detections_path", rclpy.Parameter.Type.STRING) | ||
|
||
pcd_path = node.get_parameter("pcd_path").get_parameter_value().string_value | ||
detections_path = node.get_parameter("detections_path").get_parameter_value().string_value | ||
|
||
while not os.path.exists(pcd_path) and not os.path.exists(detections_path): | ||
time.sleep(1.0) | ||
|
||
if not rclpy.ok(): | ||
rclpy.shutdown() | ||
return | ||
|
||
mesh = o3d.io.read_triangle_mesh(detections_path) | ||
pcd = o3d.io.read_point_cloud(pcd_path) | ||
|
||
mesh_frame = o3d.geometry.TriangleMesh.create_coordinate_frame(size=1.0, origin=[0, 0, 0]) | ||
|
||
detection_lines = o3d.geometry.LineSet.create_from_triangle_mesh(mesh) | ||
detection_lines.paint_uniform_color([1.0, 0.0, 1.0]) | ||
|
||
o3d.visualization.draw_geometries([mesh_frame, pcd, detection_lines]) | ||
|
||
rclpy.shutdown() | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
main() |
Oops, something went wrong.