DisconnectedJointFilter.cpp
Go to the documentation of this file.
2 
3 #include <random>
4 
5 using namespace omip;
6 
9 {
11 }
12 
14 {
15 
16 }
17 
19  JointFilter(disconnected_joint)
20 {
21 }
22 
24 {
25 
26 }
27 
29 {
30  return (_unnormalized_model_probability / this->_normalizing_term);//this->_measurements_likelihood;
31 }
32 
34 {
35  // We just give a random prediction
36  std::default_random_engine generator;;
37  std::uniform_real_distribution<double> distr(-100.0, 100.0); // define the range
38  Eigen::Twistd srb_delta_pose_in_sf_next = Eigen::Twistd(distr(generator),distr(generator),distr(generator),
39  distr(generator),distr(generator),distr(generator) );
40 
41  geometry_msgs::TwistWithCovariance hypothesis;
42 
43  hypothesis.twist.linear.x = srb_delta_pose_in_sf_next.vx();
44  hypothesis.twist.linear.y = srb_delta_pose_in_sf_next.vy();
45  hypothesis.twist.linear.z = srb_delta_pose_in_sf_next.vz();
46  hypothesis.twist.angular.x = srb_delta_pose_in_sf_next.rx();
47  hypothesis.twist.angular.y = srb_delta_pose_in_sf_next.ry();
48  hypothesis.twist.angular.z = srb_delta_pose_in_sf_next.rz();
49 
50  // If the bodies are disconnected, we cannot use the kinematic structure to give an accurate predition
51  for (unsigned int i = 0; i < 6; i++)
52  {
53  for (unsigned int j = 0; j < 6; j++)
54  {
55  if(i == j)
56  {
57  hypothesis.covariance[6 * i + j] = 1.0e6;
58  }else
59  {
60  hypothesis.covariance[6 * i + j] = 1.0e3;
61  }
62  }
63  }
64 
65  return hypothesis;
66 }
67 
69 {
70  // We just give a random prediction
71  std::default_random_engine generator;;
72  std::uniform_real_distribution<double> distr(-100.0, 100.0); // define the range
73  Eigen::Twistd srb_delta_pose_in_sf_next = Eigen::Twistd(distr(generator),distr(generator),distr(generator),
74  distr(generator),distr(generator),distr(generator) );
75 
76  geometry_msgs::TwistWithCovariance hypothesis;
77 
78  hypothesis.twist.linear.x = srb_delta_pose_in_sf_next.vx();
79  hypothesis.twist.linear.y = srb_delta_pose_in_sf_next.vy();
80  hypothesis.twist.linear.z = srb_delta_pose_in_sf_next.vz();
81  hypothesis.twist.angular.x = srb_delta_pose_in_sf_next.rx();
82  hypothesis.twist.angular.y = srb_delta_pose_in_sf_next.ry();
83  hypothesis.twist.angular.z = srb_delta_pose_in_sf_next.rz();
84 
85  // If the bodies are disconnected, we cannot use the kinematic structure to give an accurate predition
86  for (unsigned int i = 0; i < 6; i++)
87  {
88  for (unsigned int j = 0; j < 6; j++)
89  {
90  if(i == j)
91  {
92  hypothesis.covariance[6 * i + j] = 1.0e6;
93  }else
94  {
95  hypothesis.covariance[6 * i + j] = 1.0e3;
96  }
97  }
98  }
99 
100  return hypothesis;
101 }
102 
104 {
105  // If the two rigid bodies are disconnecte, the pose of the second rigid body is INDEPENDENT of the motion of the reference rigid body
106 
107  // OPTION1: This prediction is the same as predicting in the rigid body level using velocity
108  //Eigen::Twistd delta_motion_srb = this->_srb_current_vel_in_sf*(this->_loop_period_ns/1e9);
109  //Eigen::Twistd srb_pose_in_sf_next = (delta_motion_srb.exp(1e-12)*this->_srb_current_pose_in_sf.exp(1e-12)).log(1e-12);
110 
111  // OPTION2: We just give a random prediction
112  std::default_random_engine generator;;
113  std::uniform_real_distribution<double> distr(-100.0, 100.0); // define the range
114  Eigen::Twistd srb_pose_in_sf_next = Eigen::Twistd(distr(generator),distr(generator),distr(generator),
115  distr(generator),distr(generator),distr(generator) );
116 
117  geometry_msgs::TwistWithCovariance hypothesis;
118  hypothesis.twist.linear.x = srb_pose_in_sf_next.vx();
119  hypothesis.twist.linear.y = srb_pose_in_sf_next.vy();
120  hypothesis.twist.linear.z = srb_pose_in_sf_next.vz();
121  hypothesis.twist.angular.x = srb_pose_in_sf_next.rx();
122  hypothesis.twist.angular.y = srb_pose_in_sf_next.ry();
123  hypothesis.twist.angular.z = srb_pose_in_sf_next.rz();
124 
125  // If the bodies are disconnected, we cannot use the kinematic structure to give an accurate predition
126  for (unsigned int i = 0; i < 6; i++)
127  {
128  for (unsigned int j = 0; j < 6; j++)
129  {
130  if(i == j)
131  {
132  hypothesis.covariance[6 * i + j] = 1.0e6;
133  }else
134  {
135  hypothesis.covariance[6 * i + j] = 1.0e3;
136  }
137  }
138  }
139 
140 
141 #ifdef PUBLISH_PREDICTED_POSE_AS_PWC
142  // This is used to visualize the predictions based on the joint hypothesis
143  // Get the poses and covariances on the poses (pose with cov) of each RB
144  geometry_msgs::PoseWithCovarianceStamped pose_with_cov_stamped;
145  pose_with_cov_stamped.header.stamp = ros::Time::now();
146  pose_with_cov_stamped.header.frame_id = "camera_rgb_optical_frame";
147 
148  Eigen::Displacementd displ_from_twist = srb_pose_in_sf_next.exp(1e-12);
149  pose_with_cov_stamped.pose.pose.position.x = displ_from_twist.x();
150  pose_with_cov_stamped.pose.pose.position.y = displ_from_twist.y();
151  pose_with_cov_stamped.pose.pose.position.z = displ_from_twist.z();
152  pose_with_cov_stamped.pose.pose.orientation.x = displ_from_twist.qx();
153  pose_with_cov_stamped.pose.pose.orientation.y = displ_from_twist.qy();
154  pose_with_cov_stamped.pose.pose.orientation.z = displ_from_twist.qz();
155  pose_with_cov_stamped.pose.pose.orientation.w = displ_from_twist.qw();
156 
157  for (unsigned int i = 0; i < 6; i++)
158  for (unsigned int j = 0; j < 6; j++)
159  pose_with_cov_stamped.pose.covariance[6 * i + j] = hypothesis.covariance[6 * i + j];
160 
161  _predicted_next_pose_publisher.publish(pose_with_cov_stamped);
162 #endif
163 
164  return hypothesis;
165 }
166 
167 std::vector<visualization_msgs::Marker> DisconnectedJointFilter::getJointMarkersInRRBFrame() const
168 {
169  // Delete other markers
170  std::vector<visualization_msgs::Marker> empty_vector;
171  visualization_msgs::Marker empty_marker;
172  empty_marker.pose.position.x = 0.;
173  empty_marker.pose.position.y = 0.;
174  empty_marker.pose.position.z = 0.;
175  //empty_marker.header.frame_id = "camera_rgb_optical_frame";
176  empty_marker.type = visualization_msgs::Marker::SPHERE;
177  empty_marker.action = visualization_msgs::Marker::DELETE;
178  empty_marker.scale.x = 0.0001; //Using start and end points, scale.x is the radius of the array body
179  empty_marker.scale.y = 0.0001; //Using start and end points, scale.x is the radius of the array body
180  empty_marker.scale.z = 0.0001; //Using start and end points, scale.x is the radius of the array body
181  empty_marker.color.a = 0.3;
182  empty_marker.color.r = 0.0;
183  empty_marker.color.g = 0.0;
184  empty_marker.color.b = 1.0;
185  empty_marker.ns = "kinematic_structure";
186  empty_marker.id = 3 * this->_joint_id;
187  empty_vector.push_back(empty_marker);
188  empty_marker.id = 3 * this->_joint_id + 1;
189  empty_vector.push_back(empty_marker);
190  empty_marker.id = 3 * this->_joint_id + 2;
191  empty_vector.push_back(empty_marker);
192  empty_marker.ns = "kinematic_structure_uncertainty";
193  empty_marker.id = 3 * this->_joint_id ;
194  empty_vector.push_back(empty_marker);
195  empty_marker.id = 3 * this->_joint_id + 1;
196  empty_vector.push_back(empty_marker);
197  empty_marker.id = 3 * this->_joint_id + 2;
198  empty_vector.push_back(empty_marker);
199 
200  return empty_vector;
201 }
202 
204 {
205  return DISCONNECTED_JOINT;
206 }
207 
209 {
210  return std::string("DisconnectedJointFilter");
211 }
212 
213 
virtual geometry_msgs::TwistWithCovariance getPredictedSRBVelocityWithCovInSensorFrame()
Generate a prediction about the velocity of the second rigid body (SRB) and its covariance using the ...
virtual geometry_msgs::TwistWithCovariance getPredictedSRBDeltaPoseWithCovInSensorFrame()
Generate a prediction about the change in pose of the second rigid body (SRB) and its covariance usin...
JointFilterType
Definition: JointFilter.h:71
virtual double getProbabilityOfJointFilter() const
Return the normalized joint filter probability of the Disconnected Joint model, which is a constant v...
virtual JointFilterType getJointFilterType() const
virtual std::string getJointFilterTypeStr() const
double _normalizing_term
Definition: JointFilter.h:349
double _unnormalized_model_probability
Definition: JointFilter.h:351
virtual geometry_msgs::TwistWithCovariance getPredictedSRBPoseWithCovInSensorFrame()
Generate a prediction about the pose-twist of the second rigid body (SRB) and its covariance using th...
virtual std::vector< visualization_msgs::Marker > getJointMarkersInRRBFrame() const
JointCombinedFilterId _joint_id
Definition: JointFilter.h:332
static Time now()


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