sot-talos-balance  1.5.0
distribute-wrench.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2018, Gepetto team, LAAS-CNRS
3  *
4  * This file is part of sot-talos-balance.
5  * sot-talos-balance is free software: you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public License
7  * as published by the Free Software Foundation, either version 3 of
8  * the License, or (at your option) any later version.
9  * sot-talos-balance is distributed in the hope that it will be
10  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details. You should
13  * have received a copy of the GNU Lesser General Public License along
14  * with sot-talos-balance. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef __sot_talos_balance_distribute_wrench_H__
18 #define __sot_talos_balance_distribute_wrench_H__
19 
20 /* --------------------------------------------------------------------- */
21 /* --- API ------------------------------------------------------------- */
22 /* --------------------------------------------------------------------- */
23 
24 #if defined (WIN32)
25 # if defined (position_controller_EXPORTS)
26 # define DISTRIBUTE_WRENCH_EXPORT __declspec(dllexport)
27 # else
28 # define DISTRIBUTE_WRENCH_EXPORT __declspec(dllimport)
29 # endif
30 #else
31 # define DISTRIBUTE_WRENCH_EXPORT
32 #endif
33 
34 
35 /* --------------------------------------------------------------------- */
36 /* --- INCLUDE --------------------------------------------------------- */
37 /* --------------------------------------------------------------------- */
38 
39 #include <dynamic-graph/signal-helper.h>
40 
41 #include <map>
42 #include "boost/assign.hpp"
43 #include <sot/core/robot-utils.hh>
44 
45 #include <pinocchio/multibody/model.hpp>
46 #include <pinocchio/multibody/data.hpp>
47 
48 #include <eigen-quadprog/QuadProg.h>
49 
50 namespace dynamicgraph {
51  namespace sot {
52  namespace talos_balance {
53 
54  /* --------------------------------------------------------------------- */
55  /* --- CLASS ----------------------------------------------------------- */
56  /* --------------------------------------------------------------------- */
57 
59  : public ::dynamicgraph::Entity
60  {
61  DYNAMIC_GRAPH_ENTITY_DECL();
62 
63  public:
64  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
65 
66  /* --- CONSTRUCTOR ---- */
67  DistributeWrench( const std::string & name );
68 
69  void init(const std::string& robotName);
70 
71  /* --- SIGNALS --- */
72  DECLARE_SIGNAL_IN(wrenchDes, dynamicgraph::Vector);
73  DECLARE_SIGNAL_IN(q, dynamicgraph::Vector);
74 
75  DECLARE_SIGNAL_INNER(kinematics_computations, int);
76  DECLARE_SIGNAL_INNER(qp_computations, int);
77 
78  DECLARE_SIGNAL_OUT(wrenchLeft, dynamicgraph::Vector);
79  DECLARE_SIGNAL_OUT(copLeft, dynamicgraph::Vector);
80  DECLARE_SIGNAL_OUT(wrenchRight, dynamicgraph::Vector);
81  DECLARE_SIGNAL_OUT(copRight, dynamicgraph::Vector);
82 
83  DECLARE_SIGNAL_OUT(wrenchRef, dynamicgraph::Vector);
84  DECLARE_SIGNAL_OUT(zmpRef, dynamicgraph::Vector);
85  DECLARE_SIGNAL_OUT(emergencyStop, bool);
86 
87  /* --- COMMANDS --- */
88  /* --- ENTITY INHERITANCE --- */
89  virtual void display( std::ostream& os ) const;
90 
91  dynamicgraph::Vector computeCoP(const dynamicgraph::Vector & wrench, const pinocchio::SE3 & pose) const;
92 
93  protected:
95  pinocchio::Model m_model;
96  pinocchio::Data m_data;
97  RobotUtilShrPtr m_robot_util;
98 
99  pinocchio::SE3 m_ankle_M_ftSens;
100 
101  pinocchio::FrameIndex m_left_foot_id;
102  pinocchio::FrameIndex m_right_foot_id;
103 
106 
107 // Eigen::QuadProgDense m_qp1; // TODO: saturate wrench
108  Eigen::QuadProgDense m_qp2; // distribute wrench
109 
111  }; // class DistributeWrench
112 
113  } // namespace talos_balance
114  } // namespace sot
115 } // namespace dynamicgraph
116 
117 
118 
119 #endif // #ifndef __sot_talos_balance_distribute_wrench_H__
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition: math/fwd.hh:40
pinocchio::Data m_data
Pinocchio robot model.
#define DISTRIBUTE_WRENCH_EXPORT
pinocchio::FrameIndex m_left_foot_id
ankle to F/T sensor transformation
RobotUtilShrPtr m_robot_util
Pinocchio robot data.
pinocchio::Model m_model
true if the entity has been successfully initialized