| 37 | BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE) |
| 38 | |
| 39 | BOOST_AUTO_TEST_CASE(humanoid_with_bilateral_constraint) |
| 40 | { |
| 41 | // Construct humanoid |
| 42 | ModelHandle model(new Model()); |
| 43 | buildModels::humanoid(*model, true); |
| 44 | model->lowerPositionLimit = Eigen::VectorXd::Constant(model->nq, -1.0) * std::numeric_limits<double>::max(); |
| 45 | model->upperPositionLimit = Eigen::VectorXd::Constant(model->nq, 1.0) * std::numeric_limits<double>::max(); |
| 46 | DataHandle data = std::make_shared<Data>(*model); |
| 47 | |
| 48 | GeometryModelHandle geom_model(new GeometryModel()); |
| 49 | |
| 50 | // Initial state |
| 51 | Eigen::VectorXd q = pinocchio::neutral(*model); |
| 52 | |
| 53 | // Bilateral constraint on the robot right wrist |
| 54 | BilateralPointConstraintModelVector bilateral_constraint_models; |
| 55 | pinocchio::framesForwardKinematics(*model, *data, q); |
| 56 | const JointIndex joint1_id = 0; |
| 57 | const GeomIndex joint2_id = 13; |
| 58 | ::pinocchio::SE3 Mc = data->oMi[joint2_id]; |
| 59 | const SE3 joint1_placement = Mc; |
| 60 | const SE3 joint2_placement = SE3::Identity(); |
| 61 | bilateral_constraint_models.push_back(BilateralPointConstraintModel(*model, joint1_id, joint1_placement, joint2_id, joint2_placement)); |
| 62 | bilateral_constraint_models[0].baumgarte_corrector_parameters().Kp = 0.1; |
| 63 | |
| 64 | // The humanoid's freeflyer's height should remain the same |
| 65 | Simulator sim(model, geom_model, bilateral_constraint_models); |
| 66 | sim.admm_constraint_solver_settings.absolute_precision = 1e-9; |
| 67 | sim.admm_constraint_solver_settings.relative_precision = 1e-9; |
| 68 | sim.admm_constraint_solver_settings.max_iter = 1000; |
| 69 | const double dt = 1e-3; |
| 70 | Eigen::VectorXd v = Eigen::VectorXd::Zero(model->nv); |
| 71 | Eigen::VectorXd tau = Eigen::VectorXd::Zero(model->nv); |
| 72 | BOOST_CHECK_NO_THROW(sim.step<ADMM>(q, v, tau, dt)); |
| 73 | pinocchio::framesForwardKinematics(*model, *data, sim.qnew); |
| 74 | EIGEN_VECTOR_IS_APPROX(Mc.translation(), data->oMi[joint2_id].translation(), 1e-3); |
| 75 | |
| 76 | // Calling the simulator twice to test warmstart |
| 77 | sim.step<ADMM>(q, v, tau, dt); |
| 78 | INDEX_EQUALITY_CHECK(sim.admm_constraint_solver.getIterationCount(), 0); |
| 79 | |
| 80 | for (int i = 0; i < 10; ++i) |
| 81 | { |
| 82 | Eigen::VectorXd q = sim.qnew; |
| 83 | Eigen::VectorXd v = sim.vnew; |
| 84 | BOOST_CHECK_NO_THROW(sim.step<ADMM>(q, v, tau, dt)); |
| 85 | pinocchio::framesForwardKinematics(*model, *data, sim.qnew); |
| 86 | EIGEN_VECTOR_IS_APPROX(Mc.translation(), data->oMi[joint2_id].translation(), 1e-3); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | BOOST_AUTO_TEST_CASE(simulator_instance_step_with_friction_on_joints) |
| 91 | { |
nothing calls this directly
no outgoing calls
no test coverage detected