NonLinearRevoluteMeasurementPdf.cpp
Go to the documentation of this file.
2 
3 #include <Eigen/Geometry>
4 #include <lgsm/Lgsm>
5 #include <ros/ros.h>
6 
8 
9 
10 using namespace BFL;
11 
12 #define REV_PDF_DIM 6
13 #define REV_CONDITIONAL_VAR_DIM 7
14 #define REV_NUM_CONDITIONAL_ARGS 2
15 
17  AnalyticConditionalGaussianAdditiveNoise(additiveNoise,REV_NUM_CONDITIONAL_ARGS),
19 {
20 
21 }
22 
24 {
25 
26 }
27 
28 MatrixWrapper::ColumnVector NonLinearRevoluteMeasurementPdf::ExpectedValueGet() const
29 {
30  ColumnVector state = ConditionalArgumentGet(0);
31 
32  double phi = state(1);
33  double theta = state(2);
34  double sp = sin(phi);
35  double cp = cos(phi);
36  double st = sin(theta);
37  double ct = cos(theta);
38 
39  double px = state(3);
40  double py = state(4);
41  double pz = state(5);
42 
43  Eigen::Vector3d rev_joint_orientation = Eigen::Vector3d(cp * st, sp * st, ct);
44  Eigen::Vector3d rev_joint_position = Eigen::Vector3d(px, py, pz);
45 
46  double rv = state(6);
47 
48  Eigen::Vector3d joint_translation = (-rv * rev_joint_orientation).cross(rev_joint_position);
49 
50  Eigen::Twistd joint_pose = Eigen::Twistd(rv * rev_joint_orientation.x(),
51  rv * rev_joint_orientation.y(),
52  rv * rev_joint_orientation.z(),
53  joint_translation.x(),
54  joint_translation.y(),
55  joint_translation.z());
56 
57  ColumnVector expected_pose(REV_PDF_DIM);
58  expected_pose(1) = joint_pose.vx();
59  expected_pose(2) = joint_pose.vy();
60  expected_pose(3) = joint_pose.vz();
61  expected_pose(4) = joint_pose.rx();
62  expected_pose(5) = joint_pose.ry();
63  expected_pose(6) = joint_pose.rz();
64 
65  return expected_pose + this->AdditiveNoiseMuGet();
66 }
67 
68 MatrixWrapper::Matrix NonLinearRevoluteMeasurementPdf::dfGet(unsigned int i) const
69 {
70  if (i == 0) //derivative to the first conditional argument (x)
71  {
72  double phi = ConditionalArgumentGet(0)(1);
73  double theta = ConditionalArgumentGet(0)(2);
74  double sp = sin(phi);
75  double cp = cos(phi);
76  double st = sin(theta);
77  double ct = cos(theta);
78 
79  double px = ConditionalArgumentGet(0)(3);
80  double py = ConditionalArgumentGet(0)(4);
81  double pz = ConditionalArgumentGet(0)(5);
82  double rv = ConditionalArgumentGet(0)(6);
83 
84  dfx = 0;
85 
86  dfx(1, 1) = -rv * cp * st * pz;
87  dfx(2, 1) = -rv * sp * st * pz;
88  dfx(3, 1) = rv * st * (cp * px + sp * py);
89  dfx(4, 1) = -rv * sp * st;
90  dfx(5, 1) = rv * cp * st;
91 
92  dfx(1, 2) = -rv * (st * py + sp * ct * pz);
93  dfx(2, 2) = rv * (cp * ct * pz + st * px);
94  dfx(3, 2) = rv * ct * (sp * px - cp * py);
95  dfx(4, 2) = rv * cp * ct;
96  dfx(5, 2) = rv * sp * ct;
97  dfx(6, 2) = -rv * st;
98 
99  dfx(2, 3) = -rv * ct;
100  dfx(3, 3) = rv * sp * st;
101 
102  dfx(1, 4) = rv * ct;
103  dfx(3, 4) = -rv * cp * st;
104 
105  dfx(1, 5) = -rv * sp * st;
106  dfx(2, 5) = rv * cp * st;
107 
108  dfx(1, 6) = ct * py - sp * st * pz;
109  dfx(2, 6) = cp * st * pz - ct * px;
110  dfx(3, 6) = st * (sp * px - cp * py);
111  dfx(4, 6) = cp * st;
112  dfx(5, 6) = sp * st;
113  dfx(6, 6) = ct;
114 
115  dfx(1, 7) = 0;
116  dfx(2, 7) = 0;
117  dfx(3, 7) = 0;
118  dfx(4, 7) = 0;
119  dfx(5, 7) = 0;
120  dfx(6, 7) = 0;
121  return dfx;
122  }
123  else
124  {
125  ROS_ERROR_STREAM_NAMED( "NonLinearRevoluteMeasurementPdf::dfGet",
126  "The derivative is not implemented for the " << i << "th conditional argument");
127  exit(BFL_ERRMISUSE);
128  }
129 }
130 
#define REV_CONDITIONAL_VAR_DIM
NonLinearRevoluteMeasurementPdf(const Gaussian &additiveNoise)
#define ROS_ERROR_STREAM_NAMED(name, args)
TFSIMD_FORCE_INLINE Vector3 cross(const Vector3 &v) const
virtual MatrixWrapper::ColumnVector ExpectedValueGet() const
Get the expected value E[x] of the pdf Get low order statistic (Expected Value) of this AnalyticPdf...
virtual MatrixWrapper::Matrix dfGet(unsigned int i) const
Returns derivative from function to n-th conditional variable.
#define REV_NUM_CONDITIONAL_ARGS
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)


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