RevoluteJointFilter.cpp
Go to the documentation of this file.
2 
4 
5 #include <Eigen/Geometry>
6 
7 #include <boost/math/distributions/chi_squared.hpp>
8 
9 #include "geometry_msgs/PoseWithCovarianceStamped.h"
10 
11 #include "std_msgs/Float64MultiArray.h"
12 
13 using namespace omip;
14 using namespace MatrixWrapper;
15 using namespace BFL;
16 
17 // Dimensions of the system state of the filter that tracks a revolute joint: orientation (2 values), position (3 values), joint variable, and joint velocity
18 #define REV_STATE_DIM 7
19 #define MEAS_DIM 6
20 
43 using namespace omip;
44 
46  JointFilter(),
47  _sys_PDF(NULL),
48  _sys_MODEL(NULL),
49  _meas_PDF(NULL),
50  _meas_MODEL(NULL),
51  _ekf(NULL),
52  _sigma_delta_meas_uncertainty_angular(-1),
53  _accumulated_rotation(0.0)
54 {
55 }
56 
57 void RevoluteJointFilter::setCovarianceDeltaMeasurementAngular(double sigma_delta_meas_uncertainty_angular)
58 {
59  this->_sigma_delta_meas_uncertainty_angular = sigma_delta_meas_uncertainty_angular;
60 }
61 
63 {
65  this->_joint_orientation = Eigen::Vector3d( this->_current_delta_pose_in_rrbf.rx(),
66  this->_current_delta_pose_in_rrbf.ry(),
67  this->_current_delta_pose_in_rrbf.rz());
68  this->_joint_state = this->_joint_orientation.norm();
69  //this->_joint_velocity = this->_joint_state/(this->_loop_period_ns/1e9);
70  // Setting it to 0 is better.
71  // The best approximation would be to (this->_joint_state/num_steps_to_joint_state)/(this->_loop_period_ns/1e9)
72  // but we don't know how many steps passed since we estimated the first time the joint variable
73  this->_joint_velocity = 0.0;
74 
75  this->_joint_states_all.push_back(this->_joint_state);
76 
77  Eigen::Vector3d linear_part = Eigen::Vector3d( this->_current_delta_pose_in_rrbf.vx(),
78  this->_current_delta_pose_in_rrbf.vy(),
79  this->_current_delta_pose_in_rrbf.vz());
80 // Alternative
81 // Eigen::Matrix4d ht;
82 // Twist2TransformMatrix(_current_delta_pose_in_rrbf, ht);
83 
84 // this->_joint_position = ht.block<3,1>(0,3)
85 // - ht.block<3,3>(0,0)*ht.block<3,1>(0,3);
86 
87  this->_joint_position = (1.0 / (pow(this->_joint_state, 2))) * this->_joint_orientation.cross(linear_part);
88  this->_joint_orientation.normalize();
89 
90  this->_initializeSystemModel();
92  this->_initializeEKF();
93 }
94 
96 {
97  _rev_min_rot_for_ee = value;
98 }
99 
101 {
103 }
104 
106 {
107  // create SYSTEM MODEL
108  Matrix A(REV_STATE_DIM, REV_STATE_DIM);
109  A = 0.;
110  for (unsigned int i = 1; i <= REV_STATE_DIM; i++)
111  {
112  A(i, i) = 1.0;
113  }
114  A(6, 7) = this->_loop_period_ns/1e9; //Adding the velocity to the position of the joint variable
115 
116  ColumnVector sys_noise_MU(REV_STATE_DIM);
117  sys_noise_MU = 0;
118 
119  SymmetricMatrix sys_noise_COV(REV_STATE_DIM);
120  sys_noise_COV = 0.0;
121  sys_noise_COV(1, 1) = this->_sigma_sys_noise_phi* (std::pow((this->_loop_period_ns/1e9),3) / 3.0); // PHI
122  sys_noise_COV(2, 2) = this->_sigma_sys_noise_theta* (std::pow((this->_loop_period_ns/1e9),3) / 3.0); // THETA
123  sys_noise_COV(3, 3) = this->_sigma_sys_noise_px* (std::pow((this->_loop_period_ns/1e9),3) / 3.0); // Px
124  sys_noise_COV(4, 4) = this->_sigma_sys_noise_py* (std::pow((this->_loop_period_ns/1e9),3) / 3.0); // Py
125  sys_noise_COV(5, 5) = this->_sigma_sys_noise_pz* (std::pow((this->_loop_period_ns/1e9),3) / 3.0); // Pz
126  sys_noise_COV(6, 6) = this->_sigma_sys_noise_jv* (std::pow((this->_loop_period_ns/1e9),3) / 3.0); // pv
127  sys_noise_COV(7, 7) = this->_sigma_sys_noise_jvd*(this->_loop_period_ns/1e9); // d(pv)/dt
128 
129  // Initialize System Model
130  Gaussian system_uncertainty_PDF(sys_noise_MU, sys_noise_COV);
131  this->_sys_PDF = new LinearAnalyticConditionalGaussian( A, system_uncertainty_PDF);
132  this->_sys_MODEL = new LinearAnalyticSystemModelGaussianUncertainty( this->_sys_PDF);
133 }
134 
136 {
137  // create MEASUREMENT MODEL
138  ColumnVector meas_noise_MU(MEAS_DIM);
139  meas_noise_MU = 0.0;
140  SymmetricMatrix meas_noise_COV(MEAS_DIM);
141  meas_noise_COV = 0.0;
142  for (unsigned int i = 1; i <= MEAS_DIM; i++)
143  meas_noise_COV(i, i) = this->_sigma_meas_noise;
144 
145  Gaussian meas_uncertainty_PDF(meas_noise_MU, meas_noise_COV);
146 
147  this->_meas_PDF = new NonLinearRevoluteMeasurementPdf(meas_uncertainty_PDF);
148  this->_meas_MODEL = new AnalyticMeasurementModelGaussianUncertainty(this->_meas_PDF);
149 }
150 
152 {
153  ColumnVector prior_MU(REV_STATE_DIM);
154  prior_MU = 0.0;
155 
156  SymmetricMatrix prior_COV(REV_STATE_DIM);
157  prior_COV = 0.0;
158 
159  // This is weird but happens when working with synthetic data
160  // We don't want to divide by 0!
161  if(this->_joint_orientation.x() == 0.0)
162  {
163  this->_joint_orientation.x() = 1e-6;
164  }
165 
166  prior_MU(1) = atan2( this->_joint_orientation.y() , this->_joint_orientation.x());
167  prior_MU(2) = acos(this->_joint_orientation.z());
168  prior_MU(3) = this->_joint_position.x();
169  prior_MU(4) = this->_joint_position.y();
170  prior_MU(5) = this->_joint_position.z();
171  prior_MU(6) = this->_joint_state;
172  prior_MU(7) = this->_joint_velocity;
173 
174 
175  for (int i = 1; i <= REV_STATE_DIM; i++)
176  {
177  prior_COV(i, i) = _prior_cov_vel;
178  }
179 
180  Gaussian prior_PDF(prior_MU, prior_COV);
181 
182  this->_ekf = new ExtendedKalmanFilter(&prior_PDF);
183 }
184 
186 {
187  if (this->_sys_PDF)
188  {
189  delete this->_sys_PDF;
190  this->_sys_PDF = NULL;
191  }
192  if (this->_sys_MODEL)
193  {
194  delete this->_sys_MODEL;
195  this->_sys_MODEL = NULL;
196  }
197  if (this->_meas_PDF)
198  {
199  delete this->_meas_PDF;
200  this->_meas_PDF = NULL;
201  }
202  if (this->_meas_MODEL)
203  {
204  delete this->_meas_MODEL;
205  this->_meas_MODEL = NULL;
206  }
207  if (this->_ekf)
208  {
209  delete this->_ekf;
210  this->_ekf = NULL;
211  }
212 }
213 
215  JointFilter(rev_joint)
216 {
218  this->_sys_PDF = new LinearAnalyticConditionalGaussian(*(rev_joint._sys_PDF));
219  this->_sys_MODEL = new LinearAnalyticSystemModelGaussianUncertainty( *(rev_joint._sys_MODEL));
220  this->_meas_PDF = new NonLinearRevoluteMeasurementPdf(*(rev_joint._meas_PDF));
221  this->_meas_MODEL = new AnalyticMeasurementModelGaussianUncertainty( *(rev_joint._meas_MODEL));
222  this->_ekf = new ExtendedKalmanFilter(*(rev_joint._ekf));
223 }
224 
225 void RevoluteJointFilter::predictState(double time_interval_ns)
226 {
227  // Estimate the new cov matrix depending on the time elapsed between the previous and the current measurement
228  SymmetricMatrix sys_noise_COV(REV_STATE_DIM);
229  sys_noise_COV = 0.0;
230  sys_noise_COV(1, 1) = this->_sigma_sys_noise_phi* (std::pow((time_interval_ns/1e9),3) / 3.0); // PHI
231  sys_noise_COV(2, 2) = this->_sigma_sys_noise_theta* (std::pow((time_interval_ns/1e9),3) / 3.0); // THETA
232  sys_noise_COV(3, 3) = this->_sigma_sys_noise_px* (std::pow((time_interval_ns/1e9),3) / 3.0); // Px
233  sys_noise_COV(4, 4) = this->_sigma_sys_noise_py* (std::pow((time_interval_ns/1e9),3) / 3.0); // Py
234  sys_noise_COV(5, 5) = this->_sigma_sys_noise_pz* (std::pow((time_interval_ns/1e9),3) / 3.0); // Pz
235  sys_noise_COV(6, 6) = this->_sigma_sys_noise_jv* (std::pow((time_interval_ns/1e9),3) / 3.0); // pv
236  sys_noise_COV(7, 7) = this->_sigma_sys_noise_jvd*(time_interval_ns/1e9); // d(pv)/dt
237 
238  // Estimate the new updating matrix which also depends on the time elapsed between the previous and the current measurement
239  // x(t+1) = x(t) + v(t) * delta_t
240  Matrix A(REV_STATE_DIM, REV_STATE_DIM);
241  A = 0.;
242  for (unsigned int i = 1; i <= REV_STATE_DIM; i++)
243  {
244  A(i, i) = 1.0;
245  }
246  A(6, 7) = time_interval_ns/1e9;; //Adding the velocity (times the time) to the position of the joint variable
247 
248  this->_sys_PDF->MatrixSet(0, A);
249  this->_sys_PDF->AdditiveNoiseSigmaSet(sys_noise_COV);
250  //The system update
251  this->_ekf->Update(this->_sys_MODEL);
252 }
253 
255 {
256  ColumnVector empty;
257  ColumnVector state_updated_state = this->_ekf->PostGet()->ExpectedValueGet();
258 
259  ColumnVector predicted_delta_pose_in_rrbf = this->_meas_MODEL->PredictionGet(empty, state_updated_state);
260 
261  this->_predicted_delta_pose_in_rrbf = Eigen::Twistd( predicted_delta_pose_in_rrbf(4), predicted_delta_pose_in_rrbf(5),
262  predicted_delta_pose_in_rrbf(6), predicted_delta_pose_in_rrbf(1),
263  predicted_delta_pose_in_rrbf(2), predicted_delta_pose_in_rrbf(3));
264 
265  Eigen::Displacementd predicted_delta = this->_predicted_delta_pose_in_rrbf.exp(1e-20);
266  Eigen::Displacementd T_rrbf_srbf_t0 = this->_srb_initial_pose_in_rrbf.exp(1.0e-20);
267  Eigen::Displacementd T_rrbf_srbf_t_next = predicted_delta * T_rrbf_srbf_t0;
268 
269  this->_srb_predicted_pose_in_rrbf = T_rrbf_srbf_t_next.log(1.0e-20);
270 
271  bool change = false;
273 
275 }
276 
278 {
279  ColumnVector updated_state = this->_ekf->PostGet()->ExpectedValueGet();
280  ColumnVector rb2_measured_delta_relative_pose_cv(MEAS_DIM);
281  rb2_measured_delta_relative_pose_cv = 0.;
282  rb2_measured_delta_relative_pose_cv(1) = this->_current_delta_pose_in_rrbf.vx();
283  rb2_measured_delta_relative_pose_cv(2) = this->_current_delta_pose_in_rrbf.vy();
284  rb2_measured_delta_relative_pose_cv(3) = this->_current_delta_pose_in_rrbf.vz();
285  rb2_measured_delta_relative_pose_cv(4) = this->_current_delta_pose_in_rrbf.rx();
286  rb2_measured_delta_relative_pose_cv(5) = this->_current_delta_pose_in_rrbf.ry();
287  rb2_measured_delta_relative_pose_cv(6) = this->_current_delta_pose_in_rrbf.rz();
288 
289  // Update the uncertainty on the measurement
290  // The uncertainty on the measurement (the delta motion of the second rigid body wrt the reference rigid body) will be large if the measurement
291  // is small and small if the measurement is large
292  // Also at 2PI the uncertainty should be high (rotational periodicity of the exponential map)
293  Eigen::Vector3d angular_component(this->_current_delta_pose_in_rrbf.rx(), this->_current_delta_pose_in_rrbf.ry(), this->_current_delta_pose_in_rrbf.rz());
294  double meas_uncertainty_factor = 1 / (1.0 - exp(-sin(angular_component.norm()/2.0)/this->_sigma_delta_meas_uncertainty_angular));
295 
296  // Truncate the factor
297  meas_uncertainty_factor = std::min(meas_uncertainty_factor, 1e6);
298 
299  SymmetricMatrix current_delta_pose_cov_in_rrbf(6);
300  for (unsigned int i = 0; i < 6; i++)
301  {
302  for (unsigned int j = 0; j < 6; j++)
303  {
304  current_delta_pose_cov_in_rrbf(i + 1, j + 1) = _current_delta_pose_cov_in_rrbf(i, j);
305  }
306  }
307 
308  this->_meas_PDF->AdditiveNoiseSigmaSet(current_delta_pose_cov_in_rrbf * meas_uncertainty_factor );
309 
310  this->_ekf->Update(this->_meas_MODEL, rb2_measured_delta_relative_pose_cv);
311 
312  updated_state = this->_ekf->PostGet()->ExpectedValueGet();
313 
314  this->_joint_orientation(0) = sin(updated_state(2)) * cos(updated_state(1));
315  this->_joint_orientation(1) = sin(updated_state(2)) * sin(updated_state(1));
316  this->_joint_orientation(2) = cos(updated_state(2));
317 
318  SymmetricMatrix updated_uncertainty = this->_ekf->PostGet()->CovarianceGet();
319 
320  for(int i=0; i<3; i++)
321  {
322  this->_joint_position(i) = updated_state(i+3);
323  for(int j=0; j<3; j++)
324  {
325  this->_uncertainty_joint_position(i,j) = updated_uncertainty(i+3, j+3);
326  }
327  }
328 
329  double joint_state_before = _joint_state;
330 
331  // This jump should happen if we are close to 2PI or -2PI rotation
333  {
334  _accumulated_rotation = std::round(joint_state_before/(2*M_PI))*2*M_PI;
335  }
336 
337  // This jump should happen if we are close to PI or -PI rotation
339  {
340  _accumulated_rotation = std::round(joint_state_before/(M_PI))*2*M_PI;
341  }
342 
343  this->_joint_state = updated_state(6);
344 
345  // If we are inverting the twist is because we are in the interval (PI, 2PI) or (-PI, -2PI)
347  {
349  }else{
351  }
352 
353 
354  this->_uncertainty_joint_state = updated_uncertainty(6,6);
355  this->_joint_velocity = updated_state(7);
356  this->_uncertainty_joint_velocity = updated_uncertainty(7,7);
357 
358  this->_joint_orientation_phi = updated_state(1);
359  this->_joint_orientation_theta = updated_state(2);
360  this->_uncertainty_joint_orientation_phitheta(0,0) = updated_uncertainty(1, 1);
361  this->_uncertainty_joint_orientation_phitheta(0,1) = updated_uncertainty(1, 2);
362  this->_uncertainty_joint_orientation_phitheta(1,0) = updated_uncertainty(1, 2);
363  this->_uncertainty_joint_orientation_phitheta(1,1) = updated_uncertainty(2, 2);
364 }
365 
367 {
368  double accumulated_error = 0.;
369 
370  double p_one_meas_given_model_params = 0;
371  double p_all_meas_given_model_params = 0;
372 
373  double sigma_translation = 0.05;
374  double sigma_rotation = 0.2;
375 
376  ColumnVector updated_state = this->_ekf->PostGet()->ExpectedValueGet();
377  double phi = updated_state(1);
378  double theta = updated_state(2);
379  double sp = sin(phi);
380  double cp = cos(phi);
381  double st = sin(theta);
382  double ct = cos(theta);
383 
384  double px = updated_state(3);
385  double py = updated_state(4);
386  double pz = updated_state(5);
387 
388  this->_joint_states_all.push_back(updated_state(6));
389 
390  Eigen::Vector3d rev_joint_rotation_unitary = Eigen::Vector3d(cp * st, sp * st, ct);
391  rev_joint_rotation_unitary.normalize();
392 
393  // Convert the screw attributes (line description) to a twist
394  Eigen::Vector3d rev_joint_position = Eigen::Vector3d(px, py, pz);
395  Eigen::Vector3d rev_joint_translation_unitary = (-rev_joint_rotation_unitary).cross(rev_joint_position);
396 
397  double counter = 0.;
398  size_t trajectory_length = this->_delta_poses_in_rrbf.size();
399  size_t amount_samples = std::min(trajectory_length, (size_t)this->_likelihood_sample_num);
400  double delta_idx_samples = (double)std::max(1., (double)trajectory_length/(double)this->_likelihood_sample_num);
401  size_t current_idx = 0;
402 
403  double max_norm_of_deltas = 0;
404 
405  // Estimation of the quality of the parameters of the revolute joint
406  // If the joint is revolute and the parameters are accurate, the joint axis orientation and position should not change over time
407  // That means that the current orientation/position, multiplied by the amount of revolute displacement at each time step, should provide the delta in the relative
408  // pose between ref and second rb at each time step
409  // We test amount_samples of the relative trajectory
410  // I check if the joint is too young or if there is too few rotation and the axis is very far away (a prismatic joint can be seen as a revolute joint where the
411  // joint is far away)
412  // We need to have memory here: if the rotation was once larger than the this->_rev_min_rot_for_ee could be that we returned to the starting relative pose
413 
414  for (size_t sample_idx = 0; sample_idx < amount_samples; sample_idx++)
415  {
416  current_idx = boost::math::round(sample_idx*delta_idx_samples);
417  Eigen::Displacementd rb2_last_delta_relative_displ = this->_delta_poses_in_rrbf.at(current_idx).exp(1e-12);
418 
419  max_norm_of_deltas = std::max(this->_delta_poses_in_rrbf.at(current_idx).norm(), max_norm_of_deltas);
420 
421  Eigen::Vector3d rb2_last_delta_relative_translation = rb2_last_delta_relative_displ.getTranslation();
422  Eigen::Quaterniond rb2_last_delta_relative_rotation = Eigen::Quaterniond(rb2_last_delta_relative_displ.qw(),
423  rb2_last_delta_relative_displ.qx(),
424  rb2_last_delta_relative_displ.qy(),
425  rb2_last_delta_relative_displ.qz());
426 
427  Eigen::Vector3d rev_joint_translation = this->_joint_states_all.at(current_idx) * rev_joint_translation_unitary;
428  Eigen::Vector3d rev_joint_rotation = this->_joint_states_all.at(current_idx) * rev_joint_rotation_unitary;
429  Eigen::Displacementd rb2_last_delta_relative_displ_rev_hyp = Eigen::Twistd( rev_joint_rotation.x(),
430  rev_joint_rotation.y(),
431  rev_joint_rotation.z(),
432  rev_joint_translation.x(),
433  rev_joint_translation.y(),
434  rev_joint_translation.z()).exp(1e-12);
435  Eigen::Vector3d rb2_last_delta_relative_translation_rev_hyp = rb2_last_delta_relative_displ_rev_hyp.getTranslation();
436  Eigen::Quaterniond rb2_last_delta_relative_rotation_rev_hyp = Eigen::Quaterniond(rb2_last_delta_relative_displ_rev_hyp.qw(),
437  rb2_last_delta_relative_displ_rev_hyp.qx(),
438  rb2_last_delta_relative_displ_rev_hyp.qy(),
439  rb2_last_delta_relative_displ_rev_hyp.qz());
440 
441  // Distance proposed by park and okamura in "Kinematic calibration using the product of exponentials formula"
442  double translation_error = (rb2_last_delta_relative_translation - rb2_last_delta_relative_translation_rev_hyp).norm();
443  Eigen::Quaterniond rotation_error = rb2_last_delta_relative_rotation.inverse() * rb2_last_delta_relative_rotation_rev_hyp;
444  double rotation_error_angle = Eigen::Displacementd(0., 0., 0., rotation_error.w(), rotation_error.x(), rotation_error.y(), rotation_error.z()).log(1e-12).norm();
445 
446  accumulated_error += translation_error + fabs(rotation_error_angle);
447 
448  p_one_meas_given_model_params = (1.0/(sigma_translation*sqrt(2.0*M_PI)))*exp((-1.0/2.0)*pow(translation_error/sigma_translation, 2)) *
449  (1.0/(sigma_rotation*sqrt(2.0*M_PI)))*exp((-1.0/2.0)*pow(rotation_error_angle/sigma_rotation, 2));
450 
451  p_all_meas_given_model_params += (p_one_meas_given_model_params/(double)amount_samples);
452 
453  counter++;
454  }
455 
456  if(counter != 0)
457  {
458  this->_measurements_likelihood = p_all_meas_given_model_params;
459  }else{
460  this->_measurements_likelihood = 1e-5;
461  }
462 }
463 
465 {
466  Eigen::Vector3d point1_in_rrbf = this->_joint_position + 100*this->_joint_orientation;
467  Eigen::Vector3d point2_in_rrbf = this->_joint_position - 100*this->_joint_orientation;
468 
469  // The joint position and orientation are in rrb frame.
470 
471  double p_params_given_model = 1;
472 
473  // We only measure the distance to the reference rb if it is not the static environment!
474  double distance_to_rrb = 0;
475  if(_rrb_id != 0)
476  {
477  distance_to_rrb = (point2_in_rrbf- point1_in_rrbf).cross(point1_in_rrbf).norm()/((point2_in_rrbf - point1_in_rrbf).norm());
478  p_params_given_model *= (1.0/(_rev_max_joint_distance_for_ee*sqrt(2.0*M_PI)))*exp((-1.0/2.0)*pow(distance_to_rrb/_rev_max_joint_distance_for_ee, 2));
479  }
480 
481  Eigen::Vector4d point1_in_rrbf_homo(point1_in_rrbf.x(), point1_in_rrbf.y(), point1_in_rrbf.z(), 1.0);
482  Eigen::Vector4d point1_in_sf_homo = _rrb_current_pose_in_sf.exp(1e-12).toHomogeneousMatrix()*point1_in_rrbf_homo;
483  Eigen::Vector3d point1_in_sf(point1_in_sf_homo[0],point1_in_sf_homo[1],point1_in_sf_homo[2]);
484 
485  Eigen::Vector4d point2_in_rrbf_homo(point2_in_rrbf.x(), point2_in_rrbf.y(), point2_in_rrbf.z(), 1.0);
486  Eigen::Vector4d point2_in_sf_homo = _rrb_current_pose_in_sf.exp(1e-12).toHomogeneousMatrix()*point2_in_rrbf_homo;
487  Eigen::Vector3d point2_in_sf(point2_in_sf_homo[0],point2_in_sf_homo[1],point2_in_sf_homo[2]);
488 
489  double distance_to_srb = ((point2_in_sf - point1_in_sf).cross(point1_in_sf - _srb_centroid_in_sf)).norm()/((point2_in_sf - point1_in_sf).norm());
490 
491  p_params_given_model *= (1.0/(_rev_max_joint_distance_for_ee*sqrt(2.0*M_PI)))*exp((-1.0/2.0)*pow(distance_to_srb/_rev_max_joint_distance_for_ee, 2));
492 
494 }
495 
497 {
498  Eigen::Twistd predicted_delta_pose_in_sf = this->_rrb_current_pose_in_sf.exp(1e-12).adjoint()*this->_predicted_delta_pose_in_rrbf;
499 
500  geometry_msgs::TwistWithCovariance hypothesis;
501 
502  hypothesis.twist.linear.x = predicted_delta_pose_in_sf.vx();
503  hypothesis.twist.linear.y = predicted_delta_pose_in_sf.vy();
504  hypothesis.twist.linear.z = predicted_delta_pose_in_sf.vz();
505  hypothesis.twist.angular.x = predicted_delta_pose_in_sf.rx();
506  hypothesis.twist.angular.y = predicted_delta_pose_in_sf.ry();
507  hypothesis.twist.angular.z = predicted_delta_pose_in_sf.rz();
508 
509  // This call gives me the covariance of the predicted measurement: the relative pose between RBs
510  ColumnVector empty;
511  ColumnVector state_updated_state = this->_ekf->PostGet()->ExpectedValueGet();
512  SymmetricMatrix measurement_cov = this->_meas_MODEL->CovarianceGet(empty, state_updated_state);
513  for(int i=0; i<6; i++)
514  {
515  for(int j=0; j<6; j++)
516  {
517  hypothesis.covariance[6 * i + j] = measurement_cov(i+1,j+1);
518  }
519  }
520 
521  return hypothesis;
522 }
523 
525 {
526  Eigen::Twistd predicted_delta_pose_in_sf = this->_rrb_current_pose_in_sf.exp(1e-12).adjoint()*(this->_predicted_delta_pose_in_rrbf/(_loop_period_ns/1e9));
527 
528  geometry_msgs::TwistWithCovariance hypothesis;
529 
530  hypothesis.twist.linear.x = predicted_delta_pose_in_sf.vx();
531  hypothesis.twist.linear.y = predicted_delta_pose_in_sf.vy();
532  hypothesis.twist.linear.z = predicted_delta_pose_in_sf.vz();
533  hypothesis.twist.angular.x = predicted_delta_pose_in_sf.rx();
534  hypothesis.twist.angular.y = predicted_delta_pose_in_sf.ry();
535  hypothesis.twist.angular.z = predicted_delta_pose_in_sf.rz();
536 
537  // This call gives me the covariance of the predicted measurement: the relative pose between RBs
538  ColumnVector empty;
539  ColumnVector state_updated_state = this->_ekf->PostGet()->ExpectedValueGet();
540  SymmetricMatrix measurement_cov = this->_meas_MODEL->CovarianceGet(empty, state_updated_state);
541  for(int i=0; i<6; i++)
542  {
543  for(int j=0; j<6; j++)
544  {
545  hypothesis.covariance[6 * i + j] = measurement_cov(i+1,j+1);
546  }
547  }
548 
549  return hypothesis;
550 }
551 
553 {
554  Eigen::Twistd delta_rrb_in_sf = this->_rrb_current_vel_in_sf*(this->_loop_period_ns/1e9);
555  Eigen::Twistd rrb_next_pose_in_sf = (delta_rrb_in_sf.exp(1e-12)*this->_rrb_current_pose_in_sf.exp(1e-12)).log(1e-12);
556 
557  Eigen::Displacementd T_sf_rrbf_next = rrb_next_pose_in_sf.exp(1e-12);
558  Eigen::Displacementd T_rrbf_srbf_next = this->_srb_predicted_pose_in_rrbf.exp(1e-12);
559 
560  Eigen::Displacementd T_sf_srbf_next = T_rrbf_srbf_next*T_sf_rrbf_next;
561 
562  Eigen::Twistd srb_next_pose_in_sf = T_sf_srbf_next.log(1e-12);
563 
564  geometry_msgs::TwistWithCovariance hypothesis;
565 
566  hypothesis.twist.linear.x = srb_next_pose_in_sf.vx();
567  hypothesis.twist.linear.y = srb_next_pose_in_sf.vy();
568  hypothesis.twist.linear.z = srb_next_pose_in_sf.vz();
569  hypothesis.twist.angular.x = srb_next_pose_in_sf.rx();
570  hypothesis.twist.angular.y = srb_next_pose_in_sf.ry();
571  hypothesis.twist.angular.z = srb_next_pose_in_sf.rz();
572 
573  // This call gives me the covariance of the predicted measurement: the relative pose between RBs
574  ColumnVector empty;
575  ColumnVector state_updated_state = this->_ekf->PostGet()->ExpectedValueGet();
576  SymmetricMatrix measurement_cov = this->_meas_MODEL->CovarianceGet(empty, state_updated_state);
577  Eigen::Matrix<double,6,6> measurement_cov_eigen;
578  for(int i=0; i<6; i++)
579  {
580  for(int j=0; j<6; j++)
581  {
582  measurement_cov_eigen(i,j) = measurement_cov(i+1,j+1);
583  }
584  }
585  // I need the covariance of the absolute pose of the second RB, so I add the cov of the relative pose to the
586  // cov of the reference pose. I need to "move" the second covariance to align it to the reference frame (see Barfoot)
587  Eigen::Matrix<double,6,6> adjoint_eigen = this->_rrb_current_pose_in_sf.exp(1e-12).adjoint();
588  Eigen::Matrix<double,6,6> new_pose_covariance = this->_rrb_pose_cov_in_sf + adjoint_eigen*measurement_cov_eigen*adjoint_eigen.transpose();
589  for (unsigned int i = 0; i < 6; i++)
590  {
591  for (unsigned int j = 0; j < 6; j++)
592  {
593  hypothesis.covariance[6 * i + j] = new_pose_covariance(i, j);
594  }
595  }
596 
597 
598 #ifdef PUBLISH_PREDICTED_POSE_AS_PWC
599  // This is used to visualize the predictions based on the joint hypothesis
600  geometry_msgs::PoseWithCovarianceStamped pose_with_cov_stamped;
601  pose_with_cov_stamped.header.stamp = ros::Time::now();
602  pose_with_cov_stamped.header.frame_id = "camera_rgb_optical_frame";
603 
604  Eigen::Displacementd displ_from_twist = srb_next_pose_in_sf.exp(1e-12);
605  pose_with_cov_stamped.pose.pose.position.x = displ_from_twist.x();
606  pose_with_cov_stamped.pose.pose.position.y = displ_from_twist.y();
607  pose_with_cov_stamped.pose.pose.position.z = displ_from_twist.z();
608  pose_with_cov_stamped.pose.pose.orientation.x = displ_from_twist.qx();
609  pose_with_cov_stamped.pose.pose.orientation.y = displ_from_twist.qy();
610  pose_with_cov_stamped.pose.pose.orientation.z = displ_from_twist.qz();
611  pose_with_cov_stamped.pose.pose.orientation.w = displ_from_twist.qw();
612 
613  for (unsigned int i = 0; i < 6; i++)
614  for (unsigned int j = 0; j < 6; j++)
615  pose_with_cov_stamped.pose.covariance[6 * i + j] = new_pose_covariance(i, j);
616 
617  _predicted_next_pose_publisher.publish(pose_with_cov_stamped);
618 #endif
619 
620  return hypothesis;
621 }
622 
623 std::vector<visualization_msgs::Marker> RevoluteJointFilter::getJointMarkersInRRBFrame() const
624 {
625  // The class variable _joint_orientation and _rev_joint_posi (also _uncertainty_o_phi and _uncertainty_o_theta) are defined in the frame of the
626  // ref RB with the initial relative transformation to the second RB
627  // We want the variables to be in the ref RB frame, without the initial relative transformation to the second RB
628  Eigen::Vector3d rev_joint_ori_in_ref_rb = this->_joint_orientation;
629  Eigen::Vector3d rev_joint_posi_in_ref_rb = this->_joint_position;
630 
631 
632  std::vector<visualization_msgs::Marker> revolute_markers;
633  // AXIS MARKER 1 -> The axis ///////////////////////////////////////////////////////////////////////////////////////////////////////////
634  visualization_msgs::Marker axis_orientation_marker;
635  axis_orientation_marker.ns = "kinematic_structure";
636  axis_orientation_marker.action = visualization_msgs::Marker::ADD;
637  axis_orientation_marker.type = visualization_msgs::Marker::ARROW;
638 
639  // Define the joint parameters relative to the REFERENCE RIGID BODY and the marker will be also
640  // defined wrt to the frame of the REFERENCE RIGID BODY!
641  // The frame name will be assigned in the MultiJointTrackerNode because we don't know the rb ids here
642  //axis_orientation_marker.header.frame_id = "camera_rgb_optical_frame";
643  axis_orientation_marker.id = 3 * this->_joint_id;
644  axis_orientation_marker.scale.x = JOINT_AXIS_AND_VARIABLE_MARKER_RADIUS;
645  axis_orientation_marker.scale.y = 0.f;
646  axis_orientation_marker.scale.z = 0.f;
647  axis_orientation_marker.color.r = 1.f;
648  axis_orientation_marker.color.g = 0.f;
649  axis_orientation_marker.color.b = 0.f;
650  axis_orientation_marker.color.a = 1.f;
651  Eigen::Vector3d point_on_rot_axis_1 = rev_joint_posi_in_ref_rb - this->_joint_state * rev_joint_ori_in_ref_rb;
652  geometry_msgs::Point pt1;
653  pt1.x = point_on_rot_axis_1.x();
654  pt1.y = point_on_rot_axis_1.y();
655  pt1.z = point_on_rot_axis_1.z();
656  axis_orientation_marker.points.push_back(pt1);
657  Eigen::Vector3d point_on_rot_axis_2 = rev_joint_posi_in_ref_rb + this->_joint_state * rev_joint_ori_in_ref_rb;
658  geometry_msgs::Point pt2;
659  pt2.x = point_on_rot_axis_2.x();
660  pt2.y = point_on_rot_axis_2.y();
661  pt2.z = point_on_rot_axis_2.z();
662  axis_orientation_marker.points.push_back(pt2);
663  revolute_markers.push_back(axis_orientation_marker);
664 
665  // AXIS MARKER 2 -> Proportional to the joint state///////////////////////////////////////////////////////////////////////////////////////////////////////////
666  visualization_msgs::Marker axis_orientation_markerb;
667  axis_orientation_markerb.ns = "kinematic_structure";
668  axis_orientation_markerb.action = visualization_msgs::Marker::ADD;
669  axis_orientation_markerb.type = visualization_msgs::Marker::ARROW;
670  // Define the joint parameters relative to the REFERENCE RIGID BODY and the marker will be also
671  // defined wrt to the frame of the REFERENCE RIGID BODY!
672  // The frame name will be assigned in the MultiJointTrackerNode because we don't know the rb ids here
673  //axis_orientation_markerb.header.frame_id = "camera_rgb_optical_frame";
674  axis_orientation_markerb.id = 3 * this->_joint_id + 1;
675  axis_orientation_markerb.scale.x = JOINT_AXIS_MARKER_RADIUS;
676  axis_orientation_markerb.scale.y = 0.f;
677  axis_orientation_markerb.scale.z = 0.f;
678  axis_orientation_markerb.color.r = 1.f;
679  axis_orientation_markerb.color.g = 0.f;
680  axis_orientation_markerb.color.b = 0.f;
681  axis_orientation_markerb.color.a = 1.f;
682  Eigen::Vector3d point_on_rot_axis_1b = rev_joint_posi_in_ref_rb - 100 * rev_joint_ori_in_ref_rb;
683  geometry_msgs::Point pt1b;
684  pt1b.x = point_on_rot_axis_1b.x();
685  pt1b.y = point_on_rot_axis_1b.y();
686  pt1b.z = point_on_rot_axis_1b.z();
687  axis_orientation_markerb.points.push_back(pt1b);
688  Eigen::Vector3d point_on_rot_axis_2b = rev_joint_posi_in_ref_rb + 100 * rev_joint_ori_in_ref_rb;
689  geometry_msgs::Point pt2b;
690  pt2b.x = point_on_rot_axis_2b.x();
691  pt2b.y = point_on_rot_axis_2b.y();
692  pt2b.z = point_on_rot_axis_2b.z();
693  axis_orientation_markerb.points.push_back(pt2b);
694 
695  revolute_markers.push_back(axis_orientation_markerb);
696 
697  // AXIS MARKER 3 -> Text with the joint state ///////////////////////////////////////////////////////////////////////////////////////////////////////////
698  axis_orientation_markerb.points.clear();
699  axis_orientation_markerb.id = 3 * this->_joint_id + 2;
700  axis_orientation_markerb.type = visualization_msgs::Marker::TEXT_VIEW_FACING;
701  axis_orientation_markerb.scale.z = JOINT_VALUE_TEXT_SIZE;
702  std::ostringstream oss_joint_value;
703  oss_joint_value << std::fixed<< std::setprecision(0) << (180/M_PI)*this->_joint_state;
704  axis_orientation_markerb.text = oss_joint_value.str() + std::string(" deg");
705  axis_orientation_markerb.pose.position.x = rev_joint_posi_in_ref_rb.x();
706  axis_orientation_markerb.pose.position.y = rev_joint_posi_in_ref_rb.y();
707  axis_orientation_markerb.pose.position.z = rev_joint_posi_in_ref_rb.z();
708  axis_orientation_markerb.pose.orientation.x = 0;
709  axis_orientation_markerb.pose.orientation.y = 0;
710  axis_orientation_markerb.pose.orientation.z = 0;
711  axis_orientation_markerb.pose.orientation.w = 1;
712 
713  revolute_markers.push_back(axis_orientation_markerb);
714 
715  // UNCERTAINTY MARKERS ///////////////////////////////////////////////////////////////////////////////////////////////////////
716 
717  visualization_msgs::Marker axis_position_uncertainty_marker;
718  axis_position_uncertainty_marker.pose.position.x = rev_joint_posi_in_ref_rb.x();
719  axis_position_uncertainty_marker.pose.position.y = rev_joint_posi_in_ref_rb.y();
720  axis_position_uncertainty_marker.pose.position.z = rev_joint_posi_in_ref_rb.z();
721  // Define the joint parameters relative to the REFERENCE RIGID BODY and the marker will be also
722  // defined wrt to the frame of the REFERENCE RIGID BODY!
723  // The frame name will be assigned in the MultiJointTrackerNode because we don't know the rb ids here
724  //axis_position_uncertainty_marker.header.frame_id = "camera_rgb_optical_frame";
725  axis_position_uncertainty_marker.ns = "kinematic_structure_uncertainty";
726  axis_position_uncertainty_marker.type = visualization_msgs::Marker::SPHERE;
727  axis_position_uncertainty_marker.action = visualization_msgs::Marker::ADD;
728  axis_position_uncertainty_marker.id = 3 * this->_joint_id ;
729  // Reliability = 1 --> position_sphere_uncertainty = 0
730  // Reliability = 0 --> position_sphere_uncertainty = 1m
731  axis_position_uncertainty_marker.scale.x = this->_uncertainty_joint_position(0,0); //Using start and end points, scale.x is the radius of the array body
732  axis_position_uncertainty_marker.scale.y = this->_uncertainty_joint_position(1,1); //Using start and end points, scale.y is the radius of the array head
733  axis_position_uncertainty_marker.scale.z = this->_uncertainty_joint_position(2,2); //Using start and end points, scale.y is the radius of the array head
734  axis_position_uncertainty_marker.color.a = 0.3;
735  axis_position_uncertainty_marker.color.r = 1.0;
736  axis_position_uncertainty_marker.color.g = 0.0;
737  axis_position_uncertainty_marker.color.b = 0.0;
738  revolute_markers.push_back(axis_position_uncertainty_marker);
739 
740  visualization_msgs::Marker rev_axis_unc_cone1;
741  rev_axis_unc_cone1.type = visualization_msgs::Marker::MESH_RESOURCE;
742  rev_axis_unc_cone1.action = visualization_msgs::Marker::ADD;
743  rev_axis_unc_cone1.mesh_resource = "package://joint_tracker/meshes/cone.stl";
744  rev_axis_unc_cone1.pose.position.x = rev_joint_posi_in_ref_rb.x();
745  rev_axis_unc_cone1.pose.position.y = rev_joint_posi_in_ref_rb.y();
746  rev_axis_unc_cone1.pose.position.z = rev_joint_posi_in_ref_rb.z();
747 
748 
749  // NOTE:
750  // Estimation of the uncertainty cones -----------------------------------------------
751  // We estimate the orientation of the revolute axis in spherical coordinates (r=1 always)
752  // We estimate phi: angle from the x axis to the projection of the revolute joint axis to the xy plane
753  // We estimate theta: angle from the z axis to the revolute joint axis
754  // [TODO: phi and theta are in the reference rigid body. Do we need to transform it (adding uncertainty) to the reference frame?]
755  // The covariance of phi and theta (a 2x2 matrix) gives us the uncertainty of the orientation of the joint
756  // If we look from the joint axis, we would see an ellipse given by this covariance matrix [http://www.visiondummy.com/2014/04/draw-error-ellipse-representing-covariance-matrix/]
757  // But in RVIZ we can only set the scale of our cone mesh in x and y, not in a different axis
758  // The first thing is then to estimate the direction of the major and minor axis of the ellipse and their size
759  Eigen::SelfAdjointEigenSolver<Eigen::Matrix2d> eigensolver(this->_uncertainty_joint_orientation_phitheta);
760 
761  // The sizes of the major and minor axes of the ellipse are given by the eigenvalues and the chi square distribution P(x<critical_value) = confidence_value
762  // For 50% of confidence on the cones shown
763  double confidence_value = 0.5;
764  boost::math::chi_squared chi_sq_dist(2);
765  double critical_value = boost::math::quantile(chi_sq_dist, confidence_value);
766  double major_axis_length = 2*eigensolver.eigenvalues()[1]*std::sqrt(critical_value);
767  double minor_axis_length = 2*eigensolver.eigenvalues()[0]*std::sqrt(critical_value);
768 
769  // If z is pointing in the direction of the joint, the angle between the x axis and the largest axis of the ellipse is arctg(v1_y/v1_x) where v1 is the eigenvector of
770  // largest eigenvalue (the last column in the matrix returned by eigenvectors() in eigen library):
771  double alpha = atan2(eigensolver.eigenvectors().col(1)[1],eigensolver.eigenvectors().col(1)[0]);
772  // We create a rotation around the z axis to align the ellipse to have the major axis aligned to the x-axis (we UNDO the rotation of the ellipse):
773  Eigen::AngleAxisd init_rot(-alpha, Eigen::Vector3d::UnitZ());
774 
775  // Now I need to rotate the mesh so that:
776  // 1) The z axis of the mesh points in the direction of the joint
777  // 2) The x axis of the mesh is contained in the x-y plane of the reference frame
778 
779  // To get the z axis of the mesh to point in the direction of the joint
780  Eigen::Quaterniond ori_quat;
781  ori_quat.setFromTwoVectors(Eigen::Vector3d::UnitZ(), rev_joint_ori_in_ref_rb);
782 
783  // To get the x axis of the mesh to be contained in the x-y plane of the reference frame
784  // First, find a vector that is orthogonal to the joint orientation and also to the z_axis (this latter implies to be contained in the xy plane)
785  Eigen::Vector3d coplanar_xy_orthogonal_to_joint_ori = rev_joint_ori_in_ref_rb.cross(Eigen::Vector3d::UnitZ());
786  // Normalize it -> Gives me the desired x axis after the rotation
787  coplanar_xy_orthogonal_to_joint_ori.normalize();
788 
789  // Then find the corresponding y axis after the rotation as the cross product of the z axis after rotation (orientation of the joint)
790  // and the x axis after rotation
791  Eigen::Vector3d y_pos = rev_joint_ori_in_ref_rb.cross(coplanar_xy_orthogonal_to_joint_ori);
792 
793  // Create a matrix with the values of the vectors after rotation
794  Eigen::Matrix3d rotation_pos;
795  rotation_pos << coplanar_xy_orthogonal_to_joint_ori.x(),y_pos.x(),rev_joint_ori_in_ref_rb.x(),
796  coplanar_xy_orthogonal_to_joint_ori.y(),y_pos.y(),rev_joint_ori_in_ref_rb.y(),
797  coplanar_xy_orthogonal_to_joint_ori.z(),y_pos.z(),rev_joint_ori_in_ref_rb.z();
798 
799  // Create a quaternion with the matrix
800  Eigen::Quaterniond ori_quat_final(rotation_pos);
801 
802  Eigen::Quaterniond ori_quat_final_ellipse(ori_quat_final.toRotationMatrix()*init_rot.toRotationMatrix());
803 
804  rev_axis_unc_cone1.pose.orientation.x = ori_quat_final_ellipse.x();
805  rev_axis_unc_cone1.pose.orientation.y = ori_quat_final_ellipse.y();
806  rev_axis_unc_cone1.pose.orientation.z = ori_quat_final_ellipse.z();
807  rev_axis_unc_cone1.pose.orientation.w = ori_quat_final_ellipse.w();
808  // Define the joint parameters relative to the REFERENCE RIGID BODY and the marker will be also
809  // defined wrt to the frame of the REFERENCE RIGID BODY!
810  // The frame name will be assigned in the MultiJointTrackerNode because we don't know the rb ids here
811  //rev_axis_unc_cone1.header.frame_id = "camera_rgb_optical_frame";
812  rev_axis_unc_cone1.ns = "kinematic_structure_uncertainty";
813  rev_axis_unc_cone1.id = 3 * this->_joint_id + 1;
814  rev_axis_unc_cone1.color.a = 0.4;
815  rev_axis_unc_cone1.color.r = 1.0;
816  rev_axis_unc_cone1.color.g = 0.0;
817  rev_axis_unc_cone1.color.b = 0.0;
818 
819  // If the uncertainty is pi/6 (30 degrees) the scale in this direction should be 1
820  // If the uncertainty is pi/12 (15 degrees) the scale in this direction should be 0.5
821  // If the uncertainty is close to 0 the scale in this direction should be 0
822  // If the uncertainty is close to pi the scale in this direction should be inf
823 
824  rev_axis_unc_cone1.scale.x = major_axis_length / (M_PI / 6.0);
825  rev_axis_unc_cone1.scale.y = minor_axis_length / (M_PI / 6.0);
826  rev_axis_unc_cone1.scale.z = 1.;
827  revolute_markers.push_back(rev_axis_unc_cone1);
828 
829  // We repeat the process for the cone in the other direction
830  // To get the z axis of the mesh to point in the direction of the joint (negative)
831  Eigen::Vector3d rev_joint_ori_in_ref_rb_neg = -rev_joint_ori_in_ref_rb;
832  Eigen::Quaterniond ori_quat_neg;
833  ori_quat_neg.setFromTwoVectors(Eigen::Vector3d::UnitZ(), rev_joint_ori_in_ref_rb_neg);
834 
835  // To get the x axis of the mesh to be contained in the x-y plane of the reference frame
836  // First, find a vector that is orthogonal to the joint orientation and also to the z_axis (this latter implies to be contained in the xy plane)
837  Eigen::Vector3d coplanar_xy_orthogonal_to_joint_ori_neg = rev_joint_ori_in_ref_rb_neg.cross(Eigen::Vector3d::UnitZ());
838  // Normalize it -> Gives me the desired x axis after the rotation
839  coplanar_xy_orthogonal_to_joint_ori_neg.normalize();
840 
841  // Then find the corresponding y axis after the rotation as the cross product of the z axis after rotation (orientation of the joint)
842  // and the x axis after rotation
843  Eigen::Vector3d y_neg = rev_joint_ori_in_ref_rb_neg.cross(coplanar_xy_orthogonal_to_joint_ori_neg);
844 
845  // Create a matrix with the values of the vectors after rotation
846  Eigen::Matrix3d rotation_neg;
847  rotation_neg << coplanar_xy_orthogonal_to_joint_ori_neg.x(),y_neg.x(),rev_joint_ori_in_ref_rb_neg.x(),
848  coplanar_xy_orthogonal_to_joint_ori_neg.y(),y_neg.y(),rev_joint_ori_in_ref_rb_neg.y(),
849  coplanar_xy_orthogonal_to_joint_ori_neg.z(),y_neg.z(),rev_joint_ori_in_ref_rb_neg.z();
850 
851  // Create a quaternion with the matrix
852  Eigen::Quaterniond ori_quat_neg_final(rotation_neg);
853 
854  // We undo the rotation of the ellipse (but negative!):
855  Eigen::AngleAxisd init_rot_neg(alpha, Eigen::Vector3d::UnitZ());
856  Eigen::Quaterniond ori_quat_neg_final_ellipse(ori_quat_neg_final.toRotationMatrix()*init_rot_neg.toRotationMatrix());
857 
858  rev_axis_unc_cone1.pose.orientation.x = ori_quat_neg_final_ellipse.x();
859  rev_axis_unc_cone1.pose.orientation.y = ori_quat_neg_final_ellipse.y();
860  rev_axis_unc_cone1.pose.orientation.z = ori_quat_neg_final_ellipse.z();
861  rev_axis_unc_cone1.pose.orientation.w = ori_quat_neg_final_ellipse.w();
862  rev_axis_unc_cone1.scale.x = major_axis_length / (M_PI / 6.0);
863  rev_axis_unc_cone1.scale.y = minor_axis_length / (M_PI / 6.0);
864  rev_axis_unc_cone1.scale.z = 1.;
865  rev_axis_unc_cone1.id = 3 * this->_joint_id + 2;
866  revolute_markers.push_back(rev_axis_unc_cone1);
867 
868  return revolute_markers;
869 }
870 
872 {
873  return REVOLUTE_JOINT;
874 }
875 
877 {
878  return std::string("RevoluteJointFilter");
879 }
EIGEN_MAKE_ALIGNED_OPERATOR_NEW RevoluteJointFilter()
Eigen::Twistd _rrb_current_pose_in_sf
Definition: JointFilter.h:417
double _sigma_sys_noise_px
Definition: JointFilter.h:392
bool _from_inverted_to_non_inverted
Definition: JointFilter.h:460
Eigen::Twistd _predicted_delta_pose_in_rrbf
Definition: JointFilter.h:439
TFSIMD_FORCE_INLINE Vector3 cross(const Vector3 &v) const
INLINE Rall1d< T, V, S > log(const Rall1d< T, V, S > &arg)
Eigen::Matrix3d _uncertainty_joint_position
Definition: JointFilter.h:356
Eigen::Matrix< double, 6, 6 > _current_delta_pose_cov_in_rrbf
Definition: JointFilter.h:437
virtual void setMinRotationRevolute(const double &value)
virtual void initialize()
JointFilterType
Definition: JointFilter.h:71
virtual std::vector< visualization_msgs::Marker > getJointMarkersInRRBFrame() const
#define MEAS_DIM
double _sigma_sys_noise_py
Definition: JointFilter.h:393
double _joint_orientation_phi
Definition: JointFilter.h:359
double _uncertainty_joint_velocity
Definition: JointFilter.h:377
BFL::LinearAnalyticConditionalGaussian * _sys_PDF
Eigen::Twistd _srb_initial_pose_in_rrbf
Definition: JointFilter.h:428
std::vector< double > _joint_states_all
Definition: JointFilter.h:372
Eigen::Matrix< double, 6, 6 > _rrb_pose_cov_in_sf
Definition: JointFilter.h:419
Eigen::Twistd _rrb_current_vel_in_sf
Definition: JointFilter.h:420
double _model_prior_probability
Definition: JointFilter.h:348
bool _from_non_inverted_to_inverted
Definition: JointFilter.h:461
BFL::ExtendedKalmanFilter * _ekf
virtual JointFilterType getJointFilterType() const
Eigen::Twistd _srb_predicted_pose_in_rrbf
Definition: JointFilter.h:434
Eigen::Matrix2d _uncertainty_joint_orientation_phitheta
Definition: JointFilter.h:364
virtual void setMaxRadiusDistanceRevolute(const double &value)
double _uncertainty_joint_state
Definition: JointFilter.h:369
#define JOINT_VALUE_TEXT_SIZE
Definition: JointFilter.h:62
Eigen::Vector3d _joint_orientation
Definition: JointFilter.h:362
bool _inverted_delta_srb_pose_in_rrbf
Definition: JointFilter.h:459
virtual std::string getJointFilterTypeStr() const
double _measurements_likelihood
Definition: JointFilter.h:346
virtual geometry_msgs::TwistWithCovariance getPredictedSRBPoseWithCovInSensorFrame()
We use the kinematic structure to predict the next pose-twist of the second rigid body of the joint (...
double _unnormalized_model_probability
Definition: JointFilter.h:351
BFL::AnalyticMeasurementModelGaussianUncertainty * _meas_MODEL
Eigen::Twistd unwrapTwist(Eigen::Twistd &current_twist, Eigen::Displacementd &current_displacement, Eigen::Twistd &previous_twist, bool &changed)
Eigen::Vector3d _joint_position
Definition: JointFilter.h:354
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
BFL::NonLinearRevoluteMeasurementPdf * _meas_PDF
double _joint_orientation_theta
Definition: JointFilter.h:360
#define JOINT_AXIS_AND_VARIABLE_MARKER_RADIUS
Definition: JointFilter.h:61
INLINE Rall1d< T, V, S > exp(const Rall1d< T, V, S > &arg)
Eigen::Twistd _current_delta_pose_in_rrbf
Definition: JointFilter.h:436
INLINE Rall1d< T, V, S > pow(const Rall1d< T, V, S > &arg, double m)
virtual void setCovarianceDeltaMeasurementAngular(double sigma_delta_meas_uncertainty_angular)
virtual void estimateMeasurementHistoryLikelihood()
INLINE Rall1d< T, V, S > acos(const Rall1d< T, V, S > &x)
JointCombinedFilterId _joint_id
Definition: JointFilter.h:332
double _sigma_sys_noise_theta
Definition: JointFilter.h:391
virtual void estimateUnnormalizedModelProbability()
BFL::LinearAnalyticSystemModelGaussianUncertainty * _sys_MODEL
#define JOINT_AXIS_MARKER_RADIUS
Definition: JointFilter.h:60
double _sigma_sys_noise_jvd
Definition: JointFilter.h:396
INLINE Rall1d< T, V, S > atan2(const Rall1d< T, V, S > &y, const Rall1d< T, V, S > &x)
std::vector< Eigen::Twistd > _delta_poses_in_rrbf
Definition: JointFilter.h:440
virtual void predictState(double time_interval_ns)
First step when updating the filter. The next state is predicted from current state and system model...
virtual geometry_msgs::TwistWithCovariance getPredictedSRBDeltaPoseWithCovInSensorFrame()
Generate a prediction about the change in pose of the second rigid body (SRB) and its covariance usin...
static Time now()
double _sigma_sys_noise_jv
Definition: JointFilter.h:395
#define REV_STATE_DIM
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
double _joint_velocity
Definition: JointFilter.h:375
Eigen::Vector3d _srb_centroid_in_sf
Definition: JointFilter.h:386
double _sigma_sys_noise_phi
Definition: JointFilter.h:390
Eigen::Twistd _srb_previous_predicted_pose_in_rrbf
Definition: JointFilter.h:435
double _loop_period_ns
Definition: JointFilter.h:444
double _sigma_sys_noise_pz
Definition: JointFilter.h:394
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
double _sigma_meas_noise
Definition: JointFilter.h:397
virtual geometry_msgs::TwistWithCovariance getPredictedSRBVelocityWithCovInSensorFrame()
Generate a prediction about the velocity of the second rigid body (SRB) and its covariance using the ...


joint_tracker
Author(s): Roberto Martín-Martín
autogenerated on Mon Jun 10 2019 14:06:16