tinyrobotics
Loading...
Searching...
No Matches
data.hpp
Go to the documentation of this file.
1#ifndef TR_DATA_HPP
2#define TR_DATA_HPP
3
4#include <Eigen/Core>
5#include <Eigen/Geometry>
6
10namespace tinyrobotics {
11
17 template <typename Scalar, int nq>
18 struct Data {
19
21 Eigen::Matrix<Scalar, nq, 1> q;
22
24 Eigen::Matrix<Scalar, nq, 1> dq;
25
27 Eigen::Matrix<Scalar, nq, 1> ddq;
28
30 Eigen::Matrix<Scalar, nq, 1> tau;
31
33 Eigen::Matrix<Scalar, nq, nq> mass_matrix = Eigen::Matrix<Scalar, nq, nq>::Zero();
34
36 Eigen::Matrix<Scalar, nq, nq> inv_mass_matrix = Eigen::Matrix<Scalar, nq, nq>::Zero();
37
39 Eigen::Matrix<Scalar, nq, nq> coriolis = Eigen::Matrix<Scalar, nq, nq>::Zero();
40
42 Eigen::Matrix<Scalar, nq, 1> gravity;
43
45 Eigen::Matrix<Scalar, nq, nq> input_mapping = Eigen::Matrix<Scalar, nq, nq>::Identity();
46
48 Eigen::Matrix<Scalar, nq, nq> damping = Eigen::Matrix<Scalar, nq, nq>::Zero();
49
51 Scalar kinetic_energy = 0;
52
54 Scalar potential_energy = 0;
55
57 Scalar total_energy = 0;
58
60 std::vector<Eigen::Transform<Scalar, 3, Eigen::Isometry>> forward_kinematics = {};
61
63 std::vector<Eigen::Transform<Scalar, 3, Eigen::Isometry>> forward_kinematics_com = {};
64
66 std::vector<Eigen::Matrix<Scalar, 6, 6>> Xup =
67 std::vector<Eigen::Matrix<Scalar, 6, 6>>(nq, Eigen::Matrix<Scalar, 6, 6>::Zero());
68
70 std::vector<Eigen::Matrix<Scalar, 6, 1>> S =
71 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
72
74 std::vector<Eigen::Matrix<Scalar, 6, 1>> v =
75 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
76
78 std::vector<Eigen::Matrix<Scalar, 6, 1>> c =
79 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
80
82 std::vector<Eigen::Matrix<Scalar, 6, 6>> IA =
83 std::vector<Eigen::Matrix<Scalar, 6, 6>>(nq, Eigen::Matrix<Scalar, 6, 6>::Zero());
84
86 std::vector<Eigen::Matrix<Scalar, 6, 1>> pA =
87 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
88
90 std::vector<Eigen::Matrix<Scalar, 6, 1>> U =
91 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
92
94 std::vector<Scalar> d = std::vector<Scalar>(nq, 0);
95
97 std::vector<Scalar> u = std::vector<Scalar>(nq, 0);
98
100 std::vector<Eigen::Matrix<Scalar, 6, 1>> a =
101 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
102
104 Eigen::Transform<Scalar, 3, Eigen::Isometry> T = Eigen::Transform<Scalar, 3, Eigen::Isometry>::Identity();
105
107 std::vector<Eigen::Matrix<Scalar, 6, 1>> avp =
108 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
109
111 std::vector<Eigen::Matrix<Scalar, 6, 1>> fvp =
112 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
113
115 Eigen::Matrix<Scalar, nq, 1> C = Eigen::Matrix<Scalar, nq, 1>::Zero();
116
118 Eigen::Matrix<Scalar, 6, 1> fh = Eigen::Matrix<Scalar, 6, 1>::Zero();
119
121 std::vector<Eigen::Matrix<Scalar, 6, 6>> IC =
122 std::vector<Eigen::Matrix<Scalar, 6, 6>>(nq, Eigen::Matrix<Scalar, 6, 6>::Zero());
123
125 Eigen::Matrix<Scalar, 6, 1> spatial_gravity = Eigen::Matrix<Scalar, 6, 1>::Zero();
126
128 Eigen::Matrix<Scalar, 6, nq> J = Eigen::Matrix<Scalar, 6, nq>::Zero();
129
135 template <typename NewScalar>
137 Data<NewScalar, nq> new_res;
138 new_res.q = q.template cast<NewScalar>();
139 new_res.dq = dq.template cast<NewScalar>();
140 new_res.ddq = ddq.template cast<NewScalar>();
141 new_res.tau = tau.template cast<NewScalar>();
142 new_res.mass_matrix = mass_matrix.template cast<NewScalar>();
143 new_res.inv_mass_matrix = inv_mass_matrix.template cast<NewScalar>();
144 new_res.coriolis = coriolis.template cast<NewScalar>();
145 new_res.gravity = gravity.template cast<NewScalar>();
146 new_res.input_mapping = input_mapping.template cast<NewScalar>();
147 new_res.damping = damping.template cast<NewScalar>();
148 new_res.kinetic_energy = NewScalar(kinetic_energy);
149 new_res.potential_energy = NewScalar(potential_energy);
150 new_res.total_energy = NewScalar(total_energy);
151 new_res.C = C.template cast<NewScalar>();
152 new_res.fh = fh.template cast<NewScalar>();
153 new_res.spatial_gravity = spatial_gravity.template cast<NewScalar>();
154 new_res.J = J.template cast<NewScalar>();
155 new_res.forward_kinematics.resize(forward_kinematics.size());
156 for (int i = 0; i < forward_kinematics.size(); i++) {
157
158 new_res.forward_kinematics[i] = forward_kinematics[i].template cast<NewScalar>();
159 }
160 for (int i = 0; i < Xup.size(); i++) {
161 new_res.Xup[i] = Xup[i].template cast<NewScalar>();
162 new_res.S[i] = S[i].template cast<NewScalar>();
163 new_res.v[i] = v[i].template cast<NewScalar>();
164 new_res.c[i] = c[i].template cast<NewScalar>();
165 new_res.IA[i] = IA[i].template cast<NewScalar>();
166 new_res.pA[i] = pA[i].template cast<NewScalar>();
167 new_res.U[i] = U[i].template cast<NewScalar>();
168 new_res.d[i] = NewScalar(d[i]);
169 new_res.u[i] = NewScalar(u[i]);
170 new_res.a[i] = a[i].template cast<NewScalar>();
171 new_res.avp[i] = avp[i].template cast<NewScalar>();
172 new_res.fvp[i] = fvp[i].template cast<NewScalar>();
173 new_res.IC[i] = IC[i].template cast<NewScalar>();
174 }
175 return new_res;
176 }
177 };
178} // namespace tinyrobotics
179
180#endif
A data struct for storing results of various model algorithms.
Definition: data.hpp:18
Eigen::Matrix< Scalar, nq, 1 > ddq
Joint acceleration.
Definition: data.hpp:27
Eigen::Matrix< Scalar, nq, 1 > tau
Joint torque/force.
Definition: data.hpp:30
Eigen::Matrix< Scalar, nq, nq > input_mapping
Input mapping matrix.
Definition: data.hpp:45
Scalar total_energy
Total_energy.
Definition: data.hpp:57
Eigen::Transform< Scalar, 3, Eigen::Isometry > T
Homogeneous transformation matrix.
Definition: data.hpp:104
std::vector< Eigen::Matrix< Scalar, 6, 6 > > Xup
Spatial transforms from parent to child links.
Definition: data.hpp:66
Eigen::Matrix< Scalar, nq, 1 > q
Joint configuration.
Definition: data.hpp:21
Eigen::Matrix< Scalar, nq, nq > coriolis
Coriolis matrix.
Definition: data.hpp:39
std::vector< Scalar > u
Joint force bias terms for the robot links.
Definition: data.hpp:97
std::vector< Eigen::Matrix< Scalar, 6, 1 > > a
Spatial accelerations of the robot links.
Definition: data.hpp:100
Eigen::Matrix< Scalar, nq, nq > damping
Damping matrix.
Definition: data.hpp:48
Eigen::Matrix< Scalar, nq, 1 > gravity
Gravity vector.
Definition: data.hpp:42
Eigen::Matrix< Scalar, nq, nq > inv_mass_matrix
Inverse mass matrix.
Definition: data.hpp:36
std::vector< Eigen::Transform< Scalar, 3, Eigen::Isometry > > forward_kinematics
Vector of forward kinematics Data.
Definition: data.hpp:60
std::vector< Scalar > d
Joint force inertia terms for the robot links.
Definition: data.hpp:94
Eigen::Matrix< Scalar, 6, 1 > spatial_gravity
Gravity vector in spatial coordinates.
Definition: data.hpp:125
std::vector< Eigen::Matrix< Scalar, 6, 1 > > pA
Articulated-body forces for the robot links.
Definition: data.hpp:86
Scalar potential_energy
Potential energy.
Definition: data.hpp:54
std::vector< Eigen::Matrix< Scalar, 6, 6 > > IA
Articulated-body inertia matrices for the robot links.
Definition: data.hpp:82
Eigen::Matrix< Scalar, nq, 1 > dq
Joint velocity.
Definition: data.hpp:24
Data< NewScalar, nq > cast()
Casts the data to a new scalar type.
Definition: data.hpp:136
std::vector< Eigen::Matrix< Scalar, 6, 1 > > c
Spatial acceleration bias terms for the robot links.
Definition: data.hpp:78
std::vector< Eigen::Matrix< Scalar, 6, 1 > > U
Spatial force projections for the joints.
Definition: data.hpp:90
Scalar kinetic_energy
Kinetic energy.
Definition: data.hpp:51
std::vector< Eigen::Matrix< Scalar, 6, 1 > > v
Spatial velocities of the robot links.
Definition: data.hpp:74
Eigen::Matrix< Scalar, nq, nq > mass_matrix
Mass matrix.
Definition: data.hpp:33
std::vector< Eigen::Transform< Scalar, 3, Eigen::Isometry > > forward_kinematics_com
Vector of forward kinematics com Data.
Definition: data.hpp:63
Eigen::Matrix< Scalar, 6, nq > J
Geometric Jacobian.
Definition: data.hpp:128
std::vector< Eigen::Matrix< Scalar, 6, 1 > > S
Motion subspace matrices for the joints.
Definition: data.hpp:70