Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 #ifndef PF_H
00029 #define PF_H
00030 
00031 #include "pf_vector.h"
00032 #include "pf_kdtree.h"
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038 
00039 struct _pf_t;
00040 struct _rtk_fig_t;
00041 struct _pf_sample_set_t;
00042 
00043 
00044 
00045 typedef pf_vector_t (*pf_init_model_fn_t) (void *init_data);
00046 
00047 
00048 
00049 typedef void (*pf_action_model_fn_t) (void *action_data, 
00050                                       struct _pf_sample_set_t* set);
00051 
00052 
00053 
00054 typedef double (*pf_sensor_model_fn_t) (void *sensor_data, 
00055                                         struct _pf_sample_set_t* set);
00056 
00057 
00058 
00059 typedef struct
00060 {
00061   
00062   pf_vector_t pose;
00063 
00064   
00065   double weight;
00066   
00067 } pf_sample_t;
00068 
00069 
00070 
00071 typedef struct
00072 {
00073   
00074   int count;
00075 
00076   
00077   double weight;
00078 
00079   
00080   pf_vector_t mean;
00081   pf_matrix_t cov;
00082 
00083   
00084   double m[4], c[2][2];
00085   
00086 } pf_cluster_t;
00087 
00088 
00089 
00090 typedef struct _pf_sample_set_t
00091 {
00092   
00093   int sample_count;
00094   pf_sample_t *samples;
00095 
00096   
00097   pf_kdtree_t *kdtree;
00098 
00099   
00100   int cluster_count, cluster_max_count;
00101   pf_cluster_t *clusters;
00102 
00103   
00104   pf_vector_t mean;
00105   pf_matrix_t cov;
00106 
00107 } pf_sample_set_t;
00108 
00109 
00110 
00111 typedef struct _pf_t
00112 {
00113   
00114   int min_samples, max_samples;
00115 
00116   
00117   double pop_err, pop_z;
00118   
00119   
00120   
00121   int current_set;
00122   pf_sample_set_t sets[2];
00123 
00124   
00125   double w_slow, w_fast;
00126 
00127   
00128   double alpha_slow, alpha_fast;
00129 
00130   
00131   pf_init_model_fn_t random_pose_fn;
00132   void *random_pose_data;
00133 } pf_t;
00134 
00135 
00136 
00137 pf_t *pf_alloc(int min_samples, int max_samples,
00138                double alpha_slow, double alpha_fast,
00139                pf_init_model_fn_t random_pose_fn, void *random_pose_data);
00140 
00141 
00142 void pf_free(pf_t *pf);
00143 
00144 
00145 void pf_init(pf_t *pf, pf_vector_t mean, pf_matrix_t cov);
00146 
00147 
00148 void pf_init_model(pf_t *pf, pf_init_model_fn_t init_fn, void *init_data);
00149 
00150 
00151 void pf_update_action(pf_t *pf, pf_action_model_fn_t action_fn, void *action_data);
00152 
00153 
00154 void pf_update_sensor(pf_t *pf, pf_sensor_model_fn_t sensor_fn, void *sensor_data);
00155 
00156 
00157 void pf_update_resample(pf_t *pf);
00158 
00159 
00160 void pf_get_cep_stats(pf_t *pf, pf_vector_t *mean, double *var);
00161 
00162 
00163 
00164 int pf_get_cluster_stats(pf_t *pf, int cluster, double *weight,
00165                          pf_vector_t *mean, pf_matrix_t *cov);
00166 
00167 
00168 void pf_draw_samples(pf_t *pf, struct _rtk_fig_t *fig, int max_samples);
00169 
00170 
00171 void pf_draw_hist(pf_t *pf, struct _rtk_fig_t *fig);
00172 
00173 
00174 void pf_draw_cep_stats(pf_t *pf, struct _rtk_fig_t *fig);
00175 
00176 
00177 void pf_draw_cluster_stats(pf_t *pf, struct _rtk_fig_t *fig);
00178 
00179 #ifdef __cplusplus
00180 }
00181 #endif
00182 
00183 
00184 #endif