NonLinearRevoluteMeasurementPdf.cpp
Go to the documentation of this file.
00001 #include "joint_tracker/pdf/NonLinearRevoluteMeasurementPdf.h"
00002 
00003 #include <Eigen/Geometry>
00004 #include <lgsm/Lgsm>
00005 #include <ros/ros.h>
00006 
00007 #include "omip_common/OMIPUtils.h"
00008 
00009 
00010 using namespace BFL;
00011 
00012 #define REV_PDF_DIM 6
00013 #define REV_CONDITIONAL_VAR_DIM 7
00014 #define REV_NUM_CONDITIONAL_ARGS 2
00015 
00016 NonLinearRevoluteMeasurementPdf::NonLinearRevoluteMeasurementPdf(const Gaussian& additiveNoise) :
00017     AnalyticConditionalGaussianAdditiveNoise(additiveNoise,REV_NUM_CONDITIONAL_ARGS),
00018     dfx(REV_PDF_DIM, REV_CONDITIONAL_VAR_DIM)
00019 {
00020 
00021 }
00022 
00023 NonLinearRevoluteMeasurementPdf::~NonLinearRevoluteMeasurementPdf()
00024 {
00025 
00026 }
00027 
00028 MatrixWrapper::ColumnVector NonLinearRevoluteMeasurementPdf::ExpectedValueGet() const
00029 {
00030     ColumnVector state = ConditionalArgumentGet(0);
00031 
00032     double phi = state(1);
00033     double theta = state(2);
00034     double sp = sin(phi);
00035     double cp = cos(phi);
00036     double st = sin(theta);
00037     double ct = cos(theta);
00038 
00039     double px = state(3);
00040     double py = state(4);
00041     double pz = state(5);
00042 
00043     Eigen::Vector3d rev_joint_orientation = Eigen::Vector3d(cp * st, sp * st, ct);
00044     Eigen::Vector3d rev_joint_position = Eigen::Vector3d(px, py, pz);
00045 
00046     double rv = state(6);
00047 
00048     Eigen::Vector3d joint_translation = (-rv * rev_joint_orientation).cross(rev_joint_position);
00049 
00050     Eigen::Twistd joint_pose = Eigen::Twistd(rv * rev_joint_orientation.x(),
00051                                              rv * rev_joint_orientation.y(),
00052                                              rv * rev_joint_orientation.z(),
00053                                              joint_translation.x(),
00054                                              joint_translation.y(),
00055                                              joint_translation.z());
00056 
00057     ColumnVector expected_pose(REV_PDF_DIM);
00058     expected_pose(1) = joint_pose.vx();
00059     expected_pose(2) = joint_pose.vy();
00060     expected_pose(3) = joint_pose.vz();
00061     expected_pose(4) = joint_pose.rx();
00062     expected_pose(5) = joint_pose.ry();
00063     expected_pose(6) = joint_pose.rz();
00064 
00065     return expected_pose + this->AdditiveNoiseMuGet();
00066 }
00067 
00068 MatrixWrapper::Matrix NonLinearRevoluteMeasurementPdf::dfGet(unsigned int i) const
00069 {
00070     if (i == 0) //derivative to the first conditional argument (x)
00071     {
00072         double phi = ConditionalArgumentGet(0)(1);
00073         double theta = ConditionalArgumentGet(0)(2);
00074         double sp = sin(phi);
00075         double cp = cos(phi);
00076         double st = sin(theta);
00077         double ct = cos(theta);
00078 
00079         double px = ConditionalArgumentGet(0)(3);
00080         double py = ConditionalArgumentGet(0)(4);
00081         double pz = ConditionalArgumentGet(0)(5);
00082         double rv = ConditionalArgumentGet(0)(6);
00083 
00084         dfx = 0;
00085 
00086         dfx(1, 1) = -rv * cp * st * pz;
00087         dfx(2, 1) = -rv * sp * st * pz;
00088         dfx(3, 1) = rv * st * (cp * px + sp * py);
00089         dfx(4, 1) = -rv * sp * st;
00090         dfx(5, 1) = rv * cp * st;
00091 
00092         dfx(1, 2) = -rv * (st * py + sp * ct * pz);
00093         dfx(2, 2) = rv * (cp * ct * pz + st * px);
00094         dfx(3, 2) = rv * ct * (sp * px - cp * py);
00095         dfx(4, 2) = rv * cp * ct;
00096         dfx(5, 2) = rv * sp * ct;
00097         dfx(6, 2) = -rv * st;
00098 
00099         dfx(2, 3) = -rv * ct;
00100         dfx(3, 3) = rv * sp * st;
00101 
00102         dfx(1, 4) = rv * ct;
00103         dfx(3, 4) = -rv * cp * st;
00104 
00105         dfx(1, 5) = -rv * sp * st;
00106         dfx(2, 5) = rv * cp * st;
00107 
00108         dfx(1, 6) = ct * py - sp * st * pz;
00109         dfx(2, 6) = cp * st * pz - ct * px;
00110         dfx(3, 6) = st * (sp * px - cp * py);
00111         dfx(4, 6) = cp * st;
00112         dfx(5, 6) = sp * st;
00113         dfx(6, 6) = ct;
00114 
00115         dfx(1, 7) = 0;
00116         dfx(2, 7) = 0;
00117         dfx(3, 7) = 0;
00118         dfx(4, 7) = 0;
00119         dfx(5, 7) = 0;
00120         dfx(6, 7) = 0;
00121         return dfx;
00122     }
00123     else
00124     {
00125         ROS_ERROR_STREAM_NAMED( "NonLinearRevoluteMeasurementPdf::dfGet",
00126                     "The derivative is not implemented for the " << i << "th conditional argument");
00127         exit(BFL_ERRMISUSE);
00128     }
00129 }
00130 


joint_tracker
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:26:46