1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203 | #ifndef MULTIKALMANBALLLOCATOR_H
#define MULTIKALMANBALLLOCATOR_H
#include <ModuleFramework/Module.h>
#include <Eigen/StdVector> //necessary for alignement in std::vector to work
// representations
#include "Representations/Perception/MultiBallPercept.h"
#include "Representations/Modeling/BallModel.h"
#include "Representations/Modeling/BodyState.h"
#include "Representations/Modeling/PlayerInfo.h"
#include "Representations/Modeling/OdometryData.h"
#include "Representations/Modeling/KinematicChain.h"
#include "Representations/Infrastructure/FrameInfo.h"
#include "Representations/Motion/MotionStatus.h"
#include "Representations/Perception/CameraMatrix.h"
#include "Representations/Infrastructure/FieldInfo.h"
// tools
#include "BallHypothesis.h"
#include "UpdateAssociationFunctions.h"
// debug
#include "Tools/Debug/DebugDrawings.h"
#include "Tools/Debug/DebugRequest.h"
#include "Tools/Debug/DebugParameterList.h"
#include "Tools/Debug/DebugPlot.h"
#include "Tools/Debug/Color.h"
//////////////////// BEGIN MODULE INTERFACE DECLARATION ////////////////////
BEGIN_DECLARE_MODULE(MultiKalmanBallLocator)
// debug stuff
PROVIDE(DebugDrawings)
PROVIDE(DebugRequest)
PROVIDE(DebugParameterList)
PROVIDE(DebugPlot)
REQUIRE(FieldInfo)
REQUIRE(BodyState)
REQUIRE(PlayerInfo)
REQUIRE(FrameInfo)
REQUIRE(OdometryData)
// for preview stuff
REQUIRE(MotionStatus)
REQUIRE(KinematicChain)
REQUIRE(MultiBallPercept)
// for extended kalman filter
REQUIRE(CameraInfo)
REQUIRE(CameraInfoTop)
REQUIRE(CameraMatrix)
REQUIRE(CameraMatrixTop)
PROVIDE(BallModel)
END_DECLARE_MODULE(MultiKalmanBallLocator)
//////////////////// END MODULE INTERFACE DECLARATION //////////////////////
class MultiKalmanBallLocator : private MultiKalmanBallLocatorBase
{
public:
MultiKalmanBallLocator();
virtual ~MultiKalmanBallLocator();
virtual void execute();
// from other kalman filter ball locator
private:
OdometryData lastRobotOdometry;
FrameInfo lastFrameInfo;
private:
typedef std::vector<BallHypothesis, Eigen::aligned_allocator<BallHypothesis> > Filters;
Filters filter;
Filters::const_iterator bestModel;
// TODO: does it make sense to use the numerical epsilon: std::numeric_limits<double>::epsilon() or std::numeric_limits<float>::epsilon()?
// TODO: or is this value specific to the algorithms? E.g. ball speed below 1mm/s is considered 0.
const double epsilon=10e-6;
private:
void updateByPerceptsCool();
void updateByPerceptsNormal();
void updateByPerceptsGreedy(CameraInfo::CameraID camera);
void applyOdometryOnFilterState(ExtendedKalmanFilter4d& filter);
void predict(ExtendedKalmanFilter4d& filter, double dt) const;
Filters::const_iterator selectBestModel() const;
Filters::const_iterator selectBestModelBasedOnCovariance() const;
void provideBallModel(const BallHypothesis &model);
/* DEBUG STUFF */
void doDebugRequest();
void doDebugRequestBeforPredictionAndUpdate();
void doDebugRequestBeforUpdate();
void drawFilter(const BallHypothesis& bh, const Color& model_color, Color cov_loc_color, Color cov_vel_color) const;
void drawFiltersOnField() const;
void reloadParameters();
class Parameters: public ParameterList
{
public:
Parameters() : ParameterList("MultiKalmanBallLocator")<--- Member variable 'Parameters::area95Threshold' is not initialized in the constructor.
{
PARAMETER_REGISTER(processNoiseStdQ00) = 15;
PARAMETER_REGISTER(processNoiseStdQ01) = 0;
PARAMETER_REGISTER(processNoiseStdQ10) = 0;
PARAMETER_REGISTER(processNoiseStdQ11) = 20;
// experimental determined
PARAMETER_REGISTER(measurementNoiseR00) = 0.00130217; //[rad^2]
PARAMETER_REGISTER(measurementNoiseR10) = -0.00041764; //[rad^2]
PARAMETER_REGISTER(measurementNoiseR11) = 0.00123935; //[rad^2]
PARAMETER_REGISTER(initialStateStdP00) = 250;
PARAMETER_REGISTER(initialStateStdP01) = 0;
PARAMETER_REGISTER(initialStateStdP10) = 0;
PARAMETER_REGISTER(initialStateStdP11) = 250;
//thresholds for association functions
PARAMETER_REGISTER(euclidThreshold) = Math::fromDegrees(10);
PARAMETER_REGISTER(mahalanobisThreshold) = Math::fromDegrees(10);
PARAMETER_REGISTER(maximumLikelihoodThreshold) = 0.0005;
//AssymetricalBoolFilte parameters
PARAMETER_REGISTER(g0) = 0.01;
PARAMETER_REGISTER(g1) = 0.1;
PARAMETER_REGISTER(association.use_normal) = false;
PARAMETER_REGISTER(association.use_cool) = false;
PARAMETER_REGISTER(association.use_greedy) = true;
PARAMETER_REGISTER(area95Threshold_radius.factor) = std::sqrt(2) * 1;
PARAMETER_REGISTER(area95Threshold_radius.offset) = std::sqrt(2) * 125;
PARAMETER_REGISTER(use_covariance_based_selection) = true;
syncWithConfig();
}
double g0;
double g1;
double processNoiseStdQ00;
double processNoiseStdQ01;
double processNoiseStdQ10;
double processNoiseStdQ11;
double measurementNoiseR00;
double measurementNoiseR10;
double measurementNoiseR11;
double initialStateStdP00;
double initialStateStdP01;
double initialStateStdP10;
double initialStateStdP11;
double area95Threshold;
double euclidThreshold;
double mahalanobisThreshold;
double maximumLikelihoodThreshold;
struct {
bool use_normal;
bool use_cool;
bool use_greedy;
} association;
struct {
double factor;
double offset;
} area95Threshold_radius;
bool use_covariance_based_selection;
} params;
Measurement_Function_H h;
UpdateAssociationFunction* updateAssociationFunction;
// available update association value functions
EuclideanUAF euclid;
MahalanobisUAF mahalanobis;
LikelihoodUAF likelihood;
Eigen::Matrix2d processNoiseStdSingleDimension;
Eigen::Matrix2d measurementNoiseCovariances;
Eigen::Matrix2d initialStateStdSingleDimension;
};
#endif // MULTIKALMANBALLLOCATOR_H
|