ocra-wbi-plugins
Doxygen documentation for the ocra-wbi-plugins repository
ocra-wbi-plugins/ocra-icub-server/include/ocra-icub-server/IcubControllerServer.h
Go to the documentation of this file.
00001 #ifndef ICUB_CONTROLLER_SERVER_H
00002 #define ICUB_CONTROLLER_SERVER_H
00003 
00004 #include <wbi/wbi.h>
00005 #include <ocra-recipes/ControllerServer.h>
00006 #include <Eigen/Dense>
00007 #include <ocra-icub/OcraWbiModel.h>
00008 #include <iDynTree/Estimation/SimpleLeggedOdometry.h>
00009 #include <ocra/util/ErrorsHelper.h>
00010 
00011 class IcubControllerServer : public ocra_recipes::ControllerServer
00012 {
00013 public:
00014     // IcubControllerServer();
00015     IcubControllerServer(   std::shared_ptr<wbi::wholeBodyInterface> robot,
00016                             std::string icubName,
00017                             const bool usingFloatingBase,
00018                             const ocra_recipes::CONTROLLER_TYPE ctrlType=ocra_recipes::WOCRA_CONTROLLER,
00019                             const ocra_recipes::SOLVER_TYPE solver=ocra_recipes::QUADPROG,
00020                             const bool usingInterprocessCommunication=true,
00021                             const bool useOdometry=false
00022                         );
00023     virtual ~IcubControllerServer();
00024 
00025     virtual ocra::Model::Ptr loadRobotModel();
00026 
00027     virtual void getRobotState(Eigen::VectorXd& q, Eigen::VectorXd& qd, Eigen::Displacementd& H_root, Eigen::Twistd& T_root);
00028     
00029     // Odometry related methods
00030     bool initializeOdometry(std::string model_file, std::string initialFixedFrame);
00031     std::vector<std::string> getCanonical_iCubJoints();
00032     // Not in the virtual class
00033     void rootFrameVelocity(Eigen::VectorXd& q,
00034                            Eigen::VectorXd& qd,
00035                            iDynTree::Transform& wbi_H_root_Transform,
00036                            double           regularization,
00037                            int              LEFT_FOOT_CONTACT,
00038                            int              RIGHT_FOOT_CONTACT,
00039                            Eigen::VectorXd& twist);
00040     
00041     void rootFrameVelocityPivLU(Eigen::VectorXd& q,
00042                                 Eigen::VectorXd& qd,
00043                                 iDynTree::Transform& wbi_H_root_Transform,
00044                                 Eigen::VectorXd& twist);
00045     
00046     void rootFrameVelocityPivLU(Eigen::VectorXd& q,
00047                                 Eigen::VectorXd& qd,
00048                                 iDynTree::Transform& wbi_H_root_Transform,
00049                                 int              LEFT_FOOT_CONTACT,
00050                                 int              RIGHT_FOOT_CONTACT,
00051                                 Eigen::VectorXd& twist);
00052     
00053     void pinv(Eigen::MatrixXd mat, Eigen::MatrixXd& pinvmat, double pinvtoler=1.0e-6) const;
00054     
00055     void velocityError(Eigen::MatrixXd A, Eigen::MatrixXd B, Eigen::MatrixXd X);
00056 private:
00057     std::shared_ptr<wbi::wholeBodyInterface> wbi; 
00058     std::string robotName;
00059     bool isFloatingBase;
00060     bool useOdometry;
00061     static constexpr double ALL_JOINTS = -1.0;
00062     int nDoF;
00063 
00064     Eigen::VectorXd wbi_H_root_Vector;
00065     Eigen::VectorXd wbi_T_root_Vector;
00066     wbi::Frame wbi_H_root;
00067     
00068     iDynTree::SimpleLeggedOdometry odometry;
00069     
00070 };
00071 
00072 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines