1 #include <gtest/gtest.h> 42 Joint(
SpatialVector(0., 0., 0., 1., 0., 0.),
SpatialVector(0., 0., 0., 0., 1., 0.),
SpatialVector(0., 0., 0., 0., 0., 1.),
43 SpatialVector(0., 0., 1., 0., 0., 0.),
SpatialVector(0., 1., 0., 0., 0., 0.),
SpatialVector(1., 0., 0., 0., 0., 0.)),
47 VectorNd Q = VectorNd::Constant((
size_t)model->dof_count, 0.);
48 VectorNd QDot = VectorNd::Constant((
size_t)model->dof_count, 0.);
49 VectorNd QDDot = VectorNd::Constant((
size_t)model->dof_count, 0.);
50 VectorNd Tau = VectorNd::Constant((
size_t)model->dof_count, 0.);
51 VectorNd TauInv = VectorNd::Constant((
size_t)model->dof_count, 0.);
85 Joint(
SpatialVector(0., 0., 0., 1., 0., 0.),
SpatialVector(0., 0., 0., 0., 1., 0.),
SpatialVector(0., 0., 0., 0., 0., 1.),
86 SpatialVector(0., 0., 1., 0., 0., 0.),
SpatialVector(0., 1., 0., 0., 0., 0.),
SpatialVector(1., 0., 0., 0., 0., 0.)),
90 VectorNd Q = VectorNd::Constant((
size_t)model->dof_count, 0.);
91 VectorNd QDot = VectorNd::Constant((
size_t)model->dof_count, 0.);
92 VectorNd QDDot = VectorNd::Constant((
size_t)model->dof_count, 0.);
93 VectorNd Tau = VectorNd::Constant((
size_t)model->dof_count, 0.);
94 VectorNd TauInv = VectorNd::Constant((
size_t)model->dof_count, 0.);
128 MatrixNd M(model_emulated->qdot_size, model_emulated->qdot_size);
129 VectorNd N(model_emulated->qdot_size);
133 unsigned int foot_r_id = model_emulated->GetBodyId(
"foot_r");
134 SpatialForce F(model_emulated->bodyFrames[foot_r_id], -1., 2., 3.1, 82., -23., 500.1);
136 MatrixNd J_r_foot(6, model_emulated->qdot_size);
144 VectorNd tau_cf(model_emulated->qdot_size), tau_id(model_emulated->qdot_size);
147 tau_cf = M * qddot + N - J_r_foot.transpose() * F;
149 std::shared_ptr<Math::SpatialForceV> f_ext(
new Math::SpatialForceV(model_emulated->mBodies.size()));
151 for (
int i = 0; i < model_emulated->mBodies.size(); i++)
153 (*f_ext)[i].setIncludingFrame(model_emulated->bodyFrames[i], 0., 0., 0., 0., 0., 0.);
156 (*f_ext)[i].fx() = F.
fx();
157 (*f_ext)[i].fy() = F.
fy();
158 (*f_ext)[i].fz() = F.
fz();
159 (*f_ext)[i].mx() = F.
mx();
160 (*f_ext)[i].my() = F.
my();
161 (*f_ext)[i].mz() = F.
mz();
170 TEST_F(
Human36, TestInverseForwardDynamicsFloatingBaseExternalForcesNoKinematics)
174 MatrixNd M(model_emulated->qdot_size, model_emulated->qdot_size);
175 VectorNd N(model_emulated->qdot_size);
179 unsigned int foot_r_id = model_emulated->GetBodyId(
"foot_r");
180 SpatialForce F(model_emulated->bodyFrames[foot_r_id], -1., 2., 3.1, 82., -23., 500.1);
182 MatrixNd J_r_foot(6, model_emulated->qdot_size);
190 VectorNd tau_cf(model_emulated->qdot_size), tau_id(model_emulated->qdot_size);
193 tau_cf = M * qddot + N - J_r_foot.transpose() * F;
195 std::shared_ptr<Math::SpatialForceV> f_ext(
new Math::SpatialForceV(model_emulated->mBodies.size()));
197 for (
int i = 0; i < model_emulated->mBodies.size(); i++)
199 (*f_ext)[i].setIncludingFrame(model_emulated->bodyFrames[i], 0., 0., 0., 0., 0., 0.);
202 (*f_ext)[i].fx() = F.
fx();
203 (*f_ext)[i].fy() = F.
fy();
204 (*f_ext)[i].fz() = F.
fz();
205 (*f_ext)[i].mx() = F.
mx();
206 (*f_ext)[i].my() = F.
my();
207 (*f_ext)[i].mz() = F.
mz();
211 inverseDynamics(*model_emulated, q, qdot, qddot, tau_id, f_ext.get(),
false);
216 int main(
int argc,
char** argv)
218 ::testing::InitGoogleTest(&argc, argv);
219 return RUN_ALL_TESTS();
static bool checkVectorNdEpsilonClose(const RobotDynamics::Math::VectorNd &v1, const RobotDynamics::Math::VectorNd &v2, const double epsilon)
void compositeRigidBodyAlgorithm(Model &model, const Math::VectorNd &Q, Math::MatrixNd &H, bool update_kinematics=true)
Computes the joint space inertia matrix by using the Composite Rigid Body Algorithm.
std::vector< SpatialForce, Eigen::aligned_allocator< SpatialForce > > SpatialForceV
Describes all properties of a single body.
RbdlimInverseDynamicsFixture()
bool checkModelZeroVectorsAndMatrices(RobotDynamics::Model &model)
EIGEN_STRONG_INLINE double & fy()
Get reference to y-linear component.
Math::MotionVector gravity
the cartesian vector of the gravity
int main(int argc, char **argv)
EIGEN_STRONG_INLINE double & fx()
Get reference to x-linear component.
EIGEN_STRONG_INLINE double & fz()
Get reference to z-linear component.
EIGEN_STRONG_INLINE double & my()
Get reference to y-angular component.
Describes a joint relative to the predecessor body.
EIGEN_STRONG_INLINE double & mz()
Get reference to z-angular component.
void calcBodySpatialJacobian(Model &model, const Math::VectorNd &Q, unsigned int body_id, Math::MatrixNd &G, bool update_kinematics=true)
Computes the spatial jacobian for a body. The result will be returned via the G argument and represen...
void updateKinematics(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &QDDot)
Updates and computes velocities and accelerations of the bodies.
Contains all information about the rigid body model.
void updateKinematicsCustom(Model &model, const Math::VectorNd *Q, const Math::VectorNd *QDot=nullptr, const Math::VectorNd *QDDot=nullptr)
Selectively updates model internal states of body positions, velocities and/or accelerations.
Math types such as vectors and matrices and utility functions.
A SpatialForce is a spatial vector with the angular part being three moments and the linear part bein...
EIGEN_STRONG_INLINE double & mx()
Get reference to x-angular component.
TEST_F(RbdlimInverseDynamicsFixture, TestInverseForwardDynamicsFloatingBase)
void inverseDynamics(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &QDDot, Math::VectorNd &Tau, Math::SpatialForceV *f_ext=nullptr, bool update_kinematics=true)
void forwardDynamics(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &Tau, Math::VectorNd &QDDot, Math::SpatialForceV *f_ext=nullptr, bool update_kinematics=true)
Computes forward dynamics with the Articulated Body Algorithm.
void nonlinearEffects(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, Math::VectorNd &Tau, bool update_kinematics=true)
Computes the coriolis forces.
Namespace for all structures of the RobotDynamics library.