@@ -134,9 +134,11 @@ void KinodynamicsID::setTarget(
134134
135135 // Base task
136136 tsid::math::SE3ToVector (data_handler_.getBaseFramePose (), sampleBase_.pos );
137- sampleBase_.setDerivative (v_target.head <6 >());
138- sampleBase_.setSecondDerivative (a_target.head <6 >());
139- baseTask_->setReference (sampleBase_);
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 >();
140142
141143 // Foot contacts
142144 for (std::size_t foot_nb = 0 ; foot_nb < model_handler_.getFeetNb (); foot_nb++)
@@ -214,6 +216,15 @@ void KinodynamicsID::solve(
214216 }
215217 }
216218
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
217228 const tsid::solvers::HQPData & solver_data = formulation_.computeProblemData (t, q_meas, v_meas);
218229 last_solution_ = solver_.solve (solver_data);
219230 assert (last_solution_.status == tsid::solvers::HQPStatus::HQP_STATUS_OPTIMAL);
0 commit comments