@@ -37,11 +37,11 @@ KinodynamicsID::KinodynamicsID(const RobotModelHandler & model_handler, double c
3737 tsid_contacts.push_back (contact_point);
3838 break ;
3939 }
40- case RobotModelHandler::FootType::SIX_D : {
40+ case RobotModelHandler::FootType::QUAD : {
4141 auto contact_6D = std::make_shared<tsid::contacts::Contact6d>(
4242 frame_name, robot_, frame_name, model_handler_.get6DFootContactPoints (i), normal,
4343 settings_.friction_coefficient , min_f, max_f);
44- contact_6D->Kp (settings_.kp_contact * Eigen::VectorXd::Ones (3 ));
44+ contact_6D->Kp (settings_.kp_contact * Eigen::VectorXd::Ones (6 ));
4545 contact_6D->Kd (2.0 * contact_6D->Kp ().cwiseSqrt ());
4646 tsid_contacts.push_back (contact_6D);
4747 break ;
@@ -92,17 +92,27 @@ KinodynamicsID::KinodynamicsID(const RobotModelHandler & model_handler, double c
9292 solver_ = tsid::solvers::SolverHQPFactory::createNewSolver (tsid::solvers::SOLVER_HQP_PROXQP, " solver-proxqp" );
9393 solver_->resize (formulation_.nVar (), formulation_.nEq (), formulation_.nIn ());
9494
95- // Dry run to initialize solver data & output
95+ // By default initialize target in reference state
9696 const Eigen::VectorXd q_ref = model_handler.getReferenceState ().head (nq);
9797 const Eigen::VectorXd v_ref = model_handler.getReferenceState ().tail (nv);
9898 std::vector<bool > c_ref (n_contacts);
99- MatrixN3d f_ref = MatrixN3d::Zero (n_contacts, 3 ) ;
99+ std::vector<TargetContactForce> f_ref ;
100100 for (int i = 0 ; i < n_contacts; i++)
101101 {
102+ // By default initialize all foot in contact with same amount of force
102103 c_ref[i] = true ;
103- f_ref (i, 2 ) = weight / n_contacts;
104+ const RobotModelHandler::FootType foot_type = model_handler.getFootType (i);
105+ if (foot_type == RobotModelHandler::POINT)
106+ f_ref.push_back (TargetContactForce::Zero (3 ));
107+ else if (foot_type == RobotModelHandler::QUAD)
108+ f_ref.push_back (TargetContactForce::Zero (6 ));
109+ else
110+ assert (false );
111+ f_ref[i][2 ] = weight / n_contacts; // Weight on Z axis
104112 }
105113 setTarget (q_ref, v_ref, v_ref, c_ref, f_ref);
114+
115+ // Dry run to initialize solver data & output
106116 const tsid::solvers::HQPData & solver_data = formulation_.computeProblemData (0 , q_ref, v_ref);
107117 last_solution_ = solver_->solve (solver_data);
108118}
@@ -186,7 +196,7 @@ void KinodynamicsID::solve(
186196 ->setReference (data_handler_.getFootPose (i));
187197 break ;
188198 }
189- case RobotModelHandler::FootType::SIX_D : {
199+ case RobotModelHandler::FootType::QUAD : {
190200 std::static_pointer_cast<tsid::contacts::Contact6d>(tsid_contacts[i])
191201 ->setReference (data_handler_.getFootPose (i));
192202 break ;
0 commit comments