sot-talos-balance  1.6.0
simple-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_simple_distribute_wrench_H__
18 #define __sot_talos_balance_simple_distribute_wrench_H__
19 
20 /* --------------------------------------------------------------------- */
21 /* --- API ------------------------------------------------------------- */
22 /* --------------------------------------------------------------------- */
23 
24 #if defined (WIN32)
25 # if defined (position_controller_EXPORTS)
26 # define SIMPLE_DISTRIBUTE_WRENCH_EXPORT __declspec(dllexport)
27 # else
28 # define SIMPLE_DISTRIBUTE_WRENCH_EXPORT __declspec(dllimport)
29 # endif
30 #else
31 # define SIMPLE_DISTRIBUTE_WRENCH_EXPORT
32 #endif
33 
34 
35 /* --------------------------------------------------------------------- */
36 /* --- INCLUDE --------------------------------------------------------- */
37 /* --------------------------------------------------------------------- */
38 
39 #include <pinocchio/fwd.hpp>
40 #include <dynamic-graph/signal-helper.h>
41 
42 #include <map>
43 #include "boost/assign.hpp"
44 #include <sot/core/robot-utils.hh>
45 
46 #include <pinocchio/multibody/model.hpp>
47 #include <pinocchio/multibody/data.hpp>
48 
49 namespace dynamicgraph {
50  namespace sot {
51  namespace talos_balance {
52 
53  /* --------------------------------------------------------------------- */
54  /* --- CLASS ----------------------------------------------------------- */
55  /* --------------------------------------------------------------------- */
56 
58  : public ::dynamicgraph::Entity
59  {
60  DYNAMIC_GRAPH_ENTITY_DECL();
61 
62  public:
63  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
64 
65  /* --- CONSTRUCTOR ---- */
66  SimpleDistributeWrench( const std::string & name );
67 
68  void init(const std::string& robotName);
69 
70  /* --- SIGNALS --- */
71  DECLARE_SIGNAL_IN(wrenchDes, dynamicgraph::Vector);
72  DECLARE_SIGNAL_IN(q, dynamicgraph::Vector);
73  DECLARE_SIGNAL_IN(rho, double);
74  DECLARE_SIGNAL_IN(phase, int);
75 
76  DECLARE_SIGNAL_INNER(kinematics_computations, int);
77  DECLARE_SIGNAL_INNER(wrenches, int);
78 
79  DECLARE_SIGNAL_OUT(wrenchLeft, dynamicgraph::Vector);
80  DECLARE_SIGNAL_OUT(ankleWrenchLeft, dynamicgraph::Vector);
81  DECLARE_SIGNAL_OUT(copLeft, dynamicgraph::Vector);
82  DECLARE_SIGNAL_OUT(wrenchRight, dynamicgraph::Vector);
83  DECLARE_SIGNAL_OUT(ankleWrenchRight, dynamicgraph::Vector);
84  DECLARE_SIGNAL_OUT(copRight, dynamicgraph::Vector);
85 
86  DECLARE_SIGNAL_OUT(wrenchRef, dynamicgraph::Vector);
87  DECLARE_SIGNAL_OUT(zmpRef, dynamicgraph::Vector);
88  DECLARE_SIGNAL_OUT(emergencyStop, bool);
89 
90  /* --- COMMANDS --- */
91  /* --- ENTITY INHERITANCE --- */
92  virtual void display( std::ostream& os ) const;
93 
94  Eigen::Vector3d computeCoP(const dynamicgraph::Vector & wrench, const pinocchio::SE3 & pose) const;
95 
96  protected:
98  pinocchio::Model m_model;
99  pinocchio::Data m_data;
100  RobotUtilShrPtr m_robot_util;
101 
102 // pinocchio::SE3 m_ankle_M_ftSens; /// ankle to F/T sensor transformation
103  pinocchio::SE3 m_ankle_M_sole;
104 
105  pinocchio::FrameIndex m_left_foot_id;
106  pinocchio::FrameIndex m_right_foot_id;
107 
108  pinocchio::SE3 m_contactLeft;
109  pinocchio::SE3 m_contactRight;
110 
111  Eigen::Matrix<double,6,1> m_wrenchLeft;
112  Eigen::Matrix<double,6,1> m_wrenchRight;
113 
114  bool distributeWrench(const Eigen::VectorXd & wrenchDes, const double rho);
115  bool saturateWrench(const Eigen::VectorXd & wrenchDes, const int phase);
116 
118  }; // class SimpleDistributeWrench
119 
120  } // namespace talos_balance
121  } // namespace sot
122 } // namespace dynamicgraph
123 
124 
125 
126 #endif // #ifndef __sot_talos_balance_simple_distribute_wrench_H__
pinocchio::Model m_model
true if the entity has been successfully initialized
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition: math/fwd.hh:40
pinocchio::FrameIndex m_left_foot_id
ankle to sole transformation
#define SIMPLE_DISTRIBUTE_WRENCH_EXPORT