5#include <Eigen/Geometry>
10namespace tinyrobotics {
17 template <
typename Scalar,
int nq>
21 Eigen::Matrix<Scalar, nq, 1>
q;
24 Eigen::Matrix<Scalar, nq, 1>
dq;
27 Eigen::Matrix<Scalar, nq, 1>
ddq;
30 Eigen::Matrix<Scalar, nq, 1>
tau;
33 Eigen::Matrix<Scalar, nq, nq>
mass_matrix = Eigen::Matrix<Scalar, nq, nq>::Zero();
36 Eigen::Matrix<Scalar, nq, nq>
inv_mass_matrix = Eigen::Matrix<Scalar, nq, nq>::Zero();
39 Eigen::Matrix<Scalar, nq, nq>
coriolis = Eigen::Matrix<Scalar, nq, nq>::Zero();
45 Eigen::Matrix<Scalar, nq, nq>
input_mapping = Eigen::Matrix<Scalar, nq, nq>::Identity();
48 Eigen::Matrix<Scalar, nq, nq>
damping = Eigen::Matrix<Scalar, nq, nq>::Zero();
66 std::vector<Eigen::Matrix<Scalar, 6, 6>>
Xup =
67 std::vector<Eigen::Matrix<Scalar, 6, 6>>(nq, Eigen::Matrix<Scalar, 6, 6>::Zero());
70 std::vector<Eigen::Matrix<Scalar, 6, 1>>
S =
71 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
74 std::vector<Eigen::Matrix<Scalar, 6, 1>>
v =
75 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
78 std::vector<Eigen::Matrix<Scalar, 6, 1>>
c =
79 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
82 std::vector<Eigen::Matrix<Scalar, 6, 6>>
IA =
83 std::vector<Eigen::Matrix<Scalar, 6, 6>>(nq, Eigen::Matrix<Scalar, 6, 6>::Zero());
86 std::vector<Eigen::Matrix<Scalar, 6, 1>>
pA =
87 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
90 std::vector<Eigen::Matrix<Scalar, 6, 1>>
U =
91 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
94 std::vector<Scalar>
d = std::vector<Scalar>(nq, 0);
97 std::vector<Scalar>
u = std::vector<Scalar>(nq, 0);
100 std::vector<Eigen::Matrix<Scalar, 6, 1>>
a =
101 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
104 Eigen::Transform<Scalar, 3, Eigen::Isometry>
T = Eigen::Transform<Scalar, 3, Eigen::Isometry>::Identity();
107 std::vector<Eigen::Matrix<Scalar, 6, 1>> avp =
108 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
111 std::vector<Eigen::Matrix<Scalar, 6, 1>> fvp =
112 std::vector<Eigen::Matrix<Scalar, 6, 1>>(nq, Eigen::Matrix<Scalar, 6, 1>::Zero());
115 Eigen::Matrix<Scalar, nq, 1> C = Eigen::Matrix<Scalar, nq, 1>::Zero();
118 Eigen::Matrix<Scalar, 6, 1> fh = Eigen::Matrix<Scalar, 6, 1>::Zero();
121 std::vector<Eigen::Matrix<Scalar, 6, 6>> IC =
122 std::vector<Eigen::Matrix<Scalar, 6, 6>>(nq, Eigen::Matrix<Scalar, 6, 6>::Zero());
128 Eigen::Matrix<Scalar, 6, nq>
J = Eigen::Matrix<Scalar, 6, nq>::Zero();
135 template <
typename NewScalar>
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>();
151 new_res.C = C.template cast<NewScalar>();
152 new_res.fh = fh.template cast<NewScalar>();
154 new_res.
J =
J.template cast<NewScalar>();
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>();
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