GCOP
1.0
|
00001 #ifndef GCOP_KINBODY3D_H 00002 #define GCOP_KINBODY3D_H 00003 00004 #include "system.h" 00005 #include <utility> 00006 #include "kinbody3dmanifold.h" 00007 #include "rn.h" 00008 #include "se3.h" 00009 00010 namespace gcop { 00011 00012 using namespace std; 00013 using namespace Eigen; 00014 00021 template<int _nu = 6> class Kinbody3d : public System<Matrix4d, 6, _nu> { 00022 public: 00023 typedef Matrix<double, _nu, 1> Vectorud; 00024 typedef Matrix<double, 6, _nu> Matrix6ud; 00025 typedef Matrix<double, 6, 6> Matrix6d; 00026 00027 Kinbody3d(); 00028 00029 virtual double Step(Matrix4d &xb, double t, const Matrix4d &xa, 00030 const Vectorud &u, double h, const VectorXd *p = 0, 00031 Matrix6d *A = 0, Matrix6ud *B = 0, Matrix<double, 6, Dynamic> *C = 0); 00032 00033 00034 Vector3d d; 00035 Matrix6ud Bu; 00036 }; 00037 00038 template <int _nu> 00039 Kinbody3d<_nu>::Kinbody3d() : System<Matrix4d, 6, _nu>(Kinbody3dManifold::Instance()), 00040 d(.1, .05, .05), 00041 Bu(Matrix<double, 6, _nu>::Identity()) 00042 { 00043 } 00044 00045 template <int _nu> 00046 double Kinbody3d<_nu>::Step(Matrix4d &xb, double t, const Matrix4d &xa, 00047 const Vectorud &u, double h, const VectorXd *p, 00048 Matrix6d *A, Matrix6ud *B, Matrix<double, 6, Dynamic> *C ) 00049 { 00050 SE3 &se3 = SE3::Instance(); 00051 Matrix4d m; 00052 Vector6d u_kin = Bu*u; 00053 00054 00055 se3.cay(m, h*u_kin); 00056 xb = xa*m; 00057 00058 if (A) { 00059 se3.cay(m, -h*u_kin); 00060 se3.Ad(*A, m); 00061 } 00062 00063 if (B) { 00064 Matrix6d mb; 00065 se3.dcay(mb, -h*u_kin); 00066 *B = h*mb*Bu; 00067 } 00068 00069 if (C) 00070 C->setZero(); 00071 } 00072 00073 } // gcop 00074 #endif