1 |
|
|
/* |
2 |
|
|
* Author: Joseph Mirabel |
3 |
|
|
*/ |
4 |
|
|
|
5 |
|
|
#include <dynamic-graph/entity.h> |
6 |
|
|
#include <dynamic-graph/linear-algebra.h> |
7 |
|
|
#include <dynamic-graph/signal-ptr.h> |
8 |
|
|
#include <dynamic-graph/signal-time-dependent.h> |
9 |
|
|
|
10 |
|
|
#include <sot/core/matrix-geometry.hh> |
11 |
|
|
|
12 |
|
|
namespace dynamicgraph { |
13 |
|
|
/// Create a constraint to take into account: |
14 |
|
|
/// - the holonomic system: the base velocity, expressed in the base frame, |
15 |
|
|
/// is of the form ( v_lin, 0, 0, 0, 0, w_ang) |
16 |
|
|
/// - the relation between the wheels velocity and the base velocity. |
17 |
|
|
/// |
18 |
|
|
/// At the moment, only two wheels are considered. |
19 |
|
|
/// |
20 |
|
|
/// The signal projectionSOUT should be plugged into SoT.proj0. The signal |
21 |
|
|
/// value is a matrix K such that \f$ \dot{q} = K * u \f$ |
22 |
|
|
/// where: |
23 |
|
|
/// - \f$ \dot{q} \in \mathcal{se}(3)\times\mathcal{R}^n \f$ is the velocity |
24 |
|
|
/// of the underactuated robot, |
25 |
|
|
/// - \f$ u \in \mathcal{R}^2 \times \mathcal{R}^{n-2} \f$ is the velocity of |
26 |
|
|
/// the actuated robot, the two first being the linear and angular velocity. |
27 |
|
|
class HolonomicProjection : public Entity { |
28 |
|
|
public: |
29 |
|
|
DYNAMIC_GRAPH_ENTITY_DECL(); |
30 |
|
|
|
31 |
|
|
HolonomicProjection(const std::string& name); |
32 |
|
|
|
33 |
|
|
/// Header documentation of the python class |
34 |
|
|
virtual std::string getDocString() const { |
35 |
|
|
return "Compute the projection matrix for a wheeled platform."; |
36 |
|
|
} |
37 |
|
|
|
38 |
|
|
void setSize(int nv) { nv_ = nv; } |
39 |
|
|
|
40 |
|
|
private: |
41 |
|
|
/// Compute the projection matrix |
42 |
|
|
/// \return proj a matrix of size nv_ * (nv_ - 4) |
43 |
|
|
Matrix& computeProjection(Matrix& proj, const int& time); |
44 |
|
|
|
45 |
|
|
/// Number of DoF of the robot |
46 |
|
|
int nv_; |
47 |
|
|
SignalPtr<sot::MatrixHomogeneous, int> basePoseSIN; |
48 |
|
|
|
49 |
|
|
/// The index of the wheels DoF. |
50 |
|
|
int leftWheelIdx_, rightWheelIdx_; |
51 |
|
|
|
52 |
|
|
/// Wheel separation, wrt the midpoint of the wheel width: |
53 |
|
|
double wheelSeparation_; |
54 |
|
|
|
55 |
|
|
/// Wheel radius (assuming it's the same for the left and right wheels): |
56 |
|
|
double wheelRadius_; |
57 |
|
|
|
58 |
|
|
/// Calibration of the wheels separation and radii. |
59 |
|
|
SignalPtr<double, int> wheelSeparationMultiplierSIN, |
60 |
|
|
leftWheelRadiusMultiplierSIN, rightWheelRadiusMultiplierSIN; |
61 |
|
|
|
62 |
|
|
SignalTimeDependent<Matrix, int> projectionSOUT; |
63 |
|
|
}; |
64 |
|
|
|
65 |
|
|
} // namespace dynamicgraph |