7 #include <gtest/gtest.h> 68 S = MatrixNd::Zero(6, 1);
70 S_o = MatrixNd::Zero(6, 1);
71 d_u = MatrixNd::Zero(mDoFCount, 1);
77 model.
v_J[joint_id][0] = qdot[model.
mJoints[joint_id].q_index];
94 S = MatrixNd::Zero(6, 3);
95 S_o = MatrixNd::Zero(6, 3);
96 d_u = MatrixNd::Zero(mDoFCount, 1);
101 double q0 = q[model.
mJoints[joint_id].q_index];
102 double q1 = q[model.
mJoints[joint_id].q_index + 1];
103 double q2 = q[model.
mJoints[joint_id].q_index + 2];
112 model.
X_J[joint_id].E =
113 Matrix3d(c0 * c1, s0 * c1, -s1, c0 * s1 * s2 - s0 * c2, s0 * s1 * s2 + c0 * c2, c1 * s2, c0 * s1 * c2 + s0 * s2, s0 * s1 * c2 - c0 * s2, c1 * c2);
125 double qdot0 = qdot[model.
mJoints[joint_id].q_index];
126 double qdot1 = qdot[model.
mJoints[joint_id].q_index + 1];
127 double qdot2 = qdot[model.
mJoints[joint_id].q_index + 2];
129 Vector3d qdotv(qdot0, qdot1, qdot2);
130 model.
v_J[joint_id].set(S * qdotv);
132 S_o(0, 0) = -c1 * qdot1;
133 S_o(1, 0) = -s1 * s2 * qdot1 + c1 * c2 * qdot2;
134 S_o(1, 1) = -s2 * qdot2;
135 S_o(2, 0) = -s1 * c2 * qdot1 - c1 * s2 * qdot2;
136 S_o(2, 1) = -c2 * qdot2;
138 model.
c_J[joint_id] = S_o * qdotv;
143 double q0 = q[model.
mJoints[joint_id].q_index];
144 double q1 = q[model.
mJoints[joint_id].q_index + 1];
145 double q2 = q[model.
mJoints[joint_id].q_index + 2];
155 Matrix3d(c0 * c1, s0 * c1, -s1, c0 * s1 * s2 - s0 * c2, s0 * s1 * s2 + c0 * c2, c1 * s2, c0 * s1 * c2 + s0 * s2, s0 * s1 * c2 - c0 * s2, c1 * c2),
196 body.at(i).resize(3);
197 custom_joint.at(i).resize(1);
199 reference_body_id.at(i).resize(3);
200 custom_body_id.at(i).resize(3);
203 q.resize(NUMBER_OF_MODELS);
204 qdot.resize(NUMBER_OF_MODELS);
205 qddot.resize(NUMBER_OF_MODELS);
206 tau.resize(NUMBER_OF_MODELS);
214 Matrix3d inertia1 = Matrix3d::Identity(3, 3);
224 double th1 = M_PI / 6.0;
225 double sinTh1 = sin(th1);
226 double cosTh1 = cos(th1);
228 Matrix3d rm1 =
Matrix3d(1.0, 0., 0., 0., cosTh1, -sinTh1, 0., sinTh1, cosTh1);
232 double th2 = M_PI / 2.15;
233 double sinTh2 = sin(th2);
234 double cosTh2 = cos(th2);
236 Matrix3d rm2 =
Matrix3d(cosTh2, 0., sinTh2, 0., 1., 0., -sinTh2, 0., cosTh2);
248 unsigned int custom_body_id12 = custom1->addBodyCustomJoint(custom_body_id11,
SpatialTransform(rm2, r2), &custom_rx_joint1, body13);
250 VectorNd q1 = VectorNd::Zero(reference1->q_size);
251 VectorNd qdot1 = VectorNd::Zero(reference1->qdot_size);
252 VectorNd qddot1 = VectorNd::Zero(reference1->qdot_size);
253 VectorNd tau1 = VectorNd::Zero(reference1->qdot_size);
256 reference_model.at(idx) = (reference1);
257 custom_model.at(idx) = (custom1);
259 reference_body_id.at(idx).at(0) = (reference_body_id10);
260 reference_body_id.at(idx).at(1) = (reference_body_id11);
261 reference_body_id.at(idx).at(2) = (reference_body_id12);
263 custom_body_id.at(idx).at(0) = (custom_body_id10);
264 custom_body_id.at(idx).at(1) = (custom_body_id11);
265 custom_body_id.at(idx).at(2) = (custom_body_id12);
267 body.at(idx).at(0) = (body11);
268 body.at(idx).at(1) = (body12);
269 body.at(idx).at(2) = (body13);
270 custom_joint.at(idx).at(0) = (&custom_rx_joint1);
273 qdot.at(idx) = (qdot1);
274 qddot.at(idx) = (qddot1);
275 tau.at(idx) = (tau1);
291 unsigned int custom_body_id21 = custom2->addBodyCustomJoint(custom_body_id20,
SpatialTransform(rm2, r2), &custom_rx_joint1, body12);
295 VectorNd q2 = VectorNd::Zero(reference2->q_size);
296 VectorNd qdot2 = VectorNd::Zero(reference2->qdot_size);
297 VectorNd qddot2 = VectorNd::Zero(reference2->qdot_size);
298 VectorNd tau2 = VectorNd::Zero(reference2->qdot_size);
301 reference_model.at(idx) = (reference2);
302 custom_model.at(idx) = (custom2);
304 reference_body_id.at(idx).at(0) = (reference_body_id20);
305 reference_body_id.at(idx).at(1) = (reference_body_id21);
306 reference_body_id.at(idx).at(2) = (reference_body_id22);
308 custom_body_id.at(idx).at(0) = (custom_body_id20);
309 custom_body_id.at(idx).at(1) = (custom_body_id21);
310 custom_body_id.at(idx).at(2) = (custom_body_id22);
312 body.at(idx).at(0) = (body11);
313 body.at(idx).at(1) = (body12);
314 body.at(idx).at(2) = (body13);
315 custom_joint.at(idx).at(0) = (&custom_rx_joint1);
318 qdot.at(idx) = (qdot2);
319 qddot.at(idx) = (qddot2);
320 tau.at(idx) = (tau2);
334 unsigned int custom_body_id30 = custom3->addBodyCustomJoint(0,
SpatialTransform(), &custom_rx_joint1, body11);
340 VectorNd q3 = VectorNd::Zero(reference3->q_size);
341 VectorNd qdot3 = VectorNd::Zero(reference3->qdot_size);
342 VectorNd qddot3 = VectorNd::Zero(reference3->qdot_size);
343 VectorNd tau3 = VectorNd::Zero(reference3->qdot_size);
346 reference_model.at(idx) = (reference3);
347 custom_model.at(idx) = (custom3);
349 reference_body_id.at(idx).at(0) = (reference_body_id30);
350 reference_body_id.at(idx).at(1) = (reference_body_id31);
351 reference_body_id.at(idx).at(2) = (reference_body_id32);
353 custom_body_id.at(idx).at(0) = (custom_body_id30);
354 custom_body_id.at(idx).at(1) = (custom_body_id31);
355 custom_body_id.at(idx).at(2) = (custom_body_id32);
357 body.at(idx).at(0) = (body11);
358 body.at(idx).at(1) = (body12);
359 body.at(idx).at(2) = (body13);
360 custom_joint.at(idx).at(0) = (&custom_rx_joint1);
363 qdot.at(idx) = (qdot3);
364 qddot.at(idx) = (qddot3);
365 tau.at(idx) = (tau3);
370 for (
unsigned int i = 0; i < reference_model.size(); i++)
375 for (
unsigned int i = 0; i < custom_model.size(); i++)
419 int dof = reference_model.at(idx)->dof_count;
420 for (
unsigned int i = 0; i < dof; i++)
422 q.at(idx)[i] = i * 0.1;
423 qdot.at(idx)[i] = i * 0.15;
424 qddot.at(idx)[i] = i * 0.17;
427 updateKinematics(*reference_model.at(idx), q.at(idx), qdot.at(idx), qddot.at(idx));
428 updateKinematics(*custom_model.at(idx), q.at(idx), qdot.at(idx), qddot.at(idx));
431 reference_model.at(idx)->bodyFrames[reference_body_id.at(idx).at(
NUMBER_OF_BODIES - 1)]->getTransformToRoot().E,
434 reference_model.at(idx)->bodyFrames[reference_body_id.at(idx).at(
NUMBER_OF_BODIES - 1)]->getTransformToRoot().r,
447 int dof = reference_model.at(idx)->dof_count;
448 for (
unsigned int i = 0; i < dof; i++)
450 q.at(idx)[i] = i * 9.133758561390194e-01;
451 qdot.at(idx)[i] = i * 6.323592462254095e-01;
452 qddot.at(idx)[i] = i * 9.754040499940952e-02;
459 reference_model.at(idx)->bodyFrames[reference_body_id.at(idx).at(
NUMBER_OF_BODIES - 1)]->getTransformToRoot().E,
462 reference_model.at(idx)->bodyFrames[reference_body_id.at(idx).at(
NUMBER_OF_BODIES - 1)]->getTransformToRoot().r,
485 int dof = reference_model.at(idx)->dof_count;
487 for (
unsigned int i = 0; i < dof; i++)
489 q.at(idx)[i] = i * 9.133758561390194e-01;
490 qdot.at(idx)[i] = i * 6.323592462254095e-01;
491 qddot.at(idx)[i] = i * 9.754040499940952e-02;
495 updateKinematics(*reference_model.at(idx), q.at(idx), qdot.at(idx), qddot.at(idx));
496 updateKinematics(*custom_model.at(idx), q.at(idx), qdot.at(idx), qddot.at(idx));
499 MatrixNd Gref =
MatrixNd(MatrixNd::Zero(6, reference_model.at(idx)->dof_count));
500 MatrixNd Gcus =
MatrixNd(MatrixNd::Zero(6, reference_model.at(idx)->dof_count));
501 MatrixNd Gcus2 =
MatrixNd(MatrixNd::Zero(6, reference_model.at(idx)->dof_count));
502 MatrixNd GDotref =
MatrixNd(MatrixNd::Zero(6, reference_model.at(idx)->dof_count));
503 MatrixNd GDotcus =
MatrixNd(MatrixNd::Zero(6, reference_model.at(idx)->dof_count));
504 MatrixNd GDotcus2 =
MatrixNd(MatrixNd::Zero(6, reference_model.at(idx)->dof_count));
515 ReferenceFramePtr b1_ref_frame = reference_model.at(idx)->bodyFrames[reference_body_id.at(idx)[0]];
516 ReferenceFramePtr b2_ref_frame = reference_model.at(idx)->bodyFrames[reference_body_id.at(idx)[1]];
517 ReferenceFramePtr b3_ref_frame = reference_model.at(idx)->bodyFrames[reference_body_id.at(idx)[2]];
519 ReferenceFramePtr b1_cus_frame = custom_model.at(idx)->bodyFrames[custom_body_id.at(idx)[0]];
520 ReferenceFramePtr b2_cus_frame = custom_model.at(idx)->bodyFrames[custom_body_id.at(idx)[1]];
521 ReferenceFramePtr b3_cus_frame = custom_model.at(idx)->bodyFrames[custom_body_id.at(idx)[2]];
550 for (
int i = 0; i < 6; ++i)
552 for (
int j = 0; j < dof; ++j)
554 EXPECT_NEAR(GDotref(i, j), GDotcus(i, j),
TEST_PREC);
559 Vector3d point_position(1.1, 1.2, 2.1);
564 for (
int i = 0; i < 6; ++i)
566 for (
int j = 0; j < dof; ++j)
568 EXPECT_NEAR(Gref(i, j), Gcus(i, j),
TEST_PREC);
577 for (
int i = 0; i < 6; ++i)
579 for (
int j = 0; j < dof; ++j)
581 EXPECT_NEAR(Gref(i, j), Gcus(i, j),
TEST_PREC);
585 Gref = MatrixNd::Constant(3, reference_model.at(idx)->dof_count, 0.);
586 Gcus = MatrixNd::Constant(3, reference_model.at(idx)->dof_count, 0.);
591 for (
int i = 0; i < 3; ++i)
593 for (
int j = 0; j < dof; ++j)
595 EXPECT_NEAR(Gref(i, j), Gcus(i, j),
TEST_PREC);
600 MatrixNd GrefPt = MatrixNd::Constant(3, reference_model.at(idx)->dof_count, 0.);
601 MatrixNd GcusPt = MatrixNd::Constant(3, reference_model.at(idx)->dof_count, 0.);
603 MatrixNd GDotrefPt = MatrixNd::Constant(3, reference_model.at(idx)->dof_count, 0.);
604 MatrixNd GDotcusPt = MatrixNd::Constant(3, reference_model.at(idx)->dof_count, 0.);
609 for (
int i = 0; i < 3; ++i)
611 for (
int j = 0; j < dof; ++j)
613 EXPECT_NEAR(GrefPt(i, j), GcusPt(i, j),
TEST_PREC);
617 GrefPt = MatrixNd::Constant(6, reference_model.at(idx)->qdot_size, 0.);
618 GcusPt = MatrixNd::Constant(6, reference_model.at(idx)->qdot_size, 0.);
626 for (
int i = 0; i < 6; ++i)
628 for (
int j = 0; j < dof; ++j)
630 EXPECT_NEAR(GrefPt(i, j), GcusPt(i, j),
TEST_PREC);
634 GrefPt = MatrixNd::Constant(6, reference_model.at(idx)->qdot_size, 0.);
635 GcusPt = MatrixNd::Constant(6, reference_model.at(idx)->qdot_size, 0.);
637 frame1 = reference_model.at(idx)->bodyFrames[reference_body_id.at(idx).at(
NUMBER_OF_BODIES - 1)];
638 frame2 = custom_model.at(idx)->bodyFrames[custom_body_id.at(idx).at(
NUMBER_OF_BODIES - 1)];
643 for (
int i = 0; i < 6; ++i)
645 for (
int j = 0; j < dof; ++j)
647 EXPECT_NEAR(GrefPt(i, j), GcusPt(i, j),
TEST_PREC);
651 GrefPt = MatrixNd::Constant(3, reference_model.at(idx)->qdot_size, 0.);
652 GcusPt = MatrixNd::Constant(3, reference_model.at(idx)->qdot_size, 0.);
654 frame1 = reference_model.at(idx)->bodyFrames[reference_body_id.at(idx).at(
NUMBER_OF_BODIES - 1)];
655 frame2 = custom_model.at(idx)->bodyFrames[custom_body_id.at(idx).at(
NUMBER_OF_BODIES - 1)];
662 GrefPt = MatrixNd::Constant(3, reference_model.at(idx)->qdot_size, 0.);
663 GcusPt = MatrixNd::Constant(3, reference_model.at(idx)->qdot_size, 0.);
665 frame1 = reference_model.at(idx)->bodyFrames[reference_body_id.at(idx).at(
NUMBER_OF_BODIES - 1)];
666 frame2 = custom_model.at(idx)->bodyFrames[custom_body_id.at(idx).at(
NUMBER_OF_BODIES - 1)];
673 GrefPt = MatrixNd::Constant(6, reference_model.at(idx)->qdot_size, 0.);
674 GcusPt = MatrixNd::Constant(6, reference_model.at(idx)->qdot_size, 0.);
676 GDotrefPt = MatrixNd::Constant(6, reference_model.at(idx)->qdot_size, 0.);
677 GDotcusPt = MatrixNd::Constant(6, reference_model.at(idx)->qdot_size, 0.);
679 frame1 = reference_model.at(idx)->bodyFrames[reference_body_id.at(idx).at(
NUMBER_OF_BODIES - 1)];
681 frame2 = custom_model.at(idx)->bodyFrames[custom_body_id.at(idx).at(
NUMBER_OF_BODIES - 1)];
694 MatrixNd GcusPt2 = MatrixNd::Constant(6, custom_model.at(idx)->qdot_size, 0.);
695 MatrixNd GDotcusPt2 = MatrixNd::Constant(6, custom_model.at(idx)->qdot_size, 0.);
696 GcusPt = MatrixNd::Constant(6, custom_model.at(idx)->qdot_size, 0.);
697 GDotcusPt = MatrixNd::Constant(6, custom_model.at(idx)->qdot_size, 0.);
706 MatrixNd G_com_ref = MatrixNd::Constant(3, reference_model.at(idx)->dof_count, 0.);
707 MatrixNd G_com_cus = MatrixNd::Constant(3, reference_model.at(idx)->dof_count, 0.);
714 MatrixNd Aref = MatrixNd::Constant(6, reference_model.at(idx)->dof_count, 0.);
715 MatrixNd Acus = MatrixNd::Constant(6, reference_model.at(idx)->dof_count, 0.);
720 EXPECT_TRUE(unit_test_utils::checkMatrixNdEpsilonClose(Aref, Acus,
TEST_PREC));
728 int dof = reference_model.at(idx)->dof_count;
730 for (
unsigned int i = 0; i < dof; i++)
732 q.at(idx)[i] = i * 9.133758561390194e-01;
733 qdot.at(idx)[i] = i * 6.323592462254095e-01;
734 qddot.at(idx)[i] = i * 9.754040499940952e-02;
738 MatrixNd ADotref =
MatrixNd(MatrixNd::Zero(6, reference_model.at(idx)->qdot_size));
739 MatrixNd ADotcus =
MatrixNd(MatrixNd::Zero(6, reference_model.at(idx)->qdot_size));
752 int dof = reference_model.at(idx)->dof_count;
754 for (
unsigned int i = 0; i < dof; i++)
756 q.at(idx)[i] = i * 9.133758561390194e-01;
757 qdot.at(idx)[i] = i * 6.323592462254095e-01;
758 qddot.at(idx)[i] = i * 9.754040499940952e-02;
762 VectorNd tauRef = VectorNd::Zero(reference_model.at(idx)->qdot_size);
763 VectorNd tauCus = VectorNd::Zero(reference_model.at(idx)->qdot_size);
765 updateKinematics(*reference_model.at(idx), q.at(idx), qdot.at(idx), qddot.at(idx));
766 updateKinematics(*custom_model.at(idx), q.at(idx), qdot.at(idx), qddot.at(idx));
768 qdot.at(idx).setZero();
769 nonlinearEffects(*reference_model.at(idx), q.at(idx), qdot.at(idx), tauRef);
780 int dof = reference_model.at(idx)->dof_count;
782 for (
unsigned int i = 0; i < dof; i++)
784 q.at(idx)[i] = i * 9.133758561390194e-01;
785 qdot.at(idx)[i] = i * 6.323592462254095e-01;
786 qddot.at(idx)[i] = i * 9.754040499940952e-02;
790 VectorNd tauRef = VectorNd::Zero(reference_model.at(idx)->qdot_size);
791 VectorNd tauCus = VectorNd::Zero(reference_model.at(idx)->qdot_size);
793 inverseDynamics(*reference_model.at(idx), q.at(idx), qdot.at(idx), qddot.at(idx), tauRef);
794 inverseDynamics(*custom_model.at(idx), q.at(idx), qdot.at(idx), qddot.at(idx), tauCus);
804 for (
int idx = 0; idx < 2; ++idx)
806 int dof = reference_model.at(idx)->dof_count;
808 for (
unsigned int i = 0; i < dof; i++)
810 q.at(idx)[i] = (i + 0.1) * 9.133758561390194e-01;
811 qdot.at(idx)[i] = (i + 0.1) * 6.323592462254095e-01;
812 tau.at(idx)[i] = (i + 0.1) * 9.754040499940952e-02;
815 MatrixNd h_ref = MatrixNd::Constant(dof, dof, 0.);
816 VectorNd c_ref = VectorNd::Constant(dof, 0.);
817 VectorNd qddot_zero_ref = VectorNd::Constant(dof, 0.);
818 VectorNd qddot_crba_ref = VectorNd::Constant(dof, 0.);
820 MatrixNd h_cus = MatrixNd::Constant(dof, dof, 0.);
821 VectorNd c_cus = VectorNd::Constant(dof, 0.);
822 VectorNd qddot_zero_cus = VectorNd::Constant(dof, 0.);
823 VectorNd qddot_crba_cus = VectorNd::Constant(dof, 0.);
825 VectorNd qddotRef = VectorNd::Zero(dof);
826 VectorNd qddotCus = VectorNd::Zero(dof);
829 forwardDynamics(*reference_model.at(idx), q.at(idx), qdot.at(idx), tau.at(idx), qddotRef);
831 inverseDynamics(*reference_model.at(idx), q.at(idx), qdot.at(idx), qddot_zero_ref, c_ref);
835 forwardDynamics(*custom_model.at(idx), q.at(idx), qdot.at(idx), tau.at(idx), qddotCus);
837 inverseDynamics(*custom_model.at(idx), q.at(idx), qdot.at(idx), qddot_zero_cus, c_cus);
848 int dof = reference_model.at(idx)->dof_count;
850 for (
unsigned int i = 0; i < dof; i++)
852 q.at(idx)[i] = (i + 0.1) * 9.133758561390194e-01;
853 qdot.at(idx)[i] = (i + 0.1) * 6.323592462254095e-01;
854 qddot.at(idx)[i] = (i + 0.1) * 2.323592499940952e-01;
855 tau.at(idx)[i] = (i + 0.1) * 9.754040499940952e-02;
858 VectorNd qddotRef = VectorNd::Zero(reference_model.at(idx)->qdot_size);
859 VectorNd qddotCus = VectorNd::Zero(reference_model.at(idx)->qdot_size);
861 forwardDynamics(*reference_model.at(idx), q.at(idx), qdot.at(idx), tau.at(idx), qddotRef);
862 forwardDynamics(*custom_model.at(idx), q.at(idx), qdot.at(idx), tau.at(idx), qddotCus);
872 int dof = reference_model.at(idx)->dof_count;
874 for (
unsigned int i = 0; i < dof; i++)
876 q.at(idx)[i] = (i + 0.1) * 9.133758561390194e-01;
877 tau.at(idx)[i] = (i + 0.1) * 9.754040499940952e-02;
881 VectorNd qddot_minv_ref = VectorNd::Zero(dof);
883 calcMInvTimesTau(*reference_model.at(idx), q.at(idx), tau.at(idx), qddot_minv_ref,
true);
886 VectorNd qddot_minv_cus = VectorNd::Zero(dof);
887 calcMInvTimesTau(*custom_model.at(idx), q.at(idx), tau.at(idx), qddot_minv_cus,
true);
898 int dof = reference_model.at(idx)->dof_count;
904 for (
unsigned int i = 0; i < dof; i++)
906 q.at(idx)[i] = (i + 0.1) * 9.133758561390194e-01;
907 qdot.at(idx)[i] = (i + 0.1) * 6.323592462254095e-01;
908 tau.at(idx)[i] = (i + 0.1) * 9.754040499940952e-02;
911 VectorNd qddot_ref = VectorNd::Zero(dof);
912 VectorNd qddot_cus = VectorNd::Zero(dof);
914 VectorNd qdot_plus_ref = VectorNd::Zero(dof);
915 VectorNd qdot_plus_cus = VectorNd::Zero(dof);
927 constraint_set_ref.
bind(*reference_model.at(idx));
934 constraint_set_cus.
bind(*custom_model.at(idx));
942 VectorNd qdot_plus_error = qdot_plus_ref - qdot_plus_cus;
943 VectorNd qddot_error = qddot_ref - qddot_cus;
952 int main(
int argc,
char** argv)
954 ::testing::InitGoogleTest(&argc, argv);
955 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.
CustomJointTypeRevoluteX custom_rx_joint3
void calcCenterOfMassJacobian(Model &model, const Math::VectorNd &q, Math::MatrixNd &jCom, bool update_kinematics=true)
Computes the matrix such that .
void calcPointJacobian(Model &model, const Math::VectorNd &Q, unsigned int body_id, const Math::Vector3d &point_position, Math::MatrixNd &G, bool update_kinematics=true)
Computes the 3D point jacobian for a point on a body.
std::vector< Joint > mJoints
All joints.
3 DoF joint that uses Euler ZYX convention (faster than emulated
Describes all properties of a single body.
std::vector< Math::SpatialVector > c_J
void calcRelativeBodySpatialJacobianAndJacobianDot(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, Math::MatrixNd &G, Math::MatrixNd &GDot, ReferenceFramePtr baseFrame, ReferenceFramePtr relativeFrame, ReferenceFramePtr expressedInFrame=nullptr, bool update_kinematics=true)
Computes both the body spatial jacobian and its time derivative. This function will be a bit more eff...
CustomJointTypeRevoluteX custom_rx_joint2
CustomJoint is a struct used to create a joint with user defined parameters. This is accomplished by ...
std::shared_ptr< Model > ModelPtr
vector< vector< CustomJoint * > > custom_joint
bool linSolveGaussElimPivot(MatrixNd A, VectorNd b, VectorNd &x)
Solves a linear system using gaussian elimination with pivoting.
CustomJointTypeRevoluteX()
void calcRelativeBodySpatialJacobian(Model &model, const Math::VectorNd &Q, Math::MatrixNd &G, ReferenceFramePtr baseFrame, ReferenceFramePtr relativeFrame, ReferenceFramePtr expressedInFrame=nullptr, bool update_kinematics=true)
Computes the jacobian of a frame with being the "base" frame, being the "relative" frame...
void calcPointJacobianDot(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, unsigned int body_id, const Math::Vector3d &point_position, Math::MatrixNd &G, bool update_kinematics=true)
Computes the time derivative of the linear components the a point jacobian on a body.
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.
bool checkModelZeroVectorsAndMatrices(RobotDynamics::Model &model)
void calcRelativePointJacobian6D(Model &model, const Math::VectorNd &Q, Math::MatrixNd &G, ReferenceFramePtr baseFrame, ReferenceFramePtr relativeFrame, ReferenceFramePtr expressedInFrame=RobotDynamics::ReferenceFrame::getWorldFrame(), bool update_kinematics=true)
Compute the 6D jacobian of the origin of a reference frame relative to the origin of another referenc...
vector< ModelPtr > reference_model
int main(int argc, char **argv)
virtual void jcalc(Model &model, unsigned int joint_id, const Math::VectorNd &q, const Math::VectorNd &qdot)
void calcRelativePointJacobianAndJacobianDot6D(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, Math::MatrixNd &G, Math::MatrixNd &GDot, ReferenceFramePtr baseFrame, ReferenceFramePtr relativeFrame, ReferenceFramePtr expressedInFrame=RobotDynamics::ReferenceFrame::getWorldFrame(), bool update_kinematics=true)
Compute the point Jacobian of the origin of baseFrame, relative to the origin of relativeFrame, expressed in expressedInFrame. Also compute that point Jacobians time derivative.
virtual void jcalc_X_lambda_S(Model &model, unsigned int joint_id, const Math::VectorNd &q)
void calcPointJacobian6D(Model &model, const Math::VectorNd &Q, Math::MatrixNd &G, ReferenceFramePtr frame, bool update_kinematics=true)
Compute the 6D point jacobian of the origin of a reference frame If a position of a point is computed...
virtual void jcalc_X_lambda_S(Model &model, unsigned int joint_id, const Math::VectorNd &q)
std::shared_ptr< ReferenceFrame > ReferenceFramePtr
Structure that contains both constraint information and workspace memory.
void calcRelativePointJacobianDot6D(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, Math::MatrixNd &G, ReferenceFramePtr baseFrame, ReferenceFramePtr relativeFrame, ReferenceFramePtr expressedInFrame=RobotDynamics::ReferenceFrame::getWorldFrame(), bool update_kinematics=true)
Compute the time derivative of the 6D jacobian of the origin of a reference frame relative to the ori...
vector< vector< unsigned int > > reference_body_id
virtual void jcalc(Model &model, unsigned int joint_id, const Math::VectorNd &q, const Math::VectorNd &qdot)
void calcPointJacobianDot6D(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, RobotDynamics::ReferenceFramePtr frame, Math::MatrixNd &G, bool update_kinematics=true)
Computes the time derivative of a point jacobian of a point on a body.
vector< vector< Body > > body
unsigned int custom_joint_index
void calcCentroidalMomentumMatrixDot(Model &model, const Math::VectorNd &q, const Math::VectorNd &qdot, Math::MatrixNd &Adot, bool update_kinematics=true)
Calculates the time derivative of the centroidal momentum matrix, i.e. the matrix computed by RobotDy...
Describes a joint relative to the predecessor body.
void calcBodySpatialJacobianDot(Model &model, const Math::VectorNd &Q, const Math::VectorNd QDot, unsigned int body_id, Math::MatrixNd &G, const bool update_kinematics=true)
Computes the time derivative of the spatial jacobian for a body. The result will be returned via the ...
SpatialTransform Xrotx(const double &xrot)
Get transform with zero translation and pure rotation about x axis.
static bool checkMatrixNdEpsilonClose(const RobotDynamics::Math::MatrixNd &t1, const RobotDynamics::Math::MatrixNd &t2, const double epsilon)
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.
RdlCustomJointMultiBodyFixture()
std::vector< CustomJoint * > mCustomJoints
void calcCentroidalMomentumMatrix(Model &model, const Math::VectorNd &q, Math::MatrixNd &A, bool update_kinematics=true)
Calculates the centroidal momentum matrix, for a model. The centroidal momentum matrix is a matrix ...
void calcMInvTimesTau(Model &model, const Math::VectorNd &Q, const Math::VectorNd &Tau, Math::VectorNd &QDDot, bool update_kinematics=true)
Computes the effect of multiplying the inverse of the joint space inertia matrix with a vector in lin...
Contains all information about the rigid body model.
void calcRelativeBodySpatialJacobianDot(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, Math::MatrixNd &G, ReferenceFramePtr baseFrame, ReferenceFramePtr relativeFrame, ReferenceFramePtr expressedInFrame=nullptr, bool update_kinematics=true)
Computes the rate of change of the jacobian, , with being the "base" frame, being the relative" fra...
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.
bool bind(const Model &model)
Initializes and allocates memory for the constraint set.
Math types such as vectors and matrices and utility functions.
static bool checkSpatialVectorsEpsilonClose(const RobotDynamics::Math::SpatialVector &v1, const RobotDynamics::Math::SpatialVector &v2, const double epsilon)
const int NUMBER_OF_BODIES
vector< vector< unsigned int > > custom_body_id
CustomJointTypeRevoluteX custom_rx_joint1
void gravityEffects(Model &model, Math::VectorNd &Tau)
Computes the gravity vector.
TEST_F(RdlCustomJointMultiBodyFixture, UpdateKinematics)
static bool checkVector3dEpsilonClose(const RobotDynamics::Math::Vector3d &v1, const RobotDynamics::Math::Vector3d &v2, const double epsilon)
const int NUMBER_OF_MODELS
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.
std::vector< Math::SpatialTransform > X_J
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.
static bool checkMatrix3dEpsilonClose(const RobotDynamics::Math::Matrix3d &t1, const RobotDynamics::Math::Matrix3d &t2, const double epsilon)
vector< ModelPtr > custom_model