1 #include <boost/foreach.hpp> 5 #include <geometry_msgs/Vector3.h> 9 #include <wrappers/matrix/matrix_wrapper.h> 11 #include "omip_msgs/RigidBodyTwistWithCovMsg.h" 20 _ks_analysis_type(ks_analysis_type),
21 _disconnected_j_ne(dj_ne),
22 _likelihood_sample_num(0),
23 _sigma_delta_meas_uncertainty_linear(0),
24 _sigma_delta_meas_uncertainty_angular(0)
38 joint_combined_filter_it.second->predictState(time_interval_ns);
49 omip_msgs::RigidBodyPoseAndVelMsg pose_and_vel_one_rb;
52 std::map<int, double> rbid_predicted_and_likelihood;
53 std::map<int, omip_msgs::RigidBodyPoseAndVelMsg> rbid_predicted_and_predictions;
56 joint_combined_filter_it.second->predictMeasurement();
57 rbid_predicted = joint_combined_filter_it.first.second;
58 JointFilterPtr most_probable_joint_hypothesis = joint_combined_filter_it.second->getMostProbableJointFilter();
64 std::map<int, double>::iterator previous_prediction_it = rbid_predicted_and_likelihood.find(rbid_predicted);
66 if(previous_prediction_it != rbid_predicted_and_likelihood.end())
69 if(previous_prediction_it->second < most_probable_joint_hypothesis->getProbabilityOfJointFilter())
71 ROS_INFO_STREAM_NAMED(
"MultiJointTracker.predictMeasurement",
"Replacing previous prediction with prediction from " 72 << most_probable_joint_hypothesis->getJointFilterTypeStr());
73 pose_and_vel_one_rb.rb_id = rbid_predicted;
74 pose_and_vel_one_rb.pose_wc = most_probable_joint_hypothesis->getPredictedSRBDeltaPoseWithCovInSensorFrame();
75 pose_and_vel_one_rb.velocity_wc = most_probable_joint_hypothesis->getPredictedSRBVelocityWithCovInSensorFrame();
76 rbid_predicted_and_predictions[rbid_predicted] = pose_and_vel_one_rb;
77 rbid_predicted_and_likelihood[rbid_predicted] = most_probable_joint_hypothesis->getProbabilityOfJointFilter();
83 << most_probable_joint_hypothesis->getJointFilterTypeStr());
84 pose_and_vel_one_rb.rb_id = rbid_predicted;
85 pose_and_vel_one_rb.pose_wc = most_probable_joint_hypothesis->getPredictedSRBDeltaPoseWithCovInSensorFrame();
86 pose_and_vel_one_rb.velocity_wc = most_probable_joint_hypothesis->getPredictedSRBVelocityWithCovInSensorFrame();
87 rbid_predicted_and_predictions[rbid_predicted] = pose_and_vel_one_rb;
88 rbid_predicted_and_likelihood[rbid_predicted] = most_probable_joint_hypothesis->getProbabilityOfJointFilter();
94 std::map<int, omip_msgs::RigidBodyPoseAndVelMsg>::iterator best_predictions_it = rbid_predicted_and_predictions.begin();
95 std::map<int, omip_msgs::RigidBodyPoseAndVelMsg>::iterator best_predictions_it_end = rbid_predicted_and_predictions.end();
96 for(; best_predictions_it != best_predictions_it_end; best_predictions_it++)
116 size_t rrb_idx_begin = 0;
117 size_t rrb_idx_end = 0;
135 for (
size_t rrb_idx = rrb_idx_begin; rrb_idx < rrb_idx_end; rrb_idx++)
143 std::pair<int, int> rrb_srb_ids = std::pair<int, int>(rrb_id, srb_id);
163 for(
int k=0; k<n; k++)
175 size_t rrb_idx_begin = 0;
176 size_t rrb_idx_end = 0;
194 for (
size_t rrb_idx = rrb_idx_begin; rrb_idx < rrb_idx_end; rrb_idx++)
202 std::pair<int, int> rrb_srb_ids = std::pair<int, int>(rrb_id, srb_id);
223 Eigen::Twistd rrb_pose_at_srb_birthday_in_sf_twist = Eigen::Twistd(0.,0.,0.,0.,0.,0.);
227 for(; acc_frames_it != acc_frames_end; acc_frames_it++)
229 for(
int rb_prev_idx = 0; rb_prev_idx < (*acc_frames_it)->rb_poses_and_vels.size(); rb_prev_idx++)
232 if((*acc_frames_it)->rb_poses_and_vels.at(rb_prev_idx).rb_id == rrb_id)
234 ROSTwist2EigenTwist((*acc_frames_it)->rb_poses_and_vels.at(rb_prev_idx).pose_wc.twist, rrb_pose_at_srb_birthday_in_sf_twist);
248 Eigen::Twistd srb_pose_at_srb_birthday_in_sf_twist = Eigen::Twistd(0.,0.,0.,0.,0.,0.);
254 srb_pose_at_srb_birthday_in_sf_twist.vx() = this->
_last_rcvd_poses_and_vels->rb_poses_and_vels.at(rb_prev_idx).centroid.x;
255 srb_pose_at_srb_birthday_in_sf_twist.vy() = this->
_last_rcvd_poses_and_vels->rb_poses_and_vels.at(rb_prev_idx).centroid.y;
256 srb_pose_at_srb_birthday_in_sf_twist.vz() = this->
_last_rcvd_poses_and_vels->rb_poses_and_vels.at(rb_prev_idx).centroid.z;
264 Eigen::Twistd new_twist;
271 corrected_joint_combined_filters[rrb_srb_ids]->setLoopPeriodNS(this->
_loop_period_ns);
272 corrected_joint_combined_filters[rrb_srb_ids]->setNumSamplesForLikelihoodEstimation(this->
_likelihood_sample_num);
275 corrected_joint_combined_filters[rrb_srb_ids]->setMaxTranslationRigid(this->
_rig_max_translation);
276 corrected_joint_combined_filters[rrb_srb_ids]->setMaxRotationRigid(this->
_rig_max_rotation);
277 corrected_joint_combined_filters[rrb_srb_ids]->setJointLikelihoodDisconnected(this->
_disconnected_j_ne);
293 corrected_joint_combined_filters[rrb_srb_ids]->setMinRotationRevolute(this->
_rev_min_rot_for_ee);
299 corrected_joint_combined_filters[rrb_srb_ids]->initialize();
307 prev_joint_combined_filter_it->second->correctState();
308 corrected_joint_combined_filters[rrb_srb_ids] = prev_joint_combined_filter_it->second;
328 joint_combined_filter_it.second->estimateJointFilterProbabilities();
std::pair< omip_msgs::RigidBodyPoseAndVelMsg, omip_msgs::RigidBodyPoseAndVelMsg > joint_measurement_t
omip_msgs::RigidBodyPosesAndVelsMsg ks_measurement_t
MultiJointTracker(double loop_period_ns, ks_analysis_t ks_analysis_type, double dj_ne)
double _rev_sigma_sys_noise_rvd
omip_msgs::RigidBodyPosesAndVelsMsgPtr _last_rcvd_poses_and_vels
double _disconnected_j_ne
double _rev_sigma_sys_noise_pz
virtual JointCombinedFilterPtr getCombinedFilter(int n)
virtual void estimateJointFiltersProbabilities()
joint_combined_filters_map _joint_combined_filters
ks_analysis_t _ks_analysis_type
#define ROS_INFO_STREAM_NAMED(name, args)
omip_msgs::RigidBodyPosesAndVelsMsgPtr _previous_rcvd_poses_and_vels
double _rev_sigma_sys_noise_theta
double _sigma_delta_meas_uncertainty_linear
int _min_joint_age_for_ee
double _rev_sigma_sys_noise_rv
double _rev_min_rot_for_ee
double _prism_prior_cov_vel
std::map< std::pair< int, int >, Eigen::Twistd > _srb_pose_at_srb_birthday_in_sf
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 void _reflectState()
Prepares the state variable to be returned (getState is constant and we cannot change the state there...
boost::shared_ptr< JointCombinedFilter > JointCombinedFilterPtr
virtual void setMeasurement(const ks_measurement_t &poses_and_vels, const double &measurement_timestamp_ns)
double _rev_sigma_sys_noise_phi
double _previous_measurement_timestamp_ns
double _rev_sigma_meas_noise
int _likelihood_sample_num
void ROSTwist2EigenTwist(const geometry_msgs::Twist &ros_twist, Eigen::Twistd &eigen_twist)
int _min_num_frames_for_new_rb
virtual void predictMeasurement()
Second step when updating the filter. The next measurement is predicted from the predicted next state...
double _rev_sigma_sys_noise_px
double _measurement_timestamp_ns
std::list< omip_msgs::RigidBodyPosesAndVelsMsgPtr > _n_previous_rcvd_poses_and_vels
double _rev_prior_cov_vel
virtual ~MultiJointTracker()
double _prism_sigma_sys_noise_theta
virtual void correctState()
Third and final step when updating the filter. The predicted next state is corrected based on the dif...
double _rev_sigma_sys_noise_py
double _prism_sigma_sys_noise_pv
double _prism_sigma_sys_noise_pvd
double _prism_sigma_sys_noise_phi
double _rev_max_joint_distance_for_ee
std::map< std::pair< int, int >, int > _precomputing_counter
double _rig_max_translation
double _sigma_delta_meas_uncertainty_angular
std::map< std::pair< int, int >, JointCombinedFilterPtr > joint_combined_filters_map
double _prism_sigma_meas_noise
std::map< std::pair< int, int >, Eigen::Twistd > _rrb_pose_at_srb_birthday_in_sf
MeasurementType _predicted_measurement