sot-torque-control  1.6.5
Collection of dynamic-graph entities aimed at implementing torque control on different robots.
position-controller.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2015, Andrea Del Prete, LAAS-CNRS
3  *
4  */
5 
6 #ifndef __sot_torque_control_position_controller_H__
7 #define __sot_torque_control_position_controller_H__
8 
9 /* --------------------------------------------------------------------- */
10 /* --- API ------------------------------------------------------------- */
11 /* --------------------------------------------------------------------- */
12 
13 #if defined(WIN32)
14 #if defined(position_controller_EXPORTS)
15 #define SOTPOSITIONCONTROLLER_EXPORT __declspec(dllexport)
16 #else
17 #define SOTPOSITIONCONTROLLER_EXPORT __declspec(dllimport)
18 #endif
19 #else
20 #define SOTPOSITIONCONTROLLER_EXPORT
21 #endif
22 
23 /* --------------------------------------------------------------------- */
24 /* --- INCLUDE --------------------------------------------------------- */
25 /* --------------------------------------------------------------------- */
26 
27 #include <pinocchio/fwd.hpp>
28 
29 // include pinocchio first
30 
31 #include <dynamic-graph/signal-helper.h>
32 
33 #include <boost/assign.hpp>
34 #include <map>
35 #include <sot/core/matrix-geometry.hh>
36 #include <sot/core/robot-utils.hh>
38 
39 namespace dynamicgraph {
40 namespace sot {
41 namespace torque_control {
42 
43 /* --------------------------------------------------------------------- */
44 /* --- CLASS ----------------------------------------------------------- */
45 /* --------------------------------------------------------------------- */
46 
48  : public ::dynamicgraph::Entity {
50  DYNAMIC_GRAPH_ENTITY_DECL();
51 
52  public:
53  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
54 
55  /* --- CONSTRUCTOR ---- */
56  PositionController(const std::string& name);
57 
58  void init(const double& dt, const std::string& robotRef);
59 
60  void resetIntegral();
61 
62  /* --- SIGNALS --- */
63  DECLARE_SIGNAL_IN(base6d_encoders, dynamicgraph::Vector);
64  DECLARE_SIGNAL_IN(jointsVelocities, dynamicgraph::Vector);
65  DECLARE_SIGNAL_IN(qRef, dynamicgraph::Vector);
66  DECLARE_SIGNAL_IN(dqRef, dynamicgraph::Vector);
67  DECLARE_SIGNAL_IN(Kp, dynamicgraph::Vector);
68  DECLARE_SIGNAL_IN(Kd, dynamicgraph::Vector);
69  DECLARE_SIGNAL_IN(Ki, dynamicgraph::Vector);
70 
71  DECLARE_SIGNAL_OUT(pwmDes,
72  dynamicgraph::Vector);
73  // DEBUG SIGNALS
74  DECLARE_SIGNAL_OUT(qError, dynamicgraph::Vector);
75 
76  /* --- COMMANDS --- */
77  /* --- ENTITY INHERITANCE --- */
78  virtual void display(std::ostream& os) const;
79 
80  void sendMsg(const std::string& msg, MsgType t = MSG_TYPE_INFO,
81  const char* = "", int = 0) {
82  logger_.stream(t) << ("[PositionController-" + name + "] " + msg) << '\n';
83  }
84 
85  protected:
86  RobotUtilShrPtr m_robot_util;
87  Eigen::VectorXd m_pwmDes;
88  bool
90  double m_dt;
91 
93  Eigen::VectorXd m_e_integral;
94 
95  Eigen::VectorXd m_q, m_dq;
96 
97 }; // class PositionController
98 
99 } // namespace torque_control
100 } // namespace sot
101 } // namespace dynamicgraph
102 
103 #endif // #ifndef __sot_torque_control_position_controller_H__
SOTPOSITIONCONTROLLER_EXPORT
#define SOTPOSITIONCONTROLLER_EXPORT
Definition: position-controller.hh:20
dynamicgraph
to read text file
Definition: treeview.dox:22
dynamicgraph::sot::torque_control::PositionController::sendMsg
void sendMsg(const std::string &msg, MsgType t=MSG_TYPE_INFO, const char *="", int=0)
Definition: position-controller.hh:80
vector-conversions.hh
dynamicgraph::sot::torque_control::PositionController::m_e_integral
Eigen::VectorXd m_e_integral
control loop time period
Definition: position-controller.hh:93
torque_control
Definition: __init__.py:1
dynamicgraph::sot::torque_control::PositionController::m_q
Eigen::VectorXd m_q
Definition: position-controller.hh:95
dynamicgraph::sot::torque_control::EntityClassName
AdmittanceController EntityClassName
Definition: admittance-controller.cpp:51
dynamicgraph::sot::torque_control::PositionController::m_initSucceeded
bool m_initSucceeded
Definition: position-controller.hh:89
dynamicgraph::sot::torque_control::PositionController::m_robot_util
RobotUtilShrPtr m_robot_util
Definition: position-controller.hh:86
dynamicgraph::sot::torque_control::PositionController::m_pwmDes
Eigen::VectorXd m_pwmDes
Robot Util.
Definition: position-controller.hh:87
dynamicgraph::sot::torque_control::PositionController
Definition: position-controller.hh:47
dynamicgraph::sot::torque_control::PositionController::m_dt
double m_dt
true if the entity has been successfully initialized
Definition: position-controller.hh:90