Apollo  v5.5.0
Open source self driving car software
sensor_frame.h
Go to the documentation of this file.
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 #pragma once
17 
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 #include "Eigen/Core"
23 
27 
28 namespace apollo {
29 namespace perception {
30 namespace fusion {
31 
34  double timestamp = 0.0;
35  Eigen::Affine3d sensor2world_pose;
36 
37  SensorFrameHeader() = default;
38  SensorFrameHeader(const base::SensorInfo& info, double ts,
39  const Eigen::Affine3d& pose)
40  : sensor_info(info), timestamp(ts), sensor2world_pose(pose) {}
41 };
42 
43 class SensorFrame {
44  public:
45  SensorFrame();
46 
47  explicit SensorFrame(const base::FrameConstPtr& base_frame_ptr);
48 
49  void Initialize(const base::FrameConstPtr& base_frame_ptr);
50 
51  void Initialize(const base::FrameConstPtr& base_frame_ptr,
52  const SensorPtr& sensor);
53 
54  // Getter
55  inline double GetTimestamp() const { return header_->timestamp; }
56 
57  inline bool GetPose(Eigen::Affine3d* pose) const {
58  if (pose == nullptr) {
59  AERROR << "pose is not available";
60  return false;
61  }
62  *pose = header_->sensor2world_pose;
63  return true;
64  }
65 
66  inline std::vector<SensorObjectPtr>& GetForegroundObjects() {
67  return foreground_objects_;
68  }
69 
70  inline const std::vector<SensorObjectPtr>& GetForegroundObjects() const {
71  return foreground_objects_;
72  }
73 
74  inline std::vector<SensorObjectPtr>& GetBackgroundObjects() {
75  return background_objects_;
76  }
77 
78  inline const std::vector<SensorObjectPtr>& GetBackgroundObjects() const {
79  return background_objects_;
80  }
81 
82  std::string GetSensorId() const;
83 
84  base::SensorType GetSensorType() const;
85 
86  SensorFrameHeaderConstPtr GetHeader() const { return header_; }
87 
88  private:
89  std::vector<SensorObjectPtr> foreground_objects_;
90  std::vector<SensorObjectPtr> background_objects_;
91 
92  // sensor-specific frame supplements
93  base::LidarFrameSupplement lidar_frame_supplement_;
94  base::RadarFrameSupplement radar_frame_supplement_;
95  base::CameraFrameSupplement camera_frame_supplement_;
96 
97  SensorFrameHeaderPtr header_ = nullptr;
98 };
99 
100 } // namespace fusion
101 } // namespace perception
102 } // namespace apollo
std::vector< SensorObjectPtr > & GetBackgroundObjects()
Definition: sensor_frame.h:74
SensorFrameHeaderConstPtr GetHeader() const
Definition: sensor_frame.h:86
std::shared_ptr< SensorFrameHeader > SensorFrameHeaderPtr
Definition: base_forward_declaration.h:24
bool GetPose(Eigen::Affine3d *pose) const
Definition: sensor_frame.h:57
double GetTimestamp() const
Definition: sensor_frame.h:55
Definition: blob.h:72
Eigen::Affine3d sensor2world_pose
Definition: sensor_frame.h:35
base::SensorInfo sensor_info
Definition: sensor_frame.h:33
Definition: frame_supplement.h:29
std::shared_ptr< Sensor > SensorPtr
Definition: base_forward_declaration.h:32
std::vector< SensorObjectPtr > & GetForegroundObjects()
Definition: sensor_frame.h:66
const std::vector< SensorObjectPtr > & GetBackgroundObjects() const
Definition: sensor_frame.h:78
double timestamp
Definition: sensor_frame.h:34
std::shared_ptr< const Frame > FrameConstPtr
Definition: frame.h:59
const std::vector< SensorObjectPtr > & GetForegroundObjects() const
Definition: sensor_frame.h:70
Definition: frame_supplement.h:46
Definition: sensor_meta.h:57
std::shared_ptr< const SensorFrameHeader > SensorFrameHeaderConstPtr
Definition: base_forward_declaration.h:26
SensorType
Sensor types are set in the order of lidar, radar, camera, ultrasonic Please make sure SensorType has...
Definition: sensor_meta.h:29
Definition: sensor_frame.h:43
SensorFrameHeader(const base::SensorInfo &info, double ts, const Eigen::Affine3d &pose)
Definition: sensor_frame.h:38
Definition: frame_supplement.h:55