28 #pragma GCC diagnostic ignored "-Wpedantic"
38 #include "nav2_amcl/pf/pf.hpp"
39 #include "nav2_amcl/pf/pf_pdf.hpp"
40 #include "nav2_amcl/pf/pf_kdtree.hpp"
43 void pf_draw_statistics(
pf_t * pf, rtk_fig_t * fig);
47 void pf_draw_samples(
pf_t * pf, rtk_fig_t * fig,
int max_samples)
54 set = pf->sets + pf->current_set;
55 max_samples = MIN(max_samples, set->sample_count);
57 for (i = 0; i < max_samples; i++) {
58 sample = set->samples + i;
60 px = sample->pose.v[0];
61 py = sample->pose.v[1];
62 pa = sample->pose.v[2];
66 rtk_fig_point(fig, px, py);
67 rtk_fig_arrow(fig, px, py, pa, 0.1, 0.02);
74 void pf_draw_hist(
pf_t * pf, rtk_fig_t * fig)
78 set = pf->sets + pf->current_set;
80 rtk_fig_color(fig, 0.0, 0.0, 1.0);
81 pf_kdtree_draw(set->kdtree, fig);
99 void pf_draw_cluster_stats(
pf_t * pf, rtk_fig_t * fig)
107 double weight, o, d1, d2;
109 set = pf->sets + pf->current_set;
111 for (i = 0; i < set->cluster_count; i++) {
112 cluster = set->clusters + i;
114 weight = cluster->weight;
115 mean = cluster->mean;
119 pf_matrix_unitary(&r, &d, cov);
133 o = atan2(r.m[1][0], r.m[0][0]);
134 d1 = 6 * sqrt(d.m[0][0]);
135 d2 = 6 * sqrt(d.m[1][1]);
137 if (d1 > 1e-3 && d2 > 1e-3) {
139 rtk_fig_ellipse(fig, mean.v[0], mean.v[1], o, d1, d2, 0);
140 rtk_fig_line_ex(fig, mean.v[0], mean.v[1], o, d1);
141 rtk_fig_line_ex(fig, mean.v[0], mean.v[1], o + M_PI / 2, d2);
145 rtk_fig_arrow(fig, mean.v[0], mean.v[1], mean.v[2], 0.50, 0.10);
146 rtk_fig_arrow(fig, mean.v[0], mean.v[1], mean.v[2] + 3 * sqrt(cov.m[2][2]), 0.50, 0.10);
147 rtk_fig_arrow(fig, mean.v[0], mean.v[1], mean.v[2] - 3 * sqrt(cov.m[2][2]), 0.50, 0.10);