30 #include <mc_tasks/CoMTask.h> 31 #include <mc_tasks/CoPTask.h> 33 #include <eigen-quadprog/QuadProg.h> 60 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
98 void addGUIElements(std::shared_ptr<mc_rtc::gui::StateBuilder> gui);
112 void addTasks(mc_solver::QPSolver & solver);
124 Eigen::Vector3d
computeZMP(
const sva::ForceVecd & wrench)
const;
129 void configure(
const mc_rtc::Configuration &);
157 void reset(
const mc_rbdyn::Robots & robots);
175 void seekTouchdown(std::shared_ptr<mc_tasks::force::CoPTask> footTask);
184 void setContact(std::shared_ptr<mc_tasks::force::CoPTask> footTask,
const Contact & contact);
193 void setSwingFoot(std::shared_ptr<mc_tasks::force::CoPTask> footTask);
202 return contactState_;
235 const Eigen::Vector3d & comd,
236 const sva::ForceVecd & wrench,
237 double leftFootRatio);
263 +mu, +mu, -1, -Y, -X, -(X + Y) * mu,
264 +mu, -mu, -1, -Y, +X, -(X + Y) * mu,
265 -mu, +mu, -1, +Y, -X, -(X + Y) * mu,
266 -mu, -mu, -1, +Y, +X, -(X + Y) * mu,
267 +mu, +mu, +1, +Y, +X, -(X + Y) * mu,
268 +mu, -mu, +1, +Y, -X, -(X + Y) * mu,
269 -mu, +mu, +1, -Y, +X, -(X + Y) * mu,
270 -mu, -mu, +1, -Y, -X, -(X + Y) * mu;
279 Eigen::Vector3d
zmp()
const 295 void configure(
const mc_rtc::Configuration & config)
297 double ankleTorqueWeight = config(
"ankle_torque");
298 double forceRatioWeight = config(
"force_ratio");
299 double netWrenchWeight = config(
"net_wrench");
300 ankleTorqueSqrt = std::sqrt(ankleTorqueWeight);
301 forceRatioSqrt = std::sqrt(forceRatioWeight);
302 netWrenchSqrt = std::sqrt(netWrenchWeight);
306 double ankleTorqueSqrt;
307 double forceRatioSqrt;
308 double netWrenchSqrt;
319 void checkInTheAir();
324 sva::ForceVecd computeDesiredWrench();
331 void distributeWrench(
const sva::ForceVecd & desiredWrench);
332 void distributeWrenchQuadProg(
const sva::ForceVecd & desiredWrench);
341 void saturateWrench(
const sva::ForceVecd & desiredWrench, std::shared_ptr<mc_tasks::force::CoPTask> & footTask);
342 void saturateWrenchQuadProg(
const sva::ForceVecd & desiredWrench,
343 std::shared_ptr<mc_tasks::force::CoPTask> & footTask);
348 void setSupportFootGains();
360 void updateCoMTaskZMPCC();
369 void updateFootForceDifferenceControl();
374 void updateZMPFrame();
381 sva::ForceVecd contactAdmittance()
383 return {{copAdmittance_.y(), copAdmittance_.x(), 0.}, {0., 0., 0.}};
395 Eigen::Matrix<double, 16, 6> wrenchFaceMatrix_;
396 Eigen::QuadProgDense qpSolver_;
397 Eigen::Vector2d comAdmittance_ = Eigen::Vector2d::Zero();
398 Eigen::Vector2d copAdmittance_ = Eigen::Vector2d::Zero();
399 Eigen::Vector3d comStiffness_ = {1000., 1000., 100.};
400 Eigen::Vector3d dcmAverageError_ =
401 Eigen::Vector3d::Zero();
402 Eigen::Vector3d dcmError_ = Eigen::Vector3d::Zero();
403 Eigen::Vector3d dcmVelError_ =
404 Eigen::Vector3d::Zero();
405 Eigen::Vector3d measuredCoM_ = Eigen::Vector3d::Zero();
406 Eigen::Vector3d measuredCoMd_ = Eigen::Vector3d::Zero();
407 Eigen::Vector3d measuredZMP_ = Eigen::Vector3d::Zero();
408 Eigen::Vector3d zmpError_ = Eigen::Vector3d::Zero();
409 Eigen::Vector3d zmpccCoMAccel_ = Eigen::Vector3d::Zero();
410 Eigen::Vector3d zmpccCoMOffset_ = Eigen::Vector3d::Zero();
411 Eigen::Vector3d zmpccCoMVel_ = Eigen::Vector3d::Zero();
412 Eigen::Vector3d zmpccError_ = Eigen::Vector3d::Zero();
413 Eigen::Vector4d polePlacement_ = {-10., -5., -1., 10.};
415 FDQPWeights fdqpWeights_;
418 bool inTheAir_ =
false;
419 bool zmpccOnlyDS_ =
true;
420 const Pendulum & pendulum_;
421 const mc_rbdyn::Robot & controlRobot_;
422 double comWeight_ = 1000.;
423 double contactWeight_ = 100000.;
424 double dcmDerivGain_ = 0.;
425 double dcmIntegralGain_ = 5.;
426 double dcmPropGain_ = 1.;
427 double dfzAdmittance_ = 1e-4;
428 double dfzDamping_ = 0.;
429 double dfzForceError_ = 0.;
430 double dfzHeightError_ = 0.;
432 double leftFootRatio_ = 0.5;
434 double runTime_ = 0.;
435 double swingFootStiffness_ = 2000.;
436 double swingFootWeight_ = 500.;
437 double vdcFrequency_ = 1.;
438 double vdcHeightError_ = 0.;
439 double vdcStiffness_ = 1000.;
441 mc_rtc::Configuration config_;
442 std::vector<std::string> comActiveJoints_;
443 sva::ForceVecd distribWrench_ = sva::ForceVecd::Zero();
444 sva::ForceVecd measuredWrench_ = sva::ForceVecd::Zero();
445 sva::MotionVecd contactDamping_ = sva::MotionVecd::Zero();
446 sva::MotionVecd contactStiffness_ = sva::MotionVecd::Zero();
447 sva::PTransformd zmpFrame_ = sva::PTransformd::Identity();
static constexpr double MAX_DFZ_DAMPING
Maximum normalized damping in [Hz] for foot force difference control.
Contact rightFootContact
Current right foot contact.
ContactState
Contact state: set of feet in contact.
static constexpr double MAX_DCM_I_GAIN
Maximum DCM average integral gain in [Hz].
ContactState contactState()
Get contact state.
Exponential Moving Average.
Stabilizer(const mc_rbdyn::Robot &robot, const Pendulum &pendulum, double dt)
Initialize stabilizer.
void disable()
Disable all feedback components.
static constexpr double MIN_DSP_FZ
Minimum normal contact force in [N] for DSP, used to avoid low-force targets when close to contact sw...
void wrenchFaceMatrix(const Sole &sole)
Update H-representation of contact wrench cones.
void seekTouchdown(std::shared_ptr< mc_tasks::force::CoPTask > footTask)
Configure foot task for contact seeking.
void addLogEntries(mc_rtc::Logger &logger)
Log stabilizer entries.
static constexpr double MAX_FDC_RZ_VEL
Maximum z-axis angular velocity in [rad] / [s] for foot damping control.
void addTasks(mc_solver::QPSolver &solver)
Add tasks to QP solver.
void reconfigure()
Apply stored configuration.
double halfLength
Half-length of the sole in [m].
State of the inverted pendulum model.
void contactState(ContactState contactState)
Set desired contact state.
Contact leftFootContact
Current left foot contact.
static constexpr double MAX_FDC_RX_VEL
Maximum x-axis angular velocity in [rad] / [s] for foot damping control.
void run()
Update QP task targets.
double halfWidth
Half-width of the sole in [m].
Remove stationary offset from an input signal.
static EIGEN_MAKE_ALIGNED_OPERATOR_NEW constexpr double MAX_AVERAGE_DCM_ERROR
Maximum average (integral) DCM error in [m].
void reset(const mc_rbdyn::Robots &robots)
Reset CoM and foot CoP tasks.
void sole(const Sole &sole)
Set model sole properties.
bool detectTouchdown(const std::shared_ptr< mc_tasks::force::CoPTask > footTask, const Contact &contact)
Detect foot touchdown based on both force and distance.
Eigen::Vector3d computeZMP(const sva::ForceVecd &wrench) const
Compute ZMP of a wrench in the output frame.
static constexpr double MAX_DFZ_ADMITTANCE
Maximum admittance in [s] / [kg] for foot force difference control.
static constexpr double MAX_ZMPCC_COM_OFFSET
Maximum CoM offset due to admittance control in [m].
double friction
Friction coefficient.
static constexpr double MAX_DCM_D_GAIN
Maximum DCM derivative gain (no unit)
static constexpr double MAX_FDC_RY_VEL
Maximum y-axis angular velocity in [rad] / [s] for foot damping control.
std::shared_ptr< mc_tasks::CoMTask > comTask
CoM position task.
void addGUIElements(std::shared_ptr< mc_rtc::gui::StateBuilder > gui)
Add GUI panel.
std::shared_ptr< mc_tasks::force::CoPTask > leftFootTask
Left foot hybrid position/force control task.
static constexpr double MAX_COM_ADMITTANCE
Maximum admittance for CoM admittance control.
std::shared_ptr< mc_tasks::force::CoPTask > rightFootTask
Right foot hybrid position/force control task.
static constexpr double MAX_COP_ADMITTANCE
Maximum CoP admittance for foot damping control.
Walking stabilization based on linear inverted pendulum tracking.
Eigen::Vector3d zmp() const
ZMP target after wrench distribution.
void setContact(std::shared_ptr< mc_tasks::force::CoPTask > footTask, const Contact &contact)
Configure foot task for contact at a given location.
void updateState(const Eigen::Vector3d &com, const Eigen::Vector3d &comd, const sva::ForceVecd &wrench, double leftFootRatio)
Update real-robot state.
Main controller namespace.
void removeTasks(mc_solver::QPSolver &solver)
Remove tasks from QP solver.
void setSwingFoot(std::shared_ptr< mc_tasks::force::CoPTask > footTask)
Configure foot task for swinging.
static constexpr double MAX_DCM_P_GAIN
Maximum DCM proportional gain in [Hz].
void configure(const mc_rtc::Configuration &)
Read configuration from dictionary.