A sparse MPC solver for walking motion generation (old version).
|
00001 00009 /**************************************** 00010 * INCLUDES 00011 ****************************************/ 00012 00013 #include <cmath> // sin, cos 00014 00015 #include "footstep.h" 00016 00017 00018 /**************************************** 00019 * FUNCTIONS 00020 ****************************************/ 00021 00032 footstep::footstep( 00033 const double angle_, 00034 const Transform<double, 3>& posture_, 00035 const Vector3d& ZMPref_, 00036 const unsigned int time_period_, 00037 const fs_type type_, 00038 const double *d_) : 00039 RectangularConstraint_ZMP(d_), 00040 ZMPref(ZMPref_) 00041 { 00042 posture = new Transform<double, 3>(posture_); 00043 type = type_; 00044 angle = angle_; 00045 ca = cos(angle); 00046 sa = sin(angle); 00047 rotate_translate(ca, sa, x(), y()); 00048 time_left = time_period = time_period_; 00049 } 00050 00051 00057 footstep::footstep (const footstep& copy_from) : 00058 RectangularConstraint_ZMP(copy_from), 00059 ZMPref(copy_from.ZMPref) 00060 { 00061 posture = new Transform<double, 3>(*copy_from.posture); 00062 type = copy_from.type; 00063 angle = copy_from.angle; 00064 ca = copy_from.ca; 00065 sa = copy_from.sa; 00066 time_left = copy_from.time_left; 00067 time_period = copy_from.time_period; 00068 } 00069 00070 00071 00075 footstep::~footstep() 00076 { 00077 delete posture; 00078 } 00079 00080 00084 double footstep::x() 00085 { 00086 return (posture->translation()[0]); 00087 } 00088 00089 00093 double footstep::y() 00094 { 00095 return (posture->translation()[1]); 00096 } 00097 00098 00099 00106 void footstep::changePosture (const double * new_posture, const bool zero_z_coordinate) 00107 { 00108 posture->matrix() = Matrix4d::Map(new_posture); 00109 if (zero_z_coordinate) 00110 { 00111 posture->translation()[2] = 0.0; 00112 } 00113 Matrix3d rotation = posture->matrix().corner(TopLeft,3,3); 00114 angle = rotation.eulerAngles(0,1,2)[2]; 00115 ca = cos(angle); 00116 sa = sin(angle); 00117 rotate_translate(ca, sa, x(), y()); 00118 }