1 #include <gtest/gtest.h> 16 for (
unsigned int i = 0; i < model->q_size; i++)
18 Q[i] =
static_cast<double>(i + 1) * 0.1;
21 MatrixNd H(MatrixNd::Zero(model->qdot_size, model->qdot_size));
34 for (
unsigned int i = 0; i < model->q_size; i++)
36 Q[i] =
static_cast<double>(i + 1) * 0.1;
39 MatrixNd H(MatrixNd::Zero(model->qdot_size, model->qdot_size));
54 for (
unsigned int i = 0; i < model->q_size; i++)
56 Q[i] =
static_cast<double>(i + 1) * 0.1;
59 MatrixNd H(MatrixNd::Zero(model->qdot_size, model->qdot_size));
77 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(0., 1., 0.));
78 constraint_set.addConstraint(child_2_id, contact_point,
Vector3d(0., 1., 0.));
80 constraint_set_var1 = constraint_set.
Copy();
81 constraint_set_var1.
bind(*model);
82 constraint_set.bind(*model);
84 VectorNd QDDot_var1 = VectorNd::Constant(model->dof_count, 0.);
115 Model model_emulated;
118 Body body(1.,
Vector3d(1., 2., 1.),
Matrix3d(1., 0., 0, 0., 1., 0., 0., 0., 1.));
119 Joint joint_emulated(
SpatialVector(0., 1., 0., 0., 0., 0.),
SpatialVector(1., 0., 0., 0., 0., 0.),
SpatialVector(0., 0., 1., 0., 0., 0.));
125 unsigned int multdof_body_id_emulated = model_emulated.
appendBody(
SpatialTransform(Matrix3d::Identity(), Vector3d::Zero()), joint_emulated, body);
127 model_emulated.
addBody(multdof_body_id_emulated,
SpatialTransform(Matrix3d::Identity(), Vector3d::Zero()), joint_rot_y, body);
131 unsigned int multdof_body_id_3dof = model_3dof.
appendBody(
SpatialTransform(Matrix3d::Identity(), Vector3d::Zero()), joint_3dof, body);
133 model_3dof.
addBody(multdof_body_id_3dof,
SpatialTransform(Matrix3d::Identity(), Vector3d::Zero()), joint_rot_y, body);
142 for (
int i = 0; i < q.size(); i++)
144 q[i] = 1.1 * (
static_cast<double>(i + 1));
145 qdot[i] = 0.55 * (
static_cast<double>(i + 1));
146 qddot_emulated[i] = 0.23 * (
static_cast<double>(i + 1));
147 qddot_3dof[i] = 0.22 * (
static_cast<double>(i + 1));
148 tau[i] = 2.1 * (
static_cast<double>(i + 1));
151 MatrixNd H_emulated(MatrixNd::Zero(q.size(), q.size()));
152 MatrixNd H_3dof(MatrixNd::Zero(q.size(), q.size()));
157 VectorNd b(VectorNd::Zero(q.size()));
158 VectorNd x_emulated(VectorNd::Zero(q.size()));
159 VectorNd x_3dof(VectorNd::Zero(q.size()));
161 for (
unsigned int i = 0; i < b.size(); i++)
163 b[i] =
static_cast<double>(i + 1) * 2.152;
189 Model model_emulated;
192 Body body(1.,
Vector3d(1., 2., 1.),
Matrix3d(1., 0., 0, 0., 1., 0., 0., 0., 1.));
193 Joint joint_emulated(
SpatialVector(0., 1., 0., 0., 0., 0.),
SpatialVector(1., 0., 0., 0., 0., 0.),
SpatialVector(0., 0., 1., 0., 0., 0.));
201 unsigned int multdof_body_id_emulated = model_emulated.
appendBody(translate_x, joint_emulated, body);
202 model_emulated.
appendBody(translate_x, joint_emulated, body);
204 model_emulated.
appendBody(translate_x, joint_emulated, body);
207 unsigned int multdof_body_id_3dof = model_3dof.
appendBody(translate_x, joint_3dof, body);
208 model_3dof.
appendBody(translate_x, joint_3dof, body);
210 model_3dof.
appendBody(translate_x, joint_3dof, body);
218 for (
int i = 0; i < q.size(); i++)
220 q[i] = 1.1 * (
static_cast<double>(i + 1));
221 qdot[i] = 0.55 * (
static_cast<double>(i + 1));
222 qddot_emulated[i] = 0.23 * (
static_cast<double>(i + 1));
223 qddot_3dof[i] = 0.22 * (
static_cast<double>(i + 1));
224 tau[i] = 2.1 * (
static_cast<double>(i + 1));
227 MatrixNd H_emulated(MatrixNd::Zero(q.size(), q.size()));
228 MatrixNd H_3dof(MatrixNd::Zero(q.size(), q.size()));
233 VectorNd b(VectorNd::Zero(q.size()));
234 VectorNd x_emulated(VectorNd::Zero(q.size()));
235 VectorNd x_3dof(VectorNd::Zero(q.size()));
237 for (
unsigned int i = 0; i < b.size(); i++)
239 b[i] =
static_cast<double>(i + 1) * 2.152;
263 int main(
int argc,
char** argv)
265 ::testing::InitGoogleTest(&argc, argv);
266 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.
Describes all properties of a single body.
int main(int argc, char **argv)
ConstraintSet Copy()
Copies the constraints and resets its ConstraintSet::bound flag.
Fixed joint which causes the inertial properties to be merged with.
unsigned int addConstraint(unsigned int body_id, const Math::Vector3d &body_point, const Math::Vector3d &world_normal, const char *constraint_name=NULL, double normal_acceleration=0.)
Adds a constraint to the constraint set.
unsigned int appendBody(const Math::SpatialTransform &joint_frame, const Joint &joint, const Body &body, std::string body_name="")
Adds a Body to the model such that the previously added Body is the Parent.
unsigned int addBody(const unsigned int parent_id, const Math::SpatialTransform &joint_frame, const Joint &joint, const Body &body, std::string body_name="")
Connects a given body to the model.
unsigned int q_size
The size of the -vector. For models without spherical joints the value is the same as Model::dof_coun...
Structure that contains both constraint information and workspace memory.
TEST_F(FloatingBase12DoF, TestSparseFactorizationLTL)
Describes a joint relative to the predecessor body.
static bool checkMatrixNdEpsilonClose(const RobotDynamics::Math::MatrixNd &t1, const RobotDynamics::Math::MatrixNd &t2, const double epsilon)
Contains all information about the rigid body model.
bool bind(const Model &model)
Initializes and allocates memory for the constraint set.
Math types such as vectors and matrices and utility functions.
void SparseFactorizeLTL(Model &model, Math::MatrixNd &H)
void SparseSolveLTx(Model &model, Math::MatrixNd &L, Math::VectorNd &x)
void SparseSolveLx(Model &model, Math::MatrixNd &L, Math::VectorNd &x)
Namespace for all structures of the RobotDynamics library.
unsigned int qdot_size
The size of the.
3 DoF joint that uses Euler YXZ convention (faster than emulated