ocra-wbi-plugins
Doxygen documentation for the ocra-wbi-plugins repository
ocra-wbi-plugins/ocra-icub-clients/walking-client/include/walking-client/MIQPState.h
Go to the documentation of this file.
00001 
00010 #ifndef _MIQP_STATE_H_
00011 #define _MIQP_STATE_H_
00012 
00013 #include <Eigen/Dense>
00014 #include <ocra-icub/OcraWbiModel.h>
00015 #include <ocra/util/ErrorsHelper.h>
00016 #include "walking-client/utils.h"
00017 #include <ocra-icub/Utilities.h>
00018 
00019 namespace MIQP{
00020     enum StateVectorIndex{
00021         A_X=0,
00022         A_Y,
00023         B_X,
00024         B_Y,
00025         ALPHA_X,
00026         ALPHA_Y,
00027         BETA_X,
00028         BETA_Y,
00029         DELTA,
00030         GAMMA,
00031         H_X,
00032         H_Y,
00033         DH_X,
00034         DH_Y,
00035         DDH_X,
00036         DDH_Y
00037     };
00038 
00039 
00040     class MIQPState {
00041     private:
00045         Eigen::VectorXd _xi_k;
00050         Eigen::Vector2d _a;
00055         Eigen::Vector2d _b;
00059         Eigen::Vector2d _alpha;
00063         Eigen::Vector2d _beta;
00074         unsigned int          _delta;
00075 
00081         unsigned int          _gamma;
00082 
00086         Eigen::VectorXd _hk;
00087 
00092         ocra::Model::Ptr _robotModel;
00093 
00097         std::string _robot;
00098 
00099         /*
00100          * Right foot coordinates
00101          */
00102         Eigen::Vector3d _r_foot_coord;
00103 
00104         /*
00105          * Left foot coordinates
00106          */
00107         Eigen::Vector3d _l_foot_coord;
00108 
00109         /*
00110          * Port that connects to the left foot F/T sensor.
00111          */
00112         yarp::os::BufferedPort<yarp::sig::Vector> _portWrenchLeftFoot;
00113 
00114         /*
00115          * Port that connect to the right F/T sensor.
00116          */
00117         yarp::os::BufferedPort<yarp::sig::Vector> _portWrenchRightFoot;
00118 
00119         /*
00120          * Normal force threshold
00121          */
00122         double _FzThreshold; // N
00123 
00124         /*
00125          * Normal distance threshold
00126          */
00127         double _PzThreshold; // m
00128 
00129     public:
00130 
00131         MIQPState (ocra::Model::Ptr robotModel, std::string robot);
00132 
00133         virtual ~MIQPState ();
00134 
00140         bool initialize();
00141 
00146         void updateStateVector();
00147 
00159         void updateBaseOfSupportDescriptors(Eigen::Vector2d &a,
00160                                             Eigen::Vector2d &b,
00161                                             Eigen::Vector2d &alpha,
00162                                             Eigen::Vector2d &beta,
00163                                             unsigned int &delta,
00164                                             unsigned int &gamma,
00165                                             double thresholdChange);
00166 
00172         void updateHorizontalCoMState(Eigen::VectorXd &hk);
00173 
00180         bool isRobotInSS(FOOT &footInSS);
00181 
00191         bool isFootInContact(FOOT whichFoot, double FzThreshold, double PzThreshold);
00192 
00200         bool readFootWrench(FOOT whichFoot, Eigen::VectorXd &rawWrench);
00201 
00207         void getFullState(Eigen::VectorXd &xi);
00208 
00209         
00215         Eigen::Vector3d getLeftFootPosition();
00216         
00217         
00223         Eigen::Vector3d getRightFootPosition();
00224         
00228         friend std::ostream& operator<<(std::ostream &out, const MIQPState &state) {
00229             out << "----- State Vector xi_k ----- \n";
00230             out << "\ta    : [" << state._a.transpose()               << "]\n";
00231             out << "\tb    : [" << state._b.transpose()               << "]\n";
00232             out << "\talpha: [" << state._alpha.transpose()           << "]\n";
00233             out << "\tbeta : [" << state._beta.transpose()            << "]\n";
00234             out << "\tdelta:  " << state._delta                       << "]\n";
00235             out << "\tgamma:  " << state._gamma                       << " \n";
00236             out << "\th    : [" << state._hk.head(2).transpose()       << " \n";
00237             out << "\tdh   : [" << state._hk.segment<2>(2).transpose()<< "]\n";
00238             out << "\tddh  : [" << state._hk.tail(2).transpose()      << "]\n";
00239             return out;
00240         }
00241 
00242     };
00243 } // end of namespace
00244 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines