@@ -622,7 +622,7 @@ BOOST_AUTO_TEST_CASE(test_reverse_ellipsoid)
622622{
623623 using namespace pinocchio ::graph;
624624
625- ModelGraph g = buildReversableModelGraph (JointEllipsoid ());
625+ ModelGraph g = buildReversableModelGraph (JointEllipsoid (0.01 , 0.01 , 0.01 ));
626626 // /////////////// Model
627627 BOOST_CHECK_THROW (buildModel (g, " body2" , pinocchio::SE3::Identity ()), std::invalid_argument);
628628
@@ -634,15 +634,49 @@ BOOST_AUTO_TEST_CASE(test_reverse_ellipsoid)
634634 q << M_PI / 4 , M_PI, M_PI / 2 ;
635635 pinocchio::framesForwardKinematics (m_forward, d_f, q);
636636
637- cout << " Forward Ellipsoid oMf body2: \n "
638- << d_f.oMf [m_forward.getFrameId (" body2" , pinocchio::BODY)].matrix () << endl;
639- BOOST_CHECK (d_f.oMf [m_forward.getFrameId (" body2" , pinocchio::BODY)].isApprox (
640- // trouver une valeur à mettre dedans.
641- // todo après manger :)
642- ));
637+ // Create a standalone model with the EXACT same structure as the graph model
638+ 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 .));
643+ pinocchio::Model::JointIndex idx;
644+
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));
643678}
644679
645-
646680// / @brief test if reversing of a composite joint is correct.
647681BOOST_AUTO_TEST_CASE (test_reverse_composite)
648682{
0 commit comments