@@ -133,11 +133,12 @@ void KinodynamicsID::setTarget(
133133 postureTask_->setReference (samplePosture_);
134134
135135 // Base task
136- const pinocchio::SE3 oMb{data_handler_.getBaseFramePose ()};
137- const pinocchio::SE3 oMb_rotation (oMb.rotation (), Eigen::Vector3d::Zero ());
138- const pinocchio::Motion v_world_aligned{oMb_rotation.act (pinocchio::Motion (v_target.head <6 >()))};
139- const pinocchio::Motion a_world_aligned{oMb_rotation.act (pinocchio::Motion (a_target.head <6 >()))};
140- baseTask_->setReference (oMb, v_world_aligned, a_world_aligned);
136+ tsid::math::SE3ToVector (data_handler_.getBaseFramePose (), sampleBase_.pos );
137+ /* Velocity and acceleration not set here since the actual position of the robot is needed to transform from local to
138+ * world-aligned frame. Will be done in solve()
139+ */
140+ targetVelBase_ = v_target.head <6 >();
141+ targetAccBase_ = a_target.head <6 >();
141142
142143 // Foot contacts
143144 for (std::size_t foot_nb = 0 ; foot_nb < model_handler_.getFeetNb (); foot_nb++)
@@ -215,6 +216,15 @@ void KinodynamicsID::solve(
215216 }
216217 }
217218
219+ // Convert robot base vel/acc from local to world-aligned frame using actual robot pose
220+ const pinocchio::SE3 oMb_rotation (data_handler_.getBaseFramePose ().rotation (), Eigen::Vector3d::Zero ());
221+ const pinocchio::Motion v_world_aligned{oMb_rotation.act (pinocchio::Motion (targetVelBase_))};
222+ const pinocchio::Motion a_world_aligned{oMb_rotation.act (pinocchio::Motion (targetAccBase_))};
223+ sampleBase_.setDerivative (v_world_aligned.toVector ());
224+ sampleBase_.setDerivative (a_world_aligned.toVector ());
225+ baseTask_->setReference (sampleBase_);
226+
227+ // Solve QP
218228 const tsid::solvers::HQPData & solver_data = formulation_.computeProblemData (t, q_meas, v_meas);
219229 last_solution_ = solver_.solve (solver_data);
220230 assert (last_solution_.status == tsid::solvers::HQPStatus::HQP_STATUS_OPTIMAL);
0 commit comments