@@ -617,64 +617,41 @@ BOOST_AUTO_TEST_CASE(test_reverse_spherical_zyx)
617617 d_f.oMf [m_forward.getFrameId (" body1" , pinocchio::BODY)]));
618618}
619619
620- // / @brief test if reversing of an ellipsoid joint is correct.
621- BOOST_AUTO_TEST_CASE (test_reverse_ellipsoid )
620+ // / @brief test if an ellipsoid joint is correct after building
621+ BOOST_AUTO_TEST_CASE (test_ellipsoid )
622622{
623623 using namespace pinocchio ::graph;
624624
625- ModelGraph g = buildReversableModelGraph (JointEllipsoid (0.01 , 0.01 , 0.01 ));
626- // /////////////// Model
627- BOOST_CHECK_THROW (buildModel (g, " body2" , pinocchio::SE3::Identity ()), std::invalid_argument);
625+ ModelGraph g = buildReversableModelGraph (JointEllipsoid (0.01 , 0.02 , 0.03 ));
628626
629627 // ////////////////////////////////// Forward model
630628 pinocchio::Model m_forward = buildModel (g, " body1" , pinocchio::SE3::Identity ());
631629 pinocchio::Data d_f (m_forward);
632- // config vector forward model Ellipsoid
630+ // config vector forward model
633631 Eigen::Vector3d q (m_forward.nq );
634632 q << M_PI / 4 , M_PI, M_PI / 2 ;
635633 pinocchio::framesForwardKinematics (m_forward, d_f, q);
636634
637635 // Create a standalone model with the EXACT same structure as the graph model
638636 pinocchio::Model modelEllipsoid;
639- pinocchio::SE3 poseBody1 =
640- pinocchio::SE3 (Eigen::Matrix3d::Identity (), Eigen::Vector3d (2 ., 0 ., 0 .));
641- pinocchio::SE3 poseBody2 =
642- pinocchio::SE3 (Eigen::Matrix3d::Identity (), Eigen::Vector3d (0 ., 3 ., 0 .));
643637 pinocchio::Model::JointIndex idx;
644638
645- pinocchio::JointModelEllipsoid jModelEllipsoid (0.01 , 0.01 , 0.01 );
646- idx = modelEllipsoid.addJoint (0 , jModelEllipsoid, poseBody1, " ellipsoid" );
647- std::cout << " Added joint ellipsoid with index: " << idx << std::endl;
648-
649- pinocchio::Inertia body2_inertia = Inertia::Identity ();
650- modelEllipsoid.appendBodyToJoint (idx, body2_inertia, poseBody2);
651- // pinocchio::FrameIndex frame_id = modelEllipsoid.addBodyFrame("body2", -1, poseBody2);
652-
653- // This line is not working yet.
654- // pinocchio::FrameIndex frame_id = modelEllipsoid.addBodyFrame("body2", idx, poseBody2);
655-
656- // pinocchio::Data jDataEllipsoid(modelEllipsoid);
657- // pinocchio::framesForwardKinematics(modelEllipsoid, jDataEllipsoid, q);
658-
659- // DEBUG: Print both transforms
660- std::cout << " nb frames in new model: " << modelEllipsoid.nframes << std::endl;
661- // std::cout << "=== DEBUG test_reverse_ellipsoid ===" << std::endl;
662- // std::cout << "body2_graph translation:\n" << body2_graph.translation().transpose() <<
663- // std::endl; std::cout << "body2_graph rotation:\n" << body2_graph.rotation() << std::endl;
664- // std::cout << "\nbody2_standalone translation:\n" << body2_standalone.translation().transpose()
665- // << std::endl; std::cout << "body2_standalone rotation:\n" << body2_standalone.rotation() <<
666- // std::endl; std::cout << "\nTranslation difference:\n" << (body2_graph.translation() -
667- // body2_standalone.translation()).transpose() << std::endl; std::cout << "Translation difference
668- // norm: " << (body2_graph.translation() - body2_standalone.translation()).norm() << std::endl;
669- // std::cout << "Rotation difference (Frobenius norm): "
670- // << (body2_graph.rotation() - body2_standalone.rotation()).norm() << std::endl;
671-
672- // Compare the absolute placement of body2 in both models
673- // pinocchio::SE3 body2_graph = d_f.oMf[m_forward.getFrameId("body2", pinocchio::BODY)];
674- // pinocchio::SE3 body2_standalone =
675- // jDataEllipsoid.oMf[modelEllipsoid.getFrameId("body2", pinocchio::BODY)];
676-
677- // BOOST_CHECK(body2_graph.isApprox(body2_standalone));
639+ pinocchio::SE3 poseBody1 (Eigen::Matrix3d::Identity (), Eigen::Vector3d (2 ., 0 ., 0 .));
640+ pinocchio::SE3 poseBody2 (Eigen::Matrix3d::Identity (), Eigen::Vector3d (0 ., 3 ., 0 .));
641+
642+ idx = modelEllipsoid.addJoint (
643+ 0 , pinocchio::JointModelEllipsoid (0.01 , 0.02 , 0.03 ), poseBody1, " ellipsoid" );
644+
645+ modelEllipsoid.appendBodyToJoint (
646+ idx,
647+ pinocchio::Inertia (4 ., pinocchio::Inertia::Vector3 (0 ., 2 ., 0 .), pinocchio::Symmetric3::Zero ()),
648+ poseBody2);
649+
650+ pinocchio::Data data_model (modelEllipsoid);
651+ pinocchio::framesForwardKinematics (modelEllipsoid, data_model, q);
652+
653+ // Compare the joint transformations
654+ BOOST_CHECK (SE3isApprox (data_model.oMi [idx], d_f.oMi [m_forward.getJointId (" body1_to_body2" )]));
678655}
679656
680657// / @brief test if reversing of a composite joint is correct.
0 commit comments