42 AERROR <<
"Get LidarOutputComponentConfig file failed";
45 AINFO <<
"Lidar Output Component Configs: "
46 << comp_config.DebugString();
54 is_terminate_.store(
false);
55 if (save_benchmark_frame_) {
56 benchmark_thread_.reset(
69 std::function<void(
const std::shared_ptr<LidarFrameMessage>&)> model_call
71 this, std::placeholders::_1);
73 reader_config, model_call);
83 AINFO <<
"Register LidarFrameMessage for benchmark";
88 const std::shared_ptr<SensorFrameMessage>& in_message) {
89 std::shared_ptr<PerceptionObstacles> out_message(
new (std::nothrow)
91 double timestamp = in_message->timestamp_;
92 double lidar_timestamp = in_message->lidar_timestamp_;
94 std::vector<base::ObjectPtr> valid_objects;
96 if (in_message !=
nullptr && in_message->frame_ !=
nullptr) {
97 auto lidar_objects = in_message->frame_->objects;
98 valid_objects.assign(lidar_objects.begin(), lidar_objects.end());
101 if (save_benchmark_frame_) {
102 std::lock_guard<std::mutex> lock(benchmark_mutex_);
103 message_buffer_.push(in_message);
109 in_message->seq_num_,
112 out_message.get())) {
113 AERROR <<
"Failed to gen PerceptionObstacles object.";
117 writer_->Write(out_message);
118 AINFO <<
"Send lidar tracking output message.";
124 const std::shared_ptr<SensorFrameMessage>& in_message) {
125 std::shared_ptr<PerceptionBenchmarkFrame> out_message(
new (std::nothrow)
127 double timestamp = in_message->timestamp_;
128 double lidar_timestamp = in_message->lidar_timestamp_;
129 std::vector<base::ObjectPtr> valid_objects;
131 if (in_message !=
nullptr && in_message->frame_ !=
nullptr) {
132 auto lidar_objects = in_message->frame_->objects;
133 valid_objects.assign(lidar_objects.begin(), lidar_objects.end());
136 auto sensor_frame_info = out_message->mutable_sensor_frame_info();
137 sensor_frame_info->set_sensor_id(in_message->sensor_id_);
138 sensor_frame_info->set_timestamp(timestamp);
140 Eigen::Affine3d sensor2world_pose = Eigen::Affine3d::Identity();
141 if (in_message ==
nullptr || in_message->frame_ ==
nullptr) {
142 AERROR <<
"SaveBenchmarkFrame error, Can't get sensor2world_pose.";
144 sensor2world_pose = in_message->frame_->sensor2world_pose;
145 for (
int i = 0; i < 4; ++i) {
146 for (
int j = 0; j < 4; ++j) {
147 double val = sensor2world_pose.matrix()(i, j);
148 sensor_frame_info->add_sensor2world_pose(val);
156 in_message->seq_num_,
158 out_message.get())) {
159 AERROR <<
"Failed to get PerceptionBenchmarkFrame object.";
163 if (!EnsureDirectory(benchmark_frame_output_dir_)) {
164 AINFO <<
"Create dir " << benchmark_frame_output_dir_ <<
" error.";
168 double two_demical_time = round(timestamp * 100) / 100.0;
169 std::string pb_name =
"";
170 if (timestamp_two_decimal_format_) {
171 pb_name = GetAbsolutePath(benchmark_frame_output_dir_,
172 std::to_string(two_demical_time) +
".pb");
174 pb_name = GetAbsolutePath(benchmark_frame_output_dir_,
175 std::to_string(timestamp) +
".pb");
177 SetProtoToASCIIFile(*out_message, pb_name);
183 const std::shared_ptr<LidarFrameMessage>& in_message) {
184 std::shared_ptr<PerceptionBenchmarkFrame> out_message(
186 double timestamp = in_message->timestamp_;
187 double lidar_timestamp = in_message->lidar_timestamp_;
189 std::vector<base::ObjectPtr> valid_objects;
190 if (in_message !=
nullptr && in_message->lidar_frame_ !=
nullptr) {
191 auto lidar_objects = in_message->lidar_frame_->segmented_objects;
192 valid_objects.assign(lidar_objects.begin(), lidar_objects.end());
195 auto sensor_frame_info = out_message->mutable_sensor_frame_info();
196 sensor_frame_info->set_sensor_id(
197 in_message->lidar_frame_->sensor_info.name);
198 sensor_frame_info->set_timestamp(timestamp);
200 Eigen::Affine3d sensor2world_pose = Eigen::Affine3d::Identity();
201 if (in_message ==
nullptr || in_message->lidar_frame_ ==
nullptr) {
202 AERROR <<
"SaveBenchmarkLidarFrame Error, Can't get lidar2world_pose";
204 sensor2world_pose = in_message->lidar_frame_->lidar2world_pose;
205 for (
int i = 0; i < 4; ++i) {
206 for (
int j = 0; j < 4; ++j) {
207 double val = sensor2world_pose.matrix()(i, j);
208 sensor_frame_info->add_sensor2world_pose(val);
216 in_message->seq_num_,
220 use_lidar_cooridinate_)) {
221 AERROR <<
"Failed to get SerializeLidarFrameMsg object.";
225 if (!EnsureDirectory(lidar_frame_output_dir_)) {
226 AERROR <<
"Create dir " << lidar_frame_output_dir_ <<
" error.";
229 double two_demical_time = round(timestamp * 100) / 100.0;
230 std::string pb_name =
"";
231 if (timestamp_two_decimal_format_) {
232 pb_name = GetAbsolutePath(lidar_frame_output_dir_,
233 std::to_string(two_demical_time) +
".pb");
235 pb_name = GetAbsolutePath(lidar_frame_output_dir_,
236 std::to_string(timestamp) +
".pb");
238 SetProtoToASCIIFile(*out_message, pb_name);
240 AINFO <<
"SaveBenchmarkLidarFrame Success: time is "
241 << std::to_string(timestamp);
static bool SerializeMsg(double timestamp, uint64_t lidar_timestamp, int seq_num, const std::vector< base::ObjectPtr > &objects, const apollo::common::ErrorCode &error_code, PerceptionObstacles *obstacles)
static bool SerializeLidarFrameMsg(double timestamp, uint64_t lidar_timestamp, int seq_num, const Eigen::Affine3d &pose, const std::vector< base::ObjectPtr > &objects, PerceptionBenchmarkFrame *obstacles, bool use_lidar_cooridinate=true)