1 |
|
|
/* |
2 |
|
|
* Copyright 2016, |
3 |
|
|
* |
4 |
|
|
* Olivier Stasse |
5 |
|
|
* |
6 |
|
|
* LAAS, CNRS |
7 |
|
|
* |
8 |
|
|
* This file is part of TiagoController. |
9 |
|
|
* TiagoController is not a free software, |
10 |
|
|
* it contains information related to Tiago 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_TiagoDevice_H_ |
19 |
|
|
#define _SOT_TiagoDevice_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 SoTTiagoDevice : 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 |
|
|
SoTTiagoDevice(std::string RobotName); |
41 |
|
|
virtual ~SoTTiagoDevice(); |
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 setLeftWheelIndex(int idx); |
54 |
|
|
|
55 |
|
|
void setRightWheelIndex(int idx); |
56 |
|
|
|
57 |
|
|
/// \todo this should go into the parent class, in sot-core package |
58 |
|
|
void setTimeStep(double dt) { timestep_ = dt; } |
59 |
|
|
|
60 |
|
|
protected: |
61 |
|
|
void setClosedLoop(const bool &closedLoop) { closedLoop_ = closedLoop; }; |
62 |
|
|
|
63 |
|
|
/// \brief Whether the control of the base should be expressed in odometry |
64 |
|
|
/// frame of base frame. |
65 |
|
|
bool closedLoop_; |
66 |
|
|
|
67 |
|
|
/// \brief Previous robot configuration. |
68 |
|
|
dg::Vector previousState_; |
69 |
|
|
|
70 |
|
|
/// Intermediate variables to avoid allocation during control |
71 |
|
|
std::vector<double> baseff_; |
72 |
|
|
|
73 |
|
|
/// Accelerations measured by accelerometers |
74 |
|
|
dynamicgraph::Signal<dg::Vector, int> accelerometerSOUT_; |
75 |
|
|
/// Rotation velocity measured by gyrometers |
76 |
|
|
dynamicgraph::Signal<dg::Vector, int> gyrometerSOUT_; |
77 |
|
|
/// motor currents |
78 |
|
|
dynamicgraph::Signal<dg::Vector, int> currentSOUT_; |
79 |
|
|
|
80 |
|
|
/// proportional and derivative position-control gains |
81 |
|
|
dynamicgraph::Signal<dg::Vector, int> p_gainsSOUT_; |
82 |
|
|
|
83 |
|
|
dynamicgraph::Signal<dg::Vector, int> d_gainsSOUT_; |
84 |
|
|
|
85 |
|
|
/// Intermediate variables to avoid allocation during control |
86 |
|
|
dg::Vector dgforces_; |
87 |
|
|
dg::Vector dgRobotState_; |
88 |
|
|
dgsot::MatrixRotation pose; |
89 |
|
|
dg::Vector accelerometer_; |
90 |
|
|
dg::Vector gyrometer_; |
91 |
|
|
dg::Vector torques_; |
92 |
|
|
dg::Vector currents_; |
93 |
|
|
dg::Vector p_gains_; |
94 |
|
|
dg::Vector d_gains_; |
95 |
|
|
|
96 |
|
|
int leftWheelIdx_, rightWheelIdx_; |
97 |
|
|
}; |
98 |
|
|
#endif /* _SOT_TiagoDevice_H_*/ |