Apollo  v5.5.0
Open source self driving car software
mlf_motion_filter.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 
24 
25 namespace apollo {
26 namespace perception {
27 namespace lidar {
28 
30  public:
31  MlfMotionFilter() = default;
32  virtual ~MlfMotionFilter() = default;
33 
34  bool Init(
35  const MlfFilterInitOptions& options = MlfFilterInitOptions()) override;
36 
37  // @brief: updating motion filter with object
38  // @params [in]: options for updating
39  // @params [in]: track data, not include new object
40  // @params [in/out]: new object for updating
41  void UpdateWithObject(const MlfFilterOptions& options,
42  const MlfTrackDataConstPtr& track_data,
43  TrackedObjectPtr new_object) override;
44 
45  // @brief: updating motion filter without object
46  // @params [in]: options for updating
47  // @params [in]: current timestamp
48  // @params [in/out]: track data to be updated
49  void UpdateWithoutObject(const MlfFilterOptions& options, double timestamp,
50  MlfTrackDataPtr track_data) override;
51 
52  std::string Name() const override { return "MlfMotionFilter"; }
53 
54  protected:
55  // @brief: initialize track state and store in the new object
56  // @params [out]: new object to be updated
57  void InitializeTrackState(TrackedObjectPtr new_object);
58 
59  // @brief: update state with kalman filter,
60  // constant acceleration motion model,
61  // only velocity measurement is observed
62  // @params [in]: history track data
63  // @params [in]: latest object in the track data
64  // @params [in/out]: new object to be updated
66  const MlfTrackDataConstPtr& track_data,
67  const TrackedObjectConstPtr& latest_object, TrackedObjectPtr new_object);
68 
69  // @brief: adjust kalman state gain with several strategies
70  // @params [in]: history track data
71  // @params [in]: latest object in the track data
72  // @params [in]: new object to be updated
73  // @params [in/out]: state gain
74  void StateGainAdjustment(const MlfTrackDataConstPtr& track_data,
75  const TrackedObjectConstPtr& latest_object,
76  const TrackedObjectConstPtr& new_object,
77  Eigen::Vector4d* gain);
78 
79  // @brief: estimate convergence confidence and boost up state
80  // @params [in]: history track data
81  // @params [in]: latest object in the track data
82  // @params [in/out]: new object to be updated
84  const MlfTrackDataConstPtr& track_data,
85  const TrackedObjectConstPtr& latest_object, TrackedObjectPtr new_object);
86 
87  // @brief: compute convergence confidence
88  // @params [in]: history track data
89  // @params [in/out]: new object to be updated
90  // @params [in]: whether using belief velocity or output velocity
92  TrackedObjectPtr new_object,
93  bool velocity_source_is_belief = true);
94 
95  // @brief: boost up state considering track history
96  // @params [in]: history track data
97  // @params [in/out]: new object to be updated
98  void BoostupState(const MlfTrackDataConstPtr& track_data,
99  TrackedObjectPtr new_object);
100 
101  // @brief: cliping state if is within noise level
102  // @params [in/out]: new object to be updated
103  void ClipingState(TrackedObjectPtr object);
104 
105  // @brief: estimate covariance considering history measurment
106  // @params [in]: history track data
107  // @params [in/out]: new object to be updated
108  void OnlineCovarianceEstimation(const MlfTrackDataConstPtr& track_data,
109  TrackedObjectPtr object);
110 
111  // @brief: update convergence confidence
112  // @params [in]: history track data
113  // @params [in/out]: new object to be updated
114  void UpdateConverged(const MlfTrackDataConstPtr& track_data,
115  TrackedObjectPtr object);
116 
117  // @brief: synchronize state to belief to keep consistency
118  // @params [in/out]: new object to be updated
119  void StateToBelief(TrackedObjectPtr object);
120 
121  // @brief: copy belief to output
122  // @params [in/out]: new object to be updated
123  void BeliefToOutput(TrackedObjectPtr object);
124 
125  protected:
126  const double EPSION_TIME = 1e-3;
127  const double DEFAULT_FPS = 0.1;
128  // motion measurement
129  std::shared_ptr<MlfMotionMeasurement> motion_measurer_;
130  // motion refiner
131  std::shared_ptr<MlfMotionRefiner> motion_refiner_;
132  // switch for filter strategies
133  bool use_adaptive_ = true;
134  bool use_breakdown_ = true;
136  // default covariance parameters for kalman filter
141  // other parameters
145  double noise_maximum_ = 0.1;
147 }; // class MlfMotionFilter
148 
149 } // namespace lidar
150 } // namespace perception
151 } // namespace apollo
Definition: mlf_base_filter.h:31
double init_velocity_variance_
Definition: mlf_motion_filter.h:137
Definition: mlf_motion_filter.h:29
void UpdateConverged(const MlfTrackDataConstPtr &track_data, TrackedObjectPtr object)
Definition: mlf_base_filter.h:29
void UpdateWithObject(const MlfFilterOptions &options, const MlfTrackDataConstPtr &track_data, TrackedObjectPtr new_object) override
void InitializeTrackState(TrackedObjectPtr new_object)
std::shared_ptr< MlfMotionRefiner > motion_refiner_
Definition: mlf_motion_filter.h:131
const double DEFAULT_FPS
Definition: mlf_motion_filter.h:127
Definition: blob.h:72
double noise_maximum_
Definition: mlf_motion_filter.h:145
void StateGainAdjustment(const MlfTrackDataConstPtr &track_data, const TrackedObjectConstPtr &latest_object, const TrackedObjectConstPtr &new_object, Eigen::Vector4d *gain)
size_t boostup_history_size_minimum_
Definition: mlf_motion_filter.h:142
bool Init(const MlfFilterInitOptions &options=MlfFilterInitOptions()) override
double init_acceleration_variance_
Definition: mlf_motion_filter.h:138
Definition: mlf_base_filter.h:33
double converged_confidence_minimum_
Definition: mlf_motion_filter.h:144
void KalmanFilterUpdateWithPartialObservation(const MlfTrackDataConstPtr &track_data, const TrackedObjectConstPtr &latest_object, TrackedObjectPtr new_object)
std::string Name() const override
Definition: mlf_motion_filter.h:52
std::shared_ptr< MlfMotionMeasurement > motion_measurer_
Definition: mlf_motion_filter.h:129
size_t boostup_history_size_maximum_
Definition: mlf_motion_filter.h:143
void ConvergenceEstimationAndBoostUp(const MlfTrackDataConstPtr &track_data, const TrackedObjectConstPtr &latest_object, TrackedObjectPtr new_object)
std::shared_ptr< const MlfTrackData > MlfTrackDataConstPtr
Definition: mlf_track_data.h:111
bool use_convergence_boostup_
Definition: mlf_motion_filter.h:135
double predict_variance_per_sqrsec_
Definition: mlf_motion_filter.h:140
void StateToBelief(TrackedObjectPtr object)
bool use_breakdown_
Definition: mlf_motion_filter.h:134
std::shared_ptr< MlfTrackData > MlfTrackDataPtr
Definition: mlf_track_data.h:110
void ClipingState(TrackedObjectPtr object)
const double EPSION_TIME
Definition: mlf_motion_filter.h:126
double trust_orientation_range_
Definition: mlf_motion_filter.h:146
void UpdateWithoutObject(const MlfFilterOptions &options, double timestamp, MlfTrackDataPtr track_data) override
double measured_velocity_variance_
Definition: mlf_motion_filter.h:139
void ComputeConvergenceConfidence(const MlfTrackDataConstPtr &track_data, TrackedObjectPtr new_object, bool velocity_source_is_belief=true)
bool use_adaptive_
Definition: mlf_motion_filter.h:133
std::shared_ptr< const TrackedObject > TrackedObjectConstPtr
Definition: tracked_object.h:153
void OnlineCovarianceEstimation(const MlfTrackDataConstPtr &track_data, TrackedObjectPtr object)
void BoostupState(const MlfTrackDataConstPtr &track_data, TrackedObjectPtr new_object)
std::shared_ptr< TrackedObject > TrackedObjectPtr
Definition: tracked_object.h:152
void BeliefToOutput(TrackedObjectPtr object)