sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
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 /* --- INCLUDE --------------------------------------------------------- */
36 /* --------------------------------------------------------------------- */
37 
38 #include <pinocchio/fwd.hpp>
39 // include pinocchio first
40 #include <dynamic-graph/signal-helper.h>
41 
42 #include <map>
43 #include <pinocchio/multibody/data.hpp>
44 #include <pinocchio/multibody/model.hpp>
45 #include <sot/core/robot-utils.hh>
46 
47 #include "boost/assign.hpp"
48 
49 namespace dynamicgraph {
50 namespace sot {
51 namespace talos_balance {
52 
53 /* --------------------------------------------------------------------- */
54 /* --- CLASS ----------------------------------------------------------- */
55 /* --------------------------------------------------------------------- */
56 
58  : public ::dynamicgraph::Entity {
59  DYNAMIC_GRAPH_ENTITY_DECL();
60 
61  public:
62  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
63 
64  /* --- CONSTRUCTOR ---- */
65  SimpleDistributeWrench(const std::string& name);
66 
67  void init(const std::string& robotName);
68 
69  /* --- SIGNALS --- */
72  DECLARE_SIGNAL_IN(rho, double);
73  DECLARE_SIGNAL_IN(phase, int);
74 
75  DECLARE_SIGNAL_INNER(kinematics_computations, int);
76  DECLARE_SIGNAL_INNER(wrenches, int);
77 
86 
89  DECLARE_SIGNAL_OUT(emergencyStop, bool);
90 
91  public:
92  /* --- COMMANDS --- */
93  /* --- ENTITY INHERITANCE --- */
94  virtual void display(std::ostream& os) const;
95 
96  Eigen::Vector3d computeCoP(const dynamicgraph::Vector& wrench,
97  const pinocchio::SE3& pose) const;
98 
99  protected:
100  bool
102  pinocchio::Model m_model;
103  pinocchio::Data m_data;
104  RobotUtilShrPtr m_robot_util;
105 
106  // pinocchio::SE3 m_ankle_M_ftSens; /// ankle to F/T sensor
107  // transformation
108  pinocchio::SE3 m_ankle_M_sole;
109 
110  pinocchio::FrameIndex m_left_foot_id;
111  pinocchio::FrameIndex m_right_foot_id;
112 
113  pinocchio::SE3 m_contactLeft;
114  pinocchio::SE3 m_contactRight;
115 
116  Eigen::Matrix<double, 6, 1> m_wrenchLeft;
117  Eigen::Matrix<double, 6, 1> m_wrenchRight;
118 
119  void distributeWrench(const Eigen::VectorXd& wrenchDes, const double rho);
120  void saturateWrench(const Eigen::VectorXd& wrenchDes, const int phase);
121 
123 }; // class SimpleDistributeWrench
124 
125 } // namespace talos_balance
126 } // namespace sot
127 } // namespace dynamicgraph
128 
129 #endif // #ifndef __sot_talos_balance_simple_distribute_wrench_H__
DECLARE_SIGNAL_OUT(wrenchLeft, dynamicgraph::Vector)
DECLARE_SIGNAL_OUT(wrenchRef, dynamicgraph::Vector)
pinocchio::FrameIndex m_left_foot_id
ankle to sole transformation
DECLARE_SIGNAL_IN(wrenchDes, dynamicgraph::Vector)
DECLARE_SIGNAL_OUT(ankleWrenchRight, dynamicgraph::Vector)
DECLARE_SIGNAL_OUT(wrenchRight, dynamicgraph::Vector)
pinocchio::Model m_model
true if the entity has been successfully initialized
DECLARE_SIGNAL_OUT(ankleWrenchLeft, dynamicgraph::Vector)
DECLARE_SIGNAL_OUT(surfaceWrenchRight, dynamicgraph::Vector)
DECLARE_SIGNAL_OUT(surfaceWrenchLeft, dynamicgraph::Vector)
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition: fwd.hh:36
#define SIMPLE_DISTRIBUTE_WRENCH_EXPORT