Apollo 11.0
自动驾驶开放平台
online_calibration_service.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#pragma once
17
18#include <map>
19#include <memory>
20#include <string>
21#include <vector>
22
25
26
27namespace apollo {
28namespace perception {
29namespace camera {
30
33 float pitch_angle = 0.f;
34 float pitch_angle_diff = 0.f;
35 std::vector<double> k_matrix = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
36 std::vector<double> ground_plane = {0.0, 0.0, 0.0, 0.0};
37};
38
40 public:
42
43 virtual ~OnlineCalibrationService() = default;
44
45 bool Init(const CalibrationServiceInitOptions &options =
47
48 bool BuildIndex() override;
49
50 // @brief query depth on ground plane given pixel coordinate
51 bool QueryDepthOnGroundPlane(int x, int y, double *depth) const override;
52
53 // @brief query 3d point on ground plane given pixel coordinate
54 bool QueryPoint3dOnGroundPlane(int x, int y,
55 Eigen::Vector3d *point3d) const override;
56
57 // @brief query ground plane in camera frame, parameterized as
58 // [n^T, d] with n^T*x+d=0
60 Eigen::Vector4d *plane_param) const override;
61
62 // @brief query camera to ground height and pitch angle
64 float *pitch) const override;
65
66 float QueryCameraToGroundHeight() const override {
67 if (is_service_ready_) {
68 auto iter = name_camera_status_map_.find(sensor_name_);
69 return (iter->second).camera_ground_height;
70 }
71 return -1.f;
72 }
73
74 float QueryPitchAngle() const override {
75 if (is_service_ready_) {
76 auto iter = name_camera_status_map_.find(sensor_name_);
77 return (iter->second).pitch_angle;
78 }
79 return -1.f;
80 }
81
82 // @brief using calibrator to update pitch angle
83 void Update(onboard::CameraFrame *frame) override;
84
85 // @brief using calibrator to update lane detection pitch angle
86 void Update(CameraFrame *frame) override;
87
88 // @brief set camera height and pitch
90 const std::map<std::string, float> &name_camera_ground_height_map,
91 const std::map<std::string, float> &name_camera_pitch_angle_diff_map,
92 const float &pitch_angle_master_sensor) override;
93
94 std::string Name() const override { return "OnlineCalibrationService"; }
95
96 private:
97 bool HasSetIntrinsics() const {
98 return name_camera_status_map_.find(sensor_name_) !=
99 name_camera_status_map_.end();
100 }
101
102 bool HasSetGroundPlane() {
103 bool has_set_ground_plane =
104 name_camera_status_map_.find(sensor_name_) !=
105 name_camera_status_map_.end() &&
106 name_camera_status_map_[sensor_name_].camera_ground_height > 0.0;
107 return has_set_ground_plane;
108 }
109
110 bool is_service_ready_ = false;
111 std::string sensor_name_ = "";
112 std::string master_sensor_name_ = "";
113 std::map<std::string, CameraStatus> name_camera_status_map_;
114 std::shared_ptr<BaseCalibrator> calibrator_;
115};
116
117} // namespace camera
118} // namespace perception
119} // namespace apollo
bool QueryGroundPlaneInCameraFrame(Eigen::Vector4d *plane_param) const override
void SetCameraHeightAndPitch(const std::map< std::string, float > &name_camera_ground_height_map, const std::map< std::string, float > &name_camera_pitch_angle_diff_map, const float &pitch_angle_master_sensor) override
bool QueryCameraToGroundHeightAndPitchAngle(float *height, float *pitch) const override
bool QueryDepthOnGroundPlane(int x, int y, double *depth) const override
bool Init(const CalibrationServiceInitOptions &options=CalibrationServiceInitOptions()) override
bool QueryPoint3dOnGroundPlane(int x, int y, Eigen::Vector3d *point3d) const override
class register implement
Definition arena_queue.h:37