37 : start_ind_(point2ds_size), end_ind_(point2ds_size) {
48 const bool Empty()
const {
return (start_ind_ == end_ind_); }
49 size_t Size()
const {
return (end_ind_ - start_ind_); }
64 : sensor_id_(sensor_id), timestamp_(timestamp) {}
65 bool VerifyKey(std::string sensor_id,
double timestamp) {
66 return sensor_id_ == sensor_id &&
74 auto it = objects_.find(lidar_object_id);
75 if (it == objects_.end()) {
84 std::string sensor_id_;
86 std::map<int, ProjectionCacheObject> objects_;
92 template <
class EigenType>
99 point2ds_.reserve(300000);
102 : measurement_sensor_id_(sensor_id), measurement_timestamp_(timestamp) {
105 point2ds_.reserve(300000);
108 void Reset(std::string sensor_id,
double timestamp) {
109 measurement_sensor_id_ = sensor_id;
110 measurement_timestamp_ = timestamp;
116 if (ind >= point2ds_.size()) {
119 return &(point2ds_[ind]);
124 point2ds_.emplace_back(pt.x(), pt.y());
128 double measurement_timestamp,
129 const std::string& projection_sensor_id,
130 double projection_timestamp,
131 int lidar_object_id) {
132 if (!VerifyKey(measurement_sensor_id, measurement_timestamp)) {
136 QueryFrame(projection_sensor_id, projection_timestamp);
137 if (frame ==
nullptr) {
138 frame = BuildFrame(projection_sensor_id, projection_timestamp);
140 if (frame ==
nullptr) {
147 double measurement_timestamp,
148 const std::string& projection_sensor_id,
149 double projection_timestamp,
150 int lidar_object_id) {
151 if (!VerifyKey(measurement_sensor_id, measurement_timestamp)) {
155 QueryFrame(projection_sensor_id, projection_timestamp);
156 if (frame ==
nullptr) {
163 bool VerifyKey(
const std::string& sensor_id,
double timestamp) {
164 return measurement_sensor_id_ == sensor_id &&
168 ProjectionCacheFrame* BuildFrame(
const std::string& sensor_id,
170 frames_.push_back(ProjectionCacheFrame(sensor_id, timestamp));
171 return &(frames_[frames_.size() - 1]);
173 ProjectionCacheFrame* QueryFrame(
const std::string& sensor_id,
175 for (
size_t i = 0; i < frames_.size(); ++i) {
176 if (!frames_[i].VerifyKey(sensor_id, timestamp)) {
179 return &(frames_[i]);
186 std::string measurement_sensor_id_;
187 double measurement_timestamp_;
189 EigenVector<Eigen::Vector2d> point2ds_;
191 std::vector<ProjectionCacheFrame> frames_;
ProjectionCacheObject * BuildObject(int lidar_object_id)
ProjectionCacheFrame(std::string sensor_id, double timestamp)
ProjectionCacheObject * QueryObject(int lidar_object_id)
bool VerifyKey(std::string sensor_id, double timestamp)
void SetEndInd(size_t ind)
ProjectionCacheObject(size_t point2ds_size)
base::BBox2DF GetBox() const
void SetBox(base::BBox2DF box)
size_t GetStartInd() const
void SetStartInd(size_t ind)
ProjectionCacheObject * BuildObject(const std::string &measurement_sensor_id, double measurement_timestamp, const std::string &projection_sensor_id, double projection_timestamp, int lidar_object_id)
void AddPoint(const Eigen::Vector2f &pt)
void Reset(std::string sensor_id, double timestamp)
apollo::common::EigenVector< EigenType > EigenVector
ProjectionCacheObject * QueryObject(const std::string &measurement_sensor_id, double measurement_timestamp, const std::string &projection_sensor_id, double projection_timestamp, int lidar_object_id)
ProjectionCache(std::string sensor_id, double timestamp)
size_t GetPoint2dsSize() const
Eigen::Vector2d * GetPoint2d(size_t ind)
Math-related util functions.
std::enable_if<!std::numeric_limits< T >::is_integer, bool >::type almost_equal(T x, T y, int ulp)
std::vector< EigenType, Eigen::aligned_allocator< EigenType > > EigenVector
ProjectionCache * ProjectionCachePtr