Apollo 11.0
自动驾驶开放平台
sensor.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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 <deque>
20#include <memory>
21#include <string>
22#include <vector>
23
27
28namespace apollo {
29namespace perception {
30namespace fusion {
31
32class Sensor {
33 public:
34 Sensor() = delete;
35
36 explicit Sensor(const base::SensorInfo& sensor_info)
37 : sensor_info_(sensor_info) {}
38
46 void QueryLatestFrames(double timestamp, std::vector<SensorFramePtr>* frames);
47
55 SensorFramePtr QueryLatestFrame(double timestamp);
56
57 bool GetPose(double timestamp, Eigen::Affine3d* pose) const;
58
59 // Getter
60 inline std::string GetSensorId() const { return sensor_info_.name; }
61
62 // Getter
63 inline base::SensorType GetSensorType() const { return sensor_info_.type; }
64
65 void AddFrame(const base::FrameConstPtr& frame_ptr);
66
67 inline static void SetMaxCachedFrameNumber(size_t number) {
68 kMaxCachedFrameNum = number;
69 }
70
71 void SetLatestQueryTimestamp(const double latest_query_timestamp) {
72 latest_query_timestamp_ = latest_query_timestamp;
73 }
74
75 private:
76 // FRIEND_TEST(SensorTest, test);
77
78 base::SensorInfo sensor_info_;
79
80 double latest_query_timestamp_ = 0.0;
81
82 std::deque<SensorFramePtr> frames_;
83
84 static size_t kMaxCachedFrameNum;
85};
86
87} // namespace fusion
88} // namespace perception
89} // namespace apollo
std::string GetSensorId() const
Definition sensor.h:60
SensorFramePtr QueryLatestFrame(double timestamp)
query latest frame whose time stamp is in range (_latest_fused_time_stamp, time_stamp]
Definition sensor.cc:43
static void SetMaxCachedFrameNumber(size_t number)
Definition sensor.h:67
Sensor(const base::SensorInfo &sensor_info)
Definition sensor.h:36
void SetLatestQueryTimestamp(const double latest_query_timestamp)
Definition sensor.h:71
base::SensorType GetSensorType() const
Definition sensor.h:63
void QueryLatestFrames(double timestamp, std::vector< SensorFramePtr > *frames)
query frames whose time stamp is in range (_latest_fused_time_stamp, time_stamp]
Definition sensor.cc:26
bool GetPose(double timestamp, Eigen::Affine3d *pose) const
Definition sensor.cc:55
void AddFrame(const base::FrameConstPtr &frame_ptr)
Definition sensor.cc:71
SensorType
Sensor types are set in the order of lidar, radar, camera, ultrasonic Please make sure SensorType has...
Definition sensor_meta.h:29
std::shared_ptr< const Frame > FrameConstPtr
Definition frame.h:61
std::shared_ptr< SensorFrame > SensorFramePtr
class register implement
Definition arena_queue.h:37