Apollo 11.0
自动驾驶开放平台
fusion_and_compensator_component.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2024 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of 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,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include <map>
20#include <memory>
21#include <string>
22#include <vector>
23
24#include "Eigen/Eigen"
25
26// Eigen 3.3.7: #define ALIVE (0)
27// fastrtps: enum ChangeKind_t { ALIVE, ... };
28#if defined(ALIVE)
29#undef ALIVE
30#endif
31
32#include "modules/common_msgs/sensor_msgs/pointcloud.pb.h"
33#include "modules/drivers/lidar_fusion_and_compensator/proto/config.pb.h"
34
36#include "cyber/cyber.h"
38
39namespace apollo {
40namespace drivers {
41namespace lidar {
42
47
48class FusionAndCompensatorComponent : public Component<PointCloud> {
49public:
50 bool Init() override;
51 bool Proc(const std::shared_ptr<PointCloud>& point_cloud) override;
52
53private:
54 bool FusionAndCompensator(
55 const std::shared_ptr<PointCloud> source,
56 const uint64_t& timestamp_min,
57 const uint64_t& timestamp_max,
58 std::shared_ptr<PointCloud> target);
59
60 bool IsExpired(const std::shared_ptr<PointCloud>& target, const std::shared_ptr<PointCloud>& source);
61 bool QueryPoseAffineFromTF2(
62 const uint64_t& timestamp,
63 const std::string& target_frame_id,
64 const std::string& source_frame_id,
65 Eigen::Affine3d* pose);
66
67 bool IsFilteredPoint(const Eigen::Vector3f& point, const std::string& frame_id) const;
68
72 void GetTimestampInterval(
73 const std::vector<std::shared_ptr<PointCloud>>& point_clouds,
74 uint64_t* timestamp_min,
75 uint64_t* timestamp_max);
79 void MotionCompensation(
80 const std::shared_ptr<PointCloud>& source,
81 const uint64_t& timestamp_min,
82 const uint64_t& timestamp_max,
83 const Eigen::Affine3d& world_tf_min_time,
84 const Eigen::Affine3d& world_tf_max_time,
85 const Eigen::Affine3f& lidar_tf,
86 std::shared_ptr<PointCloud> target);
87
89 apollo::transform::Buffer* tf2_buffer_ptr_ = nullptr;
90 std::shared_ptr<Writer<PointCloud>> writer_;
91 std::vector<std::shared_ptr<Reader<PointCloud>>> readers_;
92
93 size_t pool_size_ = 10;
94 size_t pool_index_ = 0;
95 size_t reserved_point_size_ = 500000;
96 uint64_t seq_num_ = 1;
97
98 std::map<
99 std::string,
100 Eigen::Affine3f,
101 std::less<std::string>,
102 Eigen::aligned_allocator<std::pair<const std::string, Eigen::Affine3f>>>
103 static_tf_map_;
104 std::map<std::string, const FilterConfig*> filter_map_;
105};
106
108} // namespace lidar
109} // namespace drivers
110} // namespace apollo
Reader subscribes a channel, it has two main functions:
Definition reader.h:69
bool Proc(const std::shared_ptr< PointCloud > &point_cloud) override
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:657
class register implement
Definition arena_queue.h:37