32 #include <sys/types.h> 42 return atan2(sin(z),cos(z));
51 d2 = 2*M_PI - fabs(d1);
54 if(fabs(d1) < fabs(d2))
128 double delta_trans, delta_rot, delta_bearing;
129 double delta_trans_hat, delta_rot_hat, delta_strafe_hat;
131 delta_trans = sqrt(ndata->
delta.
v[0]*ndata->
delta.
v[0] +
133 delta_rot = ndata->
delta.
v[2];
136 double trans_hat_stddev = (
alpha3 * (delta_trans*delta_trans) +
137 alpha1 * (delta_rot*delta_rot));
138 double rot_hat_stddev = (
alpha4 * (delta_rot*delta_rot) +
139 alpha2 * (delta_trans*delta_trans));
140 double strafe_hat_stddev = (
alpha1 * (delta_rot*delta_rot) +
141 alpha5 * (delta_trans*delta_trans));
143 for (
int i = 0; i <
set->sample_count; i++)
148 old_pose.
v[2]) + sample->
pose.
v[2];
149 double cs_bearing = cos(delta_bearing);
150 double sn_bearing = sin(delta_bearing);
157 sample->
pose.
v[0] += (delta_trans_hat * cs_bearing +
158 delta_strafe_hat * sn_bearing);
159 sample->
pose.
v[1] += (delta_trans_hat * sn_bearing -
160 delta_strafe_hat * cs_bearing);
161 sample->
pose.
v[2] += delta_rot_hat ;
168 double delta_rot1, delta_trans, delta_rot2;
169 double delta_rot1_hat, delta_trans_hat, delta_rot2_hat;
170 double delta_rot1_noise, delta_rot2_noise;
180 delta_trans = sqrt(ndata->
delta.
v[0]*ndata->
delta.
v[0] +
187 delta_rot1_noise = std::min(fabs(
angle_diff(delta_rot1,0.0)),
189 delta_rot2_noise = std::min(fabs(
angle_diff(delta_rot2,0.0)),
192 for (
int i = 0; i <
set->sample_count; i++)
199 this->
alpha2*delta_trans*delta_trans));
200 delta_trans_hat = delta_trans -
202 this->
alpha4*delta_rot1_noise*delta_rot1_noise +
203 this->
alpha4*delta_rot2_noise*delta_rot2_noise);
206 this->
alpha2*delta_trans*delta_trans));
209 sample->
pose.
v[0] += delta_trans_hat *
210 cos(sample->
pose.
v[2] + delta_rot1_hat);
211 sample->
pose.
v[1] += delta_trans_hat *
212 sin(sample->
pose.
v[2] + delta_rot1_hat);
213 sample->
pose.
v[2] += delta_rot1_hat + delta_rot2_hat;
219 double delta_trans, delta_rot, delta_bearing;
220 double delta_trans_hat, delta_rot_hat, delta_strafe_hat;
222 delta_trans = sqrt(ndata->
delta.
v[0]*ndata->
delta.
v[0] +
224 delta_rot = ndata->
delta.
v[2];
227 double trans_hat_stddev = sqrt(
alpha3 * (delta_trans*delta_trans) +
228 alpha1 * (delta_rot*delta_rot) );
229 double rot_hat_stddev = sqrt(
alpha4 * (delta_rot*delta_rot) +
230 alpha2 * (delta_trans*delta_trans) );
231 double strafe_hat_stddev = sqrt(
alpha1 * (delta_rot*delta_rot) +
232 alpha5 * (delta_trans*delta_trans) );
234 for (
int i = 0; i <
set->sample_count; i++)
239 old_pose.
v[2]) + sample->
pose.
v[2];
240 double cs_bearing = cos(delta_bearing);
241 double sn_bearing = sin(delta_bearing);
248 sample->
pose.
v[0] += (delta_trans_hat * cs_bearing +
249 delta_strafe_hat * sn_bearing);
250 sample->
pose.
v[1] += (delta_trans_hat * sn_bearing -
251 delta_strafe_hat * cs_bearing);
252 sample->
pose.
v[2] += delta_rot_hat ;
259 double delta_rot1, delta_trans, delta_rot2;
260 double delta_rot1_hat, delta_trans_hat, delta_rot2_hat;
261 double delta_rot1_noise, delta_rot2_noise;
271 delta_trans = sqrt(ndata->
delta.
v[0]*ndata->
delta.
v[0] +
278 delta_rot1_noise = std::min(fabs(
angle_diff(delta_rot1,0.0)),
280 delta_rot2_noise = std::min(fabs(
angle_diff(delta_rot2,0.0)),
283 for (
int i = 0; i <
set->sample_count; i++)
290 this->
alpha2*delta_trans*delta_trans)));
291 delta_trans_hat = delta_trans -
293 this->
alpha4*delta_rot1_noise*delta_rot1_noise +
294 this->
alpha4*delta_rot2_noise*delta_rot2_noise));
297 this->
alpha2*delta_trans*delta_trans)));
300 sample->
pose.
v[0] += delta_trans_hat *
301 cos(sample->
pose.
v[2] + delta_rot1_hat);
302 sample->
pose.
v[1] += delta_trans_hat *
303 sin(sample->
pose.
v[2] + delta_rot1_hat);
304 sample->
pose.
v[2] += delta_rot1_hat + delta_rot2_hat;
void SetModelOmni(double alpha1, double alpha2, double alpha3, double alpha4, double alpha5)
pf_vector_t pf_vector_sub(pf_vector_t a, pf_vector_t b)
virtual bool UpdateAction(pf_t *pf, AMCLSensorData *data)
void SetModel(odom_model_t type, double alpha1, double alpha2, double alpha3, double alpha4, double alpha5=0)
static double angle_diff(double a, double b)
void SetModelDiff(double alpha1, double alpha2, double alpha3, double alpha4)
double pf_ran_gaussian(double sigma)
static double normalize(double z)