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:
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;
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:
100 using SystemModelT = kalman_filter::SystemModelSE2<double>;
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
Represents a point in time.
Definition DateTime.h:25
Represents a duration.
Definition Duration.h:17
const Human & get() const
HumanFilter::get returns the human whose pose is filtered containing the most recent state.
void propagation(const DateTime &detectionTime)
HumanFilter::propagation propagate the system model to the given point in time.
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...
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...
Duration detectionAge(const DateTime &currentTime) const
Eigen::Isometry2f Pose2D
Definition basic_types.h:34
This file is part of ArmarX.