Skip to content

Commit e3f5099

Browse files
authored
revert: "feat(lidar_transfusion): update TransFusion-L model" (#1478)
Revert "feat(lidar_transfusion): update TransFusion-L model"
1 parent 4a0a76a commit e3f5099

24 files changed

+115
-1542
lines changed

perception/lidar_transfusion/CMakeLists.txt

-52
Original file line numberDiff line numberDiff line change
@@ -137,58 +137,6 @@ if(TRT_AVAIL AND CUDA_AVAIL AND CUDNN_AVAIL)
137137
if(BUILD_TESTING)
138138
find_package(ament_lint_auto REQUIRED)
139139
ament_lint_auto_find_test_dependencies()
140-
141-
find_package(ament_cmake_gtest REQUIRED)
142-
ament_auto_add_gtest(test_detection_class_remapper
143-
test/test_detection_class_remapper.cpp
144-
)
145-
ament_auto_add_gtest(test_ros_utils
146-
test/test_ros_utils.cpp
147-
)
148-
ament_auto_add_gtest(test_nms
149-
test/test_nms.cpp
150-
)
151-
152-
# Temporary disabled, tracked by:
153-
# https://github.com/autowarefoundation/autoware.universe/issues/7724
154-
# ament_auto_add_gtest(test_voxel_generator
155-
# test/test_voxel_generator.cpp
156-
# )
157-
158-
# # preprocess kernel test
159-
# add_executable(test_preprocess_kernel
160-
# test/test_preprocess_kernel.cpp
161-
# )
162-
# target_include_directories(test_preprocess_kernel PUBLIC
163-
# ${test_preprocess_kernel_SOURCE_DIR}
164-
# )
165-
# target_link_libraries(test_preprocess_kernel
166-
# transfusion_cuda_lib
167-
# gtest
168-
# gtest_main
169-
# )
170-
# ament_add_test(test_preprocess_kernel
171-
# GENERATE_RESULT_FOR_RETURN_CODE_ZERO
172-
# COMMAND "$<TARGET_FILE:test_preprocess_kernel>"
173-
# )
174-
175-
# # postprocess kernel test
176-
# add_executable(test_postprocess_kernel
177-
# test/test_postprocess_kernel.cpp
178-
# )
179-
# target_include_directories(test_postprocess_kernel PUBLIC
180-
# ${test_postprocess_kernel_SOURCE_DIR}
181-
# )
182-
# target_link_libraries(test_postprocess_kernel
183-
# transfusion_cuda_lib
184-
# gtest
185-
# gtest_main
186-
# )
187-
# ament_add_test(test_postprocess_kernel
188-
# GENERATE_RESULT_FOR_RETURN_CODE_ZERO
189-
# COMMAND "$<TARGET_FILE:test_postprocess_kernel>"
190-
# )
191-
192140
endif()
193141

194142
ament_auto_package(

perception/lidar_transfusion/README.md

+2-20
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,13 @@ ros2 launch lidar_transfusion lidar_transfusion.launch.xml log_level:=debug
5959

6060
## Assumptions / Known limits
6161

62-
This library operates on raw cloud data (bytes). It is assumed that the input pointcloud message has following format:
63-
64-
```python
65-
[
66-
sensor_msgs.msg.PointField(name='x', offset=0, datatype=7, count=1),
67-
sensor_msgs.msg.PointField(name='y', offset=4, datatype=7, count=1),
68-
sensor_msgs.msg.PointField(name='z', offset=8, datatype=7, count=1),
69-
sensor_msgs.msg.PointField(name='intensity', offset=12, datatype=2, count=1)
70-
]
71-
```
72-
73-
This input may consist of other fields as well - shown format is required minimum.
74-
For debug purposes, you can validate your pointcloud topic using simple command:
75-
76-
```bash
77-
ros2 topic echo <input_topic> --field fields
78-
```
79-
8062
## Trained Models
8163

8264
You can download the onnx format of trained models by clicking on the links below.
8365

84-
- TransFusion: [transfusion.onnx](https://awf.ml.dev.web.auto/perception/models/transfusion/t4xx1_90m/v2/transfusion.onnx)
66+
- TransFusion: [transfusion.onnx](https://awf.ml.dev.web.auto/perception/models/transfusion/v1/transfusion.onnx)
8567

86-
The model was trained in TIER IV's internal database (~11k lidar frames) for 50 epochs.
68+
The model was trained in TIER IV's internal database (~11k lidar frames) for 20 epochs.
8769

8870
### Changelog
8971

perception/lidar_transfusion/config/transfusion.param.yaml

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
class_names: ["CAR", "TRUCK", "BUS", "BICYCLE", "PEDESTRIAN"]
55
trt_precision: fp16
66
voxels_num: [5000, 30000, 60000] # [min, opt, max]
7-
point_cloud_range: [-92.16, -92.16, -3.0, 92.16, 92.16, 7.0] # [x_min, y_min, z_min, x_max, y_max, z_max]
8-
voxel_size: [0.24, 0.24, 10.0] # [x, y, z]
9-
num_proposals: 500
7+
point_cloud_range: [-76.8, -76.8, -3.0, 76.8, 76.8, 5.0] # [x_min, y_min, z_min, x_max, y_max, z_max]
8+
voxel_size: [0.3, 0.3, 8.0] # [x, y, z]
109
onnx_path: "$(var model_path)/transfusion.onnx"
1110
engine_path: "$(var model_path)/transfusion.engine"
1211
# pre-process params
@@ -18,4 +17,4 @@
1817
iou_nms_search_distance_2d: 10.0
1918
iou_nms_threshold: 0.1
2019
yaw_norm_thresholds: [0.3, 0.3, 0.3, 0.3, 0.0] # refers to the class_names
21-
score_threshold: 0.1
20+
score_threshold: 0.2

perception/lidar_transfusion/include/lidar_transfusion/preprocess/pointcloud_densification.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class DensificationParam
5151

5252
struct PointCloudWithTransform
5353
{
54-
cuda::unique_ptr<uint8_t[]> data_d{nullptr};
54+
cuda::unique_ptr<float[]> points_d{nullptr};
5555
std_msgs::msg::Header header;
5656
size_t num_points{0};
5757
Eigen::Affine3f affine_past2world;

perception/lidar_transfusion/include/lidar_transfusion/preprocess/preprocess_kernel.hpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ class PreprocessCuda
5656
unsigned int * mask, float * voxels, unsigned int * pillar_num, float * voxel_features,
5757
unsigned int * voxel_num, unsigned int * voxel_idxs);
5858

59+
// cudaError_t generateVoxelsInput_launch(
60+
// uint8_t * cloud_data, CloudInfo & cloud_info, unsigned int points_agg, unsigned int
61+
// points_size, float time_lag, float * affine_transform, float * points);
62+
5963
cudaError_t generateSweepPoints_launch(
60-
const uint8_t * input_data, size_t points_size, int input_point_step, float time_lag,
64+
const float * input_points, size_t points_size, int input_point_step, float time_lag,
6165
const float * transform, float * output_points);
6266

6367
private:

perception/lidar_transfusion/include/lidar_transfusion/preprocess/voxel_generator.hpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,15 @@
1818
#include "lidar_transfusion/cuda_utils.hpp"
1919
#include "lidar_transfusion/preprocess/pointcloud_densification.hpp"
2020
#include "lidar_transfusion/preprocess/preprocess_kernel.hpp"
21-
#include "lidar_transfusion/ros_utils.hpp"
2221
#include "lidar_transfusion/transfusion_config.hpp"
22+
#include "lidar_transfusion/utils.hpp"
2323

2424
#ifdef ROS_DISTRO_GALACTIC
2525
#include <tf2_eigen/tf2_eigen.h>
2626
#else
2727
#include <tf2_eigen/tf2_eigen.hpp>
2828
#endif
2929

30-
#include <autoware_point_types/types.hpp>
31-
3230
#include <sensor_msgs/msg/point_cloud2.hpp>
3331

3432
#include <memory>
@@ -38,8 +36,8 @@
3836

3937
namespace lidar_transfusion
4038
{
41-
constexpr size_t AFF_MAT_SIZE = 16; // 4x4 matrix
42-
constexpr size_t MAX_CLOUD_STEP_SIZE = sizeof(autoware_point_types::PointXYZIRCAEDT);
39+
constexpr size_t AFF_MAT_SIZE = 16; // 4x4 matrix
40+
constexpr size_t MAX_CLOUD_STEP_SIZE = 35; // PointXYZIRCADT
4341

4442
class VoxelGenerator
4543
{

perception/lidar_transfusion/include/lidar_transfusion/ros_utils.hpp

-68
Original file line numberDiff line numberDiff line change
@@ -17,84 +17,16 @@
1717

1818
#include "lidar_transfusion/utils.hpp"
1919

20-
#include <autoware_point_types/types.hpp>
21-
2220
#include <autoware_perception_msgs/msg/detected_object_kinematics.hpp>
2321
#include <autoware_perception_msgs/msg/detected_objects.hpp>
2422
#include <autoware_perception_msgs/msg/object_classification.hpp>
2523
#include <autoware_perception_msgs/msg/shape.hpp>
26-
#include <sensor_msgs/msg/point_field.hpp>
2724

28-
#include <cstdint>
2925
#include <string>
3026
#include <vector>
3127

32-
#define CHECK_OFFSET(offset, structure, field) \
33-
static_assert( \
34-
offsetof(structure, field) == offset, \
35-
"Offset of " #field " in " #structure " does not match expected offset.")
36-
#define CHECK_TYPE(type, structure, field) \
37-
static_assert( \
38-
std::is_same<decltype(structure::field), type>::value, \
39-
"Type of " #field " in " #structure " does not match expected type.")
40-
#define CHECK_FIELD(offset, type, structure, field) \
41-
CHECK_OFFSET(offset, structure, field); \
42-
CHECK_TYPE(type, structure, field)
43-
4428
namespace lidar_transfusion
4529
{
46-
using sensor_msgs::msg::PointField;
47-
48-
CHECK_FIELD(0, float, autoware_point_types::PointXYZIRCAEDT, x);
49-
CHECK_FIELD(4, float, autoware_point_types::PointXYZIRCAEDT, y);
50-
CHECK_FIELD(8, float, autoware_point_types::PointXYZIRCAEDT, z);
51-
CHECK_FIELD(12, uint8_t, autoware_point_types::PointXYZIRCAEDT, intensity);
52-
53-
struct CloudInfo
54-
{
55-
uint32_t x_offset{0};
56-
uint32_t y_offset{sizeof(float)};
57-
uint32_t z_offset{sizeof(float) * 2};
58-
uint32_t intensity_offset{sizeof(float) * 3};
59-
uint8_t x_datatype{PointField::FLOAT32};
60-
uint8_t y_datatype{PointField::FLOAT32};
61-
uint8_t z_datatype{PointField::FLOAT32};
62-
uint8_t intensity_datatype{PointField::UINT8};
63-
uint8_t x_count{1};
64-
uint8_t y_count{1};
65-
uint8_t z_count{1};
66-
uint8_t intensity_count{1};
67-
uint32_t point_step{sizeof(autoware_point_types::PointXYZIRCAEDT)};
68-
bool is_bigendian{false};
69-
70-
bool operator!=(const CloudInfo & rhs) const
71-
{
72-
return x_offset != rhs.x_offset || y_offset != rhs.y_offset || z_offset != rhs.z_offset ||
73-
intensity_offset != rhs.intensity_offset || x_datatype != rhs.x_datatype ||
74-
y_datatype != rhs.y_datatype || z_datatype != rhs.z_datatype ||
75-
intensity_datatype != rhs.intensity_datatype || x_count != rhs.x_count ||
76-
y_count != rhs.y_count || z_count != rhs.z_count ||
77-
intensity_count != rhs.intensity_count || is_bigendian != rhs.is_bigendian;
78-
}
79-
80-
friend std::ostream & operator<<(std::ostream & os, const CloudInfo & info)
81-
{
82-
os << "x_offset: " << static_cast<int>(info.x_offset) << std::endl;
83-
os << "y_offset: " << static_cast<int>(info.y_offset) << std::endl;
84-
os << "z_offset: " << static_cast<int>(info.z_offset) << std::endl;
85-
os << "intensity_offset: " << static_cast<int>(info.intensity_offset) << std::endl;
86-
os << "x_datatype: " << static_cast<int>(info.x_datatype) << std::endl;
87-
os << "y_datatype: " << static_cast<int>(info.y_datatype) << std::endl;
88-
os << "z_datatype: " << static_cast<int>(info.z_datatype) << std::endl;
89-
os << "intensity_datatype: " << static_cast<int>(info.intensity_datatype) << std::endl;
90-
os << "x_count: " << static_cast<int>(info.x_count) << std::endl;
91-
os << "y_count: " << static_cast<int>(info.y_count) << std::endl;
92-
os << "z_count: " << static_cast<int>(info.z_count) << std::endl;
93-
os << "intensity_count: " << static_cast<int>(info.intensity_count) << std::endl;
94-
os << "is_bigendian: " << static_cast<int>(info.is_bigendian) << std::endl;
95-
return os;
96-
}
97-
};
9830

9931
void box3DToDetectedObject(
10032
const Box3D & box3d, const std::vector<std::string> & class_names,

perception/lidar_transfusion/include/lidar_transfusion/transfusion_config.hpp

+3-10
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ class TransfusionConfig
2626
public:
2727
TransfusionConfig(
2828
const std::vector<int64_t> & voxels_num, const std::vector<double> & point_cloud_range,
29-
const std::vector<double> & voxel_size, const int num_proposals,
30-
const float circle_nms_dist_threshold, const std::vector<double> & yaw_norm_thresholds,
31-
const float score_threshold)
29+
const std::vector<double> & voxel_size, const float circle_nms_dist_threshold,
30+
const std::vector<double> & yaw_norm_thresholds, const float score_threshold)
3231
{
3332
if (voxels_num.size() == 3) {
3433
max_voxels_ = voxels_num[2];
@@ -62,9 +61,6 @@ class TransfusionConfig
6261
voxel_y_size_ = static_cast<float>(voxel_size[1]);
6362
voxel_z_size_ = static_cast<float>(voxel_size[2]);
6463
}
65-
if (num_proposals > 0) {
66-
num_proposals_ = num_proposals;
67-
}
6864
if (score_threshold > 0.0) {
6965
score_threshold_ = score_threshold;
7066
}
@@ -80,9 +76,6 @@ class TransfusionConfig
8076
grid_x_size_ = static_cast<std::size_t>((max_x_range_ - min_x_range_) / voxel_x_size_);
8177
grid_y_size_ = static_cast<std::size_t>((max_y_range_ - min_y_range_) / voxel_y_size_);
8278
grid_z_size_ = static_cast<std::size_t>((max_z_range_ - min_z_range_) / voxel_z_size_);
83-
84-
feature_x_size_ = grid_x_size_ / out_size_factor_;
85-
feature_y_size_ = grid_y_size_ / out_size_factor_;
8679
}
8780

8881
///// INPUT PARAMETERS /////
@@ -114,7 +107,7 @@ class TransfusionConfig
114107
const std::size_t out_size_factor_{4};
115108
const std::size_t max_num_points_per_pillar_{points_per_voxel_};
116109
const std::size_t num_point_values_{4};
117-
std::size_t num_proposals_{200};
110+
const std::size_t num_proposals_{200};
118111
// the number of feature maps for pillar scatter
119112
const std::size_t num_feature_scatter_{pillar_feature_size_};
120113
// the score threshold for classification

perception/lidar_transfusion/include/lidar_transfusion/utils.hpp

+46
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,52 @@ struct Box3D
3636
float yaw;
3737
};
3838

39+
struct CloudInfo
40+
{
41+
uint32_t x_offset;
42+
uint32_t y_offset;
43+
uint32_t z_offset;
44+
uint32_t intensity_offset;
45+
uint8_t x_datatype;
46+
uint8_t y_datatype;
47+
uint8_t z_datatype;
48+
uint8_t intensity_datatype;
49+
uint8_t x_count;
50+
uint8_t y_count;
51+
uint8_t z_count;
52+
uint8_t intensity_count;
53+
uint32_t point_step;
54+
bool is_bigendian;
55+
56+
CloudInfo()
57+
: x_offset(0),
58+
y_offset(4),
59+
z_offset(8),
60+
intensity_offset(12),
61+
x_datatype(7),
62+
y_datatype(7),
63+
z_datatype(7),
64+
intensity_datatype(7),
65+
x_count(1),
66+
y_count(1),
67+
z_count(1),
68+
intensity_count(1),
69+
point_step(16),
70+
is_bigendian(false)
71+
{
72+
}
73+
74+
bool operator!=(const CloudInfo & rhs) const
75+
{
76+
return x_offset != rhs.x_offset || y_offset != rhs.y_offset || z_offset != rhs.z_offset ||
77+
intensity_offset != rhs.intensity_offset || x_datatype != rhs.x_datatype ||
78+
y_datatype != rhs.y_datatype || z_datatype != rhs.z_datatype ||
79+
intensity_datatype != rhs.intensity_datatype || x_count != rhs.x_count ||
80+
y_count != rhs.y_count || z_count != rhs.z_count ||
81+
intensity_count != rhs.intensity_count || is_bigendian != rhs.is_bigendian;
82+
}
83+
};
84+
3985
enum NetworkIO { voxels = 0, num_points, coors, cls_score, dir_pred, bbox_pred, ENUM_SIZE };
4086

4187
// cspell: ignore divup

perception/lidar_transfusion/lib/preprocess/pointcloud_densification.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,16 @@ void PointCloudDensification::enqueue(
9393
affine_world2current_ = affine_world2current;
9494
current_timestamp_ = rclcpp::Time(msg.header.stamp).seconds();
9595

96-
auto data_d = cuda::make_unique<uint8_t[]>(
97-
sizeof(uint8_t) * msg.width * msg.height * msg.point_step / sizeof(uint8_t));
96+
assert(sizeof(uint8_t) * msg.width * msg.height * msg.point_step % sizeof(float) == 1);
97+
auto points_d = cuda::make_unique<float[]>(
98+
sizeof(uint8_t) * msg.width * msg.height * msg.point_step / sizeof(float));
9899

99100
CHECK_CUDA_ERROR(cudaMemcpyAsync(
100-
data_d.get(), msg.data.data(), sizeof(uint8_t) * msg.width * msg.height * msg.point_step,
101+
points_d.get(), msg.data.data(), sizeof(uint8_t) * msg.width * msg.height * msg.point_step,
101102
cudaMemcpyHostToDevice, stream_));
102103

103104
PointCloudWithTransform pointcloud = {
104-
std::move(data_d), msg.header, msg.width * msg.height, affine_world2current.inverse()};
105+
std::move(points_d), msg.header, msg.width * msg.height, affine_world2current.inverse()};
105106

106107
pointcloud_cache_.push_front(std::move(pointcloud));
107108
}

0 commit comments

Comments
 (0)