Autoware.Auto
filter_interface.hpp
Go to the documentation of this file.
1 // Copyright 2021 the Autoware Foundation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // Developed by Apex.AI, Inc.
16 
21 
22 #ifndef KALMAN_FILTER__FILTER_INTERFACE_HPP_
23 #define KALMAN_FILTER__FILTER_INTERFACE_HPP_
24 
28 
29 #include <chrono>
30 
31 namespace autoware
32 {
33 namespace prediction
34 {
35 
41 template<typename Derived>
42 class KALMAN_FILTER_PUBLIC FilterInterface : public common::helper_functions::crtp<Derived>
43 {
44 public:
52  auto predict(const std::chrono::nanoseconds & dt) {return this->impl().crtp_predict(dt);}
53 
65  template<typename MeasurementT>
66  auto correct(const MeasurementT & measurement)
67  {
68  static_assert(
69  std::is_base_of<MeasurementInterface<MeasurementT>, MeasurementT>::value,
70  "\n\nMeasurement must inherit from MeasurementInterface\n\n");
71  return this->impl().template crtp_correct<MeasurementT>(measurement);
72  }
73 
82  template<typename StateT>
83  void reset(const StateT & state, const typename StateT::Matrix & covariance)
84  {
85  static_assert(
86  std::is_same<typename Derived::State, StateT>::value,
87  "\n\nProvided type StateT must match the filter implementation State type.\n\n");
88  this->impl().template crtp_reset(state, covariance);
89  }
90 
92  auto & state() {return this->impl().crtp_state();}
94  const auto & state() const {return this->impl().crtp_state();}
95 
97  auto & covariance() {return this->impl().crtp_covariance();}
99  const auto & covariance() const {return this->impl().crtp_covariance();}
100 };
101 
102 
103 } // namespace prediction
104 } // namespace autoware
105 
106 #endif // KALMAN_FILTER__FILTER_INTERFACE_HPP_
visibility_control.hpp
autoware::prediction::MeasurementInterface
A CRTP interface to any measurement.
Definition: measurement_interface.hpp:37
autoware::prediction::FilterInterface::state
const auto & state() const
Return current state.
Definition: filter_interface.hpp:94
autoware::prediction::FilterInterface::covariance
const auto & covariance() const
Return current covariance.
Definition: filter_interface.hpp:99
autoware::prediction::FilterInterface::correct
auto correct(const MeasurementT &measurement)
Correct the state with a measurement.
Definition: filter_interface.hpp:66
autoware::prediction::FilterInterface::reset
void reset(const StateT &state, const typename StateT::Matrix &covariance)
Reset the internal state of the vector to the given state and covariance.
Definition: filter_interface.hpp:83
autoware
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24
autoware::common::helper_functions::crtp
Definition: crtp.hpp:29
autoware::prediction::FilterInterface::state
auto & state()
Return current state.
Definition: filter_interface.hpp:92
autoware::prediction::FilterInterface::covariance
auto & covariance()
Return current covariance.
Definition: filter_interface.hpp:97
autoware::prediction::FilterInterface
Interface for a filter that can be used to track an object.
Definition: filter_interface.hpp:42
measurement_interface.hpp
This defines measurement interface class.
crtp.hpp
This file includes common helper functions.
autoware::prediction::FilterInterface::predict
auto predict(const std::chrono::nanoseconds &dt)
Predict the state by dt into the future.
Definition: filter_interface.hpp:52