31std::atomic<uint32_t> PointCloudPreprocessComponent::seq_num_{0};
36 AERROR <<
"Get PointCloudPreprocessComponentConfig file failed";
39 AINFO <<
"PointCloud Preprocess Component Configs: "
40 << comp_config.DebugString();
46 lidar2novatel_tf2_child_frame_id_ = comp_config.
sensor_name();
47 lidar_query_tf_offset_ =
51 std::string cloud_preprocessor_name = plugin_param.
name();
52 config_path_ = plugin_param.config_path();
53 config_file_ = plugin_param.config_file();
54 cloud_preprocessor_ = BasePointCloudPreprocessorRegisterer::GetInstanceByName(
55 cloud_preprocessor_name);
56 CHECK_NOTNULL(cloud_preprocessor_);
61 if (!InitAlgorithmPlugin()) {
62 AERROR <<
"Failed to init pointcloud preprocess component plugin.";
70 const std::shared_ptr<drivers::PointCloud>& message) {
72 AINFO << std::setprecision(16)
73 <<
"Enter pointcloud preprocess component, message timestamp: "
74 << message->measurement_time()
77 auto out_message = std::make_shared<onboard::LidarFrameMessage>();
79 bool status = InternalProc(message, out_message);
81 writer_->Write(out_message);
82 AINFO <<
"Send pointcloud preprocess output message.";
88bool PointCloudPreprocessComponent::InitAlgorithmPlugin() {
89 ACHECK(algorithm::SensorManager::Instance()->GetSensorInfo(sensor_name_,
93 preprocessor_init_options.
sensor_name = sensor_name_;
94 preprocessor_init_options.
config_path = config_path_;
95 preprocessor_init_options.
config_file = config_file_;
96 ACHECK(cloud_preprocessor_->
Init(preprocessor_init_options));
99 lidar2world_trans_.
Init(lidar2novatel_tf2_child_frame_id_);
103bool PointCloudPreprocessComponent::InternalProc(
104 const std::shared_ptr<const drivers::PointCloud>& in_message,
105 const std::shared_ptr<onboard::LidarFrameMessage>& out_message) {
106 uint32_t seq_num = seq_num_.fetch_add(1);
107 const double timestamp = in_message->measurement_time();
109 const double start_latency = (cur_time - timestamp) * 1e3;
110 AINFO << std::setprecision(16) <<
"FRAME:Preprocess:Start:msg_time["
111 << timestamp <<
"]:sensor[" << sensor_name_ <<
"]:cur_time[" << cur_time
112 <<
"]:cur_latency[" << start_latency <<
"]";
114 out_message->timestamp_ = timestamp;
115 out_message->lidar_timestamp_ = in_message->header().lidar_timestamp();
116 out_message->seq_num_ = seq_num;
120 auto& frame = out_message->lidar_frame_;
122 frame->cloud = base::PointFCloudPool::Instance().Get();
123 frame->timestamp = timestamp;
124 frame->sensor_info = sensor_info_;
126 Eigen::Affine3d pose = Eigen::Affine3d::Identity();
127 Eigen::Affine3d pose_novatel = Eigen::Affine3d::Identity();
128 const double lidar_query_tf_timestamp =
129 timestamp - lidar_query_tf_offset_ * 0.001;
133 AERROR <<
"Failed to get pose at time: " << lidar_query_tf_timestamp;
137 frame->lidar2world_pose = pose;
138 frame->novatel2world_pose = pose_novatel;
140 PointCloudPreprocessorOptions preprocessor_option;
142 &preprocessor_option.sensor2novatel_extrinsics)) {
143 AERROR <<
"Get sensor2novatel extrinsics error.";
146 frame->lidar2novatel_extrinsics =
147 preprocessor_option.sensor2novatel_extrinsics;
150 if (!cloud_preprocessor_->Preprocess(
151 preprocessor_option, in_message, frame.get())) {
152 AERROR <<
"Pointcloud preprocess error.";
a singleton clock that can be used to get the current timestamp.
static double NowInSeconds()
gets the current time in second.
bool GetProtoConfig(T *config) const
std::shared_ptr< Node > node_
static ConcurrentObjectPool & Instance()
std::shared_ptr< ObjectType > Get() override
virtual bool Init(const PointCloudPreprocessorInitOptions &options=PointCloudPreprocessorInitOptions())=0
Init pointcloud preprocessor
bool Proc(const std::shared_ptr< drivers::PointCloud > &message) override
Process of pointcloud preprocess
bool Init() override
Init pointcloud preprocess component
std::string GetAbsolutePath(const std::string &prefix, const std::string &relative_path)
Get absolute path by concatenating prefix and relative_path.
#define PERF_FUNCTION(...)
optional perception::PluginParam plugin_param
optional string sensor_name
optional string output_channel_name
optional double lidar_query_tf_offset