HumanFilter.h
Go to the documentation of this file.
1 /**
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @author Tobias Gröger ( tobias dot groeger at student dot kit dot edu )
17  * @author Corvin Navarro Ecker ( corvin dot ecker at student dot kit dot edu )
18  * @date 2022
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <cstdint>
26 #include <list>
27 #include <memory>
28 
31 
33 
37 
39 {
40 
41  /**
42  * @brief The HumanFilter class can be used to track and filter the state of a single human. It
43  * hides implementation detail on how the filtering is done. New information about the human can
44  * be fed by using the update method. The human itself can be obtained using the get method.
45  */
47  {
48 
49  public:
50  struct Parameters
51  {
52  //TODO which values are appropriate?
53  double control_pos_cov = 0.01;
54  double control_rot_cov = 0.01;
55  double obs_pos_cov = 0.01;
56  double obs_rot_cov = 0.01;
57  double initial_state_pos_cov = 0.01;
58  double initial_state_rot_cov = 0.01;
59  double alpha = 0.5;
60 
61  float velocityAlpha = 0.15;
62 
63  unsigned int velocityAverageBinSize = 10;
64  unsigned int velocityAverageBinDistance = 5;
65  unsigned int positionAverageBinSize = 8;
66  };
67 
68  /**
69  * @brief HumanFilter::HumanFilter creates a new filter that filters 2D poses (position and
70  * rotation in a two dimensional plane)
71  * @param pose0 the first known pose of the human
72  * @param detectionTime the point of detection
73  */
74  HumanFilter(const core::Pose2D& pose0, const DateTime& detectionTime, bool useKalmanFilter);
75 
76  /**
77  * @brief HumanFilter::propagation propagate the system model to the given point in time. This
78  * means that the human pose is updated according to the filters prediction for the given point
79  * in time. Should be called at most once between every two calls of HumanFilter::update.
80  * @param detectionTime the point in time for which the pose should be predicted
81  */
82  void propagation(const DateTime& detectionTime);
83  /**
84  * @brief HumanFilter::update update the filter a new detected pose of the tracked human and
85  * the detection time
86  * @param pose the new detected pose of the human
87  * @param detectionTime the detection time
88  */
89  void update(const core::Pose2D& pose, const DateTime& detectionTime);
90  /**
91  * @brief HumanFilter::get returns the human whose pose is filtered containing the most recent
92  * state
93  * @return the human
94  */
95  const Human& get() const;
96 
97  Duration detectionAge(const DateTime& currentTime) const;
98 
99  private:
101 
102  SystemModelT::StateT toUkfState(const core::Pose2D& pose);
103  core::Pose2D fromUkfState(const SystemModelT::StateT& pose);
104  SystemModelT::ControlT toUkfControl(const Eigen::Vector2f& vel);
105  SystemModelT::ObsT toUkfObs(const core::Pose2D& pose);
106 
107  struct TimedVector2f
108  {
109  std::int64_t time;
110  Eigen::Vector2f pose;
111  };
112 
113  TimedVector2f getAveragedTimedPose(unsigned int start_idx, unsigned int end_idx);
114 
115  private:
116  Parameters params{};
117  /**
118  * @brief oldHuman stores information about the human at the point in time of the last
119  * HumanFilter::update call
120  */
121  Human lastDetectedHuman{};
122  /**
123  * @brief human stores information about the human at the point in time of the last
124  * HumanFilter::propagation call
125  */
126  Human human{};
127  std::unique_ptr<UnscentedKalmanFilter<SystemModelT>> ukf = nullptr;
128  bool useKalmanFilter;
129 
130  std::list<TimedVector2f> pastPoses;
131  };
132 
133 } // namespace armarx::navigation::human
armarx::navigation::human::HumanFilter::HumanFilter
HumanFilter(const core::Pose2D &pose0, const DateTime &detectionTime, bool useKalmanFilter)
HumanFilter::HumanFilter creates a new filter that filters 2D poses (position and rotation in a two d...
Definition: HumanFilter.cpp:17
armarx::navigation::human::HumanFilter::Parameters::obs_rot_cov
double obs_rot_cov
Definition: HumanFilter.h:56
armarx::navigation::human::Human
Definition: types.h:36
armarx::navigation::human::kalman_filter::SystemModelSE2
Definition: HumanSystemModel.h:93
basic_types.h
armarx::navigation::human::HumanFilter::Parameters::initial_state_rot_cov
double initial_state_rot_cov
Definition: HumanFilter.h:58
armarx::navigation::human::HumanFilter::Parameters::control_pos_cov
double control_pos_cov
Definition: HumanFilter.h:53
armarx::navigation::human::HumanFilter::Parameters
Definition: HumanFilter.h:50
DateTime.h
Duration.h
types.h
armarx::navigation::human
This file is part of ArmarX.
Definition: aron_conversions.cpp:10
armarx::skills::gui::Parameters
aron::data::DictPtr Parameters
Definition: SkillManagerWrapper.h:21
armarx::navigation::human::HumanFilter::update
void update(const core::Pose2D &pose, const DateTime &detectionTime)
HumanFilter::update update the filter a new detected pose of the tracked human and the detection time...
Definition: HumanFilter.cpp:77
armarx::navigation::human::HumanFilter::Parameters::obs_pos_cov
double obs_pos_cov
Definition: HumanFilter.h:55
armarx::navigation::human::HumanFilter::Parameters::positionAverageBinSize
unsigned int positionAverageBinSize
Definition: HumanFilter.h:65
armarx::navigation::core::Pose2D
Eigen::Isometry2f Pose2D
Definition: basic_types.h:34
armarx::navigation::human::HumanFilter::Parameters::initial_state_pos_cov
double initial_state_pos_cov
Definition: HumanFilter.h:57
armarx::navigation::human::HumanFilter::Parameters::velocityAverageBinSize
unsigned int velocityAverageBinSize
Definition: HumanFilter.h:63
armarx::navigation::human::kalman_filter::StateSE2
Definition: HumanSystemModel.h:81
armarx::navigation::human::HumanFilter::detectionAge
Duration detectionAge(const DateTime &currentTime) const
Definition: HumanFilter.cpp:151
armarx::navigation::human::HumanFilter::Parameters::alpha
double alpha
Definition: HumanFilter.h:59
armarx::navigation::human::HumanFilter::Parameters::control_rot_cov
double control_rot_cov
Definition: HumanFilter.h:54
armarx::navigation::human::HumanFilter::get
const Human & get() const
HumanFilter::get returns the human whose pose is filtered containing the most recent state.
Definition: HumanFilter.cpp:145
armarx::navigation::human::HumanFilter::propagation
void propagation(const DateTime &detectionTime)
HumanFilter::propagation propagate the system model to the given point in time.
Definition: HumanFilter.cpp:57
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::navigation::human::HumanFilter
The HumanFilter class can be used to track and filter the state of a single human.
Definition: HumanFilter.h:46
armarx::navigation::human::HumanFilter::Parameters::velocityAlpha
float velocityAlpha
Definition: HumanFilter.h:61
armarx::navigation::human::HumanFilter::Parameters::velocityAverageBinDistance
unsigned int velocityAverageBinDistance
Definition: HumanFilter.h:64
armarx::core::time::Duration
Represents a duration.
Definition: Duration.h:16
armarx::navigation::human::kalman_filter::ControlSE2
Definition: HumanSystemModel.h:87
Eigen::Matrix
Definition: EigenForwardDeclarations.h:27
UnscentedKalmanFilter.h
HumanSystemModel.h