SAF
Loading...
Searching...
No Matches
saf_tracker_internal.h
Go to the documentation of this file.
1/*
2 * This file is part of the saf_tracker module.
3 * Copyright (c) 2020 - Leo McCormack
4 *
5 * The saf_tracker module is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * The saf_tracker module is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * See <http://www.gnu.org/licenses/> for a copy of the GNU General Public
16 * License.
17 */
18
44#ifndef __SAF_TRACKER_INTERNAL_H_INCLUDED__
45#define __SAF_TRACKER_INTERNAL_H_INCLUDED__
46
47#include "saf_tracker.h"
49#include "saf_externals.h"
50
51#ifdef __cplusplus
52extern "C" {
53#endif /* __cplusplus */
54
55#ifdef SAF_ENABLE_TRACKER_MODULE
56
58//#define TRACKER_VERBOSE
59#ifdef TRACKER_VERBOSE
61//# define TRACKER_VERY_VERBOSE
62#endif
63
65#define TRACKER3D_MAX_NUM_TARGETS ( 24 )
67#define TRACKER3D_MAX_NUM_EVENTS ( 24 )
69#define TRACKER3D_MAX_NUM_PARTICLES ( 100 )
70
71/* ========================================================================== */
72/* Internal Structures */
73/* ========================================================================== */
74
77typedef void* voidPtr;
78
80typedef struct _M6 {
81 union {
82 struct { float m0, m1, m2, m3, m4, m5; };
83 float M[6];
84 };
85} M6;
86
88typedef struct _P66 {
89 union {
90 struct {
91 float p00, p01, p02, p03, p04, p05,
92 p10, p11, p12, p13, p14, p15,
93 p20, p21, p22, p23, p24, p25,
94 p30, p31, p32, p33, p34, p35,
95 p40, p41, p42, p43, p44, p45,
96 p50, p51, p52, p53, p54, p55;
97 };
98 float P[6][6];
99 };
100} P66;
101
103typedef struct _MCS {
104 float W;
105 float W_prev;
106 float W0;
108 float dt;
109 M6* M;
112 int* Tcount;
114#ifdef TRACKER_VERBOSE
115 char evstr[256];
116#endif
117
118} MCS_data;
119
121typedef struct _tracker3d
122{
125
126 /* Internal */
127 void* hKF6;
130 float R[3][3];
132 float A[6][6];
133 float Q[6][6];
134 float H[3][6];
136 float W0;
138 /* Events */
139#ifdef TRACKER_VERBOSE
140 char evt[TRACKER3D_MAX_NUM_EVENTS][256];
141#endif
149
150
151/* ========================================================================== */
152/* Internal Functions */
153/* ========================================================================== */
154
162void tracker3d_particleCreate(void** phPart,
163 float W0,
164 float dt);
165
171void tracker3d_particleReset(void* hPart);
172
179void tracker3d_particleCopy(void* hPart1,
180 void* hPart2);
181
187void tracker3d_particleDestroy(void** phPart);
188
195void tracker3d_predict(void* const hT3d,
196 int Tinc);
197
205void tracker3d_update(void* const hT3d,
206 float* Y,
207 int Tinc);
208
215int tracker3d_getMaxParticleIdx(void* const hT3d);
216
217
218/* ========================================================================== */
219/* RBMCDA Functions */
220/* ========================================================================== */
221
247void resampstr(voidPtr* SS,
248 int NP,
249 int* s);
250
262float eff_particles(voidPtr* SS,
263 int NP);
264
274 int NP);
275
299void kf_predict6(float M[6],
300 float P[6][6],
301 float A[6][6],
302 float Q[6][6]);
303
305void kf_update6_create(void ** const phUp6);
306
308void kf_update6_destroy(void ** const phUp6);
309
353void kf_update6(void * const hUp6,
354 float X[6],
355 float P[6][6],
356 float y[3],
357 float H[3][6],
358 float R[3][3],
359 float X_out[6],
360 float P_out[6][6],
361 float* LH);
362
374float gamma_cdf(float x,
375 float gam,
376 float beta,
377 float mu);
378
404void lti_disc(/* Input Arguments */
405 float* F,
406 int len_N,
407 int len_Q,
408 float* opt_L,
409 float* opt_Qc,
410 float dt,
411 /* Output Arguments */
412 float* A,
413 float* Q);
414
433float gauss_pdf3(/* Input Arguments */
434 void * const hUp6,
435 float X[3],
436 float M[3],
437 float S[3][3]);
438
447int categ_rnd(float* P,
448 int len_P);
449
450#endif /* SAF_ENABLE_TRACKER_MODULE */
451
452
453#ifdef __cplusplus
454} /* extern "C" */
455#endif /* __cplusplus */
456
457#endif /* __SAF_TRACKER_INTERNAL_H_INCLUDED__ */
Include header for SAF externals.
void * voidPtr
Void pointer (just to improve code readability when working with arrays of handles)
Particle filtering based 3D multi-target tracker (SAF_TRACKER_MODULE)
void tracker3d_update(void *const hT3d, float *Y, int Tinc)
Prediction update.
#define TRACKER3D_MAX_NUM_EVENTS
Maximum number of possible events during update.
void tracker3d_particleDestroy(void **phPart)
Destroys an instance of a particle / Monte-Carlo Sample.
float gamma_cdf(float x, float gam, float beta, float mu)
Cumulative density function of a Gamma distribution.
void kf_update6(void *const hUp6, float X[6], float P[6][6], float y[3], float H[3][6], float R[3][3], float X_out[6], float P_out[6][6], float *LH)
Kalman Filter update step.
void tracker3d_particleReset(void *hPart)
Resets a particle structure to defaults.
int categ_rnd(float *P, int len_P)
Draws samples from a given one dimensional discrete distribution.
void kf_update6_create(void **const phUp6)
Creates helper structure for kf_update6()
void tracker3d_particleCopy(void *hPart1, void *hPart2)
Copies particle structure "hPart1" into structure "hPart2".
void tracker3d_predict(void *const hT3d, int Tinc)
Prediction step.
void lti_disc(float *F, int len_N, int len_Q, float *opt_L, float *opt_Qc, float dt, float *A, float *Q)
LTI_DISC Discretize LTI ODE with Gaussian Noise.
int tracker3d_getMaxParticleIdx(void *const hT3d)
Returns the index of the most important particle.
void tracker3d_particleCreate(void **phPart, float W0, float dt)
Creates an instance of a particle / Monte-Carlo Sample.
void normalise_weights(voidPtr *SS, int NP)
Normalises the weights of the given particles.
float gauss_pdf3(void *const hUp6, float X[3], float M[3], float S[3][3])
Multivariate Gaussian PDF.
void * voidPtr
Void pointer (just to improve code readability when working with arrays of handles)
float eff_particles(voidPtr *SS, int NP)
Estimate the number of effective particles.
void kf_update6_destroy(void **const phUp6)
Destroys helper structure for kf_update6()
void kf_predict6(float M[6], float P[6][6], float A[6][6], float Q[6][6])
Perform Kalman Filter prediction step.
void resampstr(voidPtr *SS, int NP, int *s)
Stratified resampling - returns a new set of indices according to the probabilities P.
Main header for the utilities module (SAF_UTILITIES_MODULE)
static const double p11[19]
Table 1: Coefficients for Eqs.
Union struct for 3-D mean values.
Monte-Carlo Sample (particle) structure.
P66 * P
Current target variances; nTargets x ([6][6])
float dt
Elapsed time between each observation/measurement.
float W
Importance weight.
int * targetIDs
Unique ID assigned to each target; nTargets x 1.
float W0
PRIOR importance weight.
int nTargets
Number of targets being tracked.
int * Tcount
Time elapsed since birth of target (Tcount * dt); nTargets x 1.
float W_prev
Previous importance weight.
M6 * M
Current target means; nTargets x ([6])
Union struct for 3-D variance values.
User parameters for tracker3d.
Definition saf_tracker.h:59
Main structure for tracker3d.
int incrementTime
Number steps of "tpars.dt" to increment time by.
float W0
PRIOR importance weight.
tracker3d_config tpars
User parameters struct.
voidPtr * SS_resamp
Resampled particles; tpars.Np x 1.
voidPtr * SS
The particles; tpars.Np x 1.
void * hKF6
kf_update6 handle