Apollo 11.0
自动驾驶开放平台
kalman_motion_fusion.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 <deque>
19#include <string>
20#include <vector>
21
22#include "cyber/common/macros.h"
26
27namespace apollo {
28namespace perception {
29namespace fusion {
30
32 public:
33 explicit KalmanMotionFusion(TrackPtr track) : BaseMotionFusion(track) {}
35
36 // @brief init kalman filter and some magic number
37 bool Init() override;
38
39 // @brief update the tracker with current measurement
40 // @params[IN] measurement: sensor results
41 // @params[IN] target_timestamp: tracker timestamp
42 void UpdateWithMeasurement(const SensorObjectConstPtr& measurement,
43 double target_timestamp) override;
44
45 // @brief update the tracker only use time diff
46 // @params[IN] sensor_id
47 // @params[IN] measurement_timestamp
48 // @params[IN] target_timestamp
49 void UpdateWithoutMeasurement(const std::string& sensor_id,
50 double measurement_timestamp,
51 double target_timestamp) override;
52
53 std::string Name() const override { return "KalmamnMotionFusion"; }
54
61 void GetStates(Eigen::Vector3d* anchor_point, Eigen::Vector3d* velocity);
62
63 private:
64 bool InitFilter(const SensorObjectConstPtr& sensor_object);
65
66 void MotionFusionWithoutMeasurement(const double time_diff);
67 void MotionFusionWithMeasurement(const SensorObjectConstPtr& measurement,
68 double time_diff);
69
71 void UpdateMotionState();
72
73 // @brief We use the history sensor information
74 // to compute the acceleration.
75 // @params[IN] sensor_type: which sensor type we
76 // need in history queue
77 // @params[IN] velocity: the current velocity
78 // @params[IN] timestamp: the current timestamp
79 // @return result acceleration
80 Eigen::VectorXd ComputeAccelerationMeasurement(
81 const base::SensorType& sensor_type, const Eigen::Vector3d& velocity,
82 const double& timestamp);
83
84 void UpdateSensorHistory(const base::SensorType& sensor_type,
85 const Eigen::Vector3d& velocity,
86 const double& timestamp);
87 // @brief reward r matrix according coming sensor type and converge status
88 // @params[IN] sensor_type: sensor type of coming measurement
89 // @params[IN] converged: converge status of coming measurement
90 void RewardRMatrix(const base::SensorType& sensor_type, const bool& converged,
91 Eigen::MatrixXd* r_matrix);
92 // @brief compute pseudo measurement
93 // @params[IN] measurement: original measurement
94 // @params[IN] sensor_type: sensor type of coming measurement
95 // @params[OUT] has_good_radar: whether good radar has been found or not
96 // @return pseudo measurement of coming measurement
97 Eigen::Vector4d ComputePseudoMeasurement(const Eigen::Vector4d& measurement,
98 const base::SensorType& sensor_type);
99
100 // @brief compute pseudo lidar measurement
101 // @params[IN] measurement: original lidar measurement
102 // @return pseudo measurement of coming lidar measurement
103 Eigen::Vector4d ComputePseudoLidarMeasurement(
104 const Eigen::Vector4d& measurement);
105 // @brief compute pseudo camera measurement
106 // @params[IN] measurement: original camera measurement
107 // @return pseudo measurement of coming camera measurement
108 Eigen::Vector4d ComputePseudoCameraMeasurement(
109 const Eigen::Vector4d& measurement);
110 // @brief compute pseudo radar measurement
111 // @params[IN] measurement: original radar measurement
112 // @return pseudo measurement of coming radar measurement
113 Eigen::Vector4d ComputePseudoRadarMeasurement(
114 const Eigen::Vector4d& measurement);
115
116 int GetSensorHistoryLength(const base::SensorType& sensor_type);
117 int GetSensorHistoryIndex(const base::SensorType& sensor_type,
118 const int& trace_length);
119
120 private:
121 bool filter_init_ = false;
123 std::deque<double> history_timestamp_;
124 std::deque<base::SensorType> history_sensor_type_;
125 KalmanFilter kalman_filter_;
126 Eigen::Vector3d fused_anchor_point_;
127 Eigen::Vector3d fused_velocity_;
128 Eigen::Vector3d fused_acceleration_;
129 Eigen::Matrix3f center_uncertainty_ = Eigen::Matrix3f::Zero();
130 Eigen::Matrix3f velo_uncertainty_ = Eigen::Matrix3f::Zero();
131 Eigen::Matrix3f acc_uncertainty_ = Eigen::Matrix3f::Zero();
132
133 static int s_eval_window_;
134 static size_t s_history_size_maximum_;
135 double velocity_length_change_thresh_ = 5.0f; // diff < 5 m/s
136
138};
139
140} // namespace fusion
141} // namespace perception
142} // namespace apollo
void GetStates(Eigen::Vector3d *anchor_point, Eigen::Vector3d *velocity)
Get states
bool Init() override
Init base data association config
void UpdateWithMeasurement(const SensorObjectConstPtr &measurement, double target_timestamp) override
update track motion state with measurement
void UpdateWithoutMeasurement(const std::string &sensor_id, double measurement_timestamp, double target_timestamp) override
update track motion state without measurement
std::string Name() const override
The name of BaseMotionFusion
#define DISALLOW_COPY_AND_ASSIGN(classname)
Definition macros.h:48
std::deque< EigenType, Eigen::aligned_allocator< EigenType > > EigenDeque
Definition eigen_defs.h:36
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 SensorObject > SensorObjectConstPtr
std::shared_ptr< Track > TrackPtr
Definition track.h:397
class register implement
Definition arena_queue.h:37