1 |
|
|
/* |
2 |
|
|
* Copyright 2016, |
3 |
|
|
* |
4 |
|
|
* Olivier Stasse |
5 |
|
|
* |
6 |
|
|
* LAAS, CNRS |
7 |
|
|
* |
8 |
|
|
* This file is part of TalosController. |
9 |
|
|
* TalosController is not a free software, |
10 |
|
|
* it contains information related to Talos which involves |
11 |
|
|
* that you either purchased the proper license to havec access to |
12 |
|
|
* those informations, or that you signed the appropriate |
13 |
|
|
* Non-Disclosure agreement. |
14 |
|
|
* |
15 |
|
|
* |
16 |
|
|
*/ |
17 |
|
|
|
18 |
|
|
#ifndef _SOT_TalosDevice_H_ |
19 |
|
|
#define _SOT_TalosDevice_H_ |
20 |
|
|
|
21 |
|
|
#include <dynamic-graph/entity.h> |
22 |
|
|
#include <dynamic-graph/linear-algebra.h> |
23 |
|
|
#include <dynamic-graph/signal-ptr.h> |
24 |
|
|
#include <dynamic-graph/signal.h> |
25 |
|
|
|
26 |
|
|
#include <sot/core/abstract-sot-external-interface.hh> |
27 |
|
|
#include <sot/core/device.hh> |
28 |
|
|
#include <sot/core/matrix-geometry.hh> |
29 |
|
|
|
30 |
|
|
namespace dgsot = dynamicgraph::sot; |
31 |
|
|
namespace dg = dynamicgraph; |
32 |
|
|
|
33 |
|
|
class SoTTalosDevice : public dgsot::Device { |
34 |
|
|
public: |
35 |
|
|
static const std::string CLASS_NAME; |
36 |
|
|
static const double TIMESTEP_DEFAULT; |
37 |
|
|
|
38 |
|
|
virtual const std::string &getClassName() const { return CLASS_NAME; } |
39 |
|
|
|
40 |
|
|
SoTTalosDevice(std::string RobotName); |
41 |
|
|
virtual ~SoTTalosDevice(); |
42 |
|
|
|
43 |
|
|
void setSensors(std::map<std::string, dgsot::SensorValues> &sensorsIn); |
44 |
|
|
|
45 |
|
|
void setupSetSensors(std::map<std::string, dgsot::SensorValues> &sensorsIn); |
46 |
|
|
|
47 |
|
|
void nominalSetSensors(std::map<std::string, dgsot::SensorValues> &sensorsIn); |
48 |
|
|
|
49 |
|
|
void cleanupSetSensors(std::map<std::string, dgsot::SensorValues> &sensorsIn); |
50 |
|
|
|
51 |
|
|
void getControl(std::map<std::string, dgsot::ControlValues> &anglesOut); |
52 |
|
|
|
53 |
|
|
void timeStep(double ts) { timestep_ = ts; } |
54 |
|
|
|
55 |
|
|
protected: |
56 |
|
|
/// \brief Previous robot configuration. |
57 |
|
|
dg::Vector previousState_; |
58 |
|
|
|
59 |
|
|
/// Intermediate variables to avoid allocation during control |
60 |
|
|
std::vector<double> baseff_; |
61 |
|
|
|
62 |
|
|
/// Accelerations measured by accelerometers |
63 |
|
|
dynamicgraph::Signal<dg::Vector, int> accelerometerSOUT_; |
64 |
|
|
/// Rotation velocity measured by gyrometers |
65 |
|
|
dynamicgraph::Signal<dg::Vector, int> gyrometerSOUT_; |
66 |
|
|
/// motor currents |
67 |
|
|
dynamicgraph::Signal<dg::Vector, int> currentsSOUT_; |
68 |
|
|
/// joint angles |
69 |
|
|
dynamicgraph::Signal<dg::Vector, int> joint_anglesSOUT_; |
70 |
|
|
/// motor angles |
71 |
|
|
dynamicgraph::Signal<dg::Vector, int> motor_anglesSOUT_; |
72 |
|
|
|
73 |
|
|
/// proportional and derivative position-control gains |
74 |
|
|
dynamicgraph::Signal<dg::Vector, int> p_gainsSOUT_; |
75 |
|
|
|
76 |
|
|
dynamicgraph::Signal<dg::Vector, int> d_gainsSOUT_; |
77 |
|
|
|
78 |
|
|
/// Protected methods for internal variables filling |
79 |
|
|
void setSensorsForce(std::map<std::string, dgsot::SensorValues> &SensorsIn, |
80 |
|
|
int t); |
81 |
|
|
void setSensorsIMU(std::map<std::string, dgsot::SensorValues> &SensorsIn, |
82 |
|
|
int t); |
83 |
|
|
void setSensorsEncoders(std::map<std::string, dgsot::SensorValues> &SensorsIn, |
84 |
|
|
int t); |
85 |
|
|
void setSensorsVelocities( |
86 |
|
|
std::map<std::string, dgsot::SensorValues> &SensorsIn, int t); |
87 |
|
|
void setSensorsTorquesCurrents( |
88 |
|
|
std::map<std::string, dgsot::SensorValues> &SensorsIn, int t); |
89 |
|
|
void setSensorsGains(std::map<std::string, dgsot::SensorValues> &SensorsIn, |
90 |
|
|
int t); |
91 |
|
|
|
92 |
|
|
/// Intermediate variables to avoid allocation during control |
93 |
|
|
dg::Vector dgforces_; |
94 |
|
|
dg::Vector dgRobotState_; // motor-angles |
95 |
|
|
dg::Vector joint_angles_; // joint-angles |
96 |
|
|
dg::Vector motor_angles_; // motor-angles |
97 |
|
|
dg::Vector dgRobotVelocity_; // motor velocities |
98 |
|
|
dg::Vector velocities_; // motor velocities |
99 |
|
|
dgsot::MatrixRotation pose; |
100 |
|
|
dg::Vector accelerometer_; |
101 |
|
|
dg::Vector gyrometer_; |
102 |
|
|
dg::Vector torques_; |
103 |
|
|
dg::Vector currents_; |
104 |
|
|
dg::Vector p_gains_; |
105 |
|
|
dg::Vector d_gains_; |
106 |
|
|
}; |
107 |
|
|
#endif /* _SOT_TalosDevice_H_*/ |