Go to the documentation of this file.
18 namespace lipm_stabilizer
24 FDQPWeights() : ankleTorqueSqrt(
std::sqrt(100)), netWrenchSqrt(
std::sqrt(10000)), pressureSqrt(
std::sqrt(1)) {}
26 FDQPWeights(
double netWrench,
double ankleTorque,
double pressure)
27 : ankleTorqueSqrt(
std::sqrt(ankleTorque)), netWrenchSqrt(
std::sqrt(netWrench)), pressureSqrt(
std::sqrt(pressure))
36 if(config.
has(
"ankle_torque")) { ankleTorqueSqrt = std::sqrt(
static_cast<double>(config(
"ankle_torque"))); }
37 if(config.
has(
"net_wrench")) { netWrenchSqrt = std::sqrt(
static_cast<double>(config(
"net_wrench"))); }
38 if(config.
has(
"pressure")) { pressureSqrt = std::sqrt(
static_cast<double>(config(
"pressure"))); }
44 config.
add(
"ankle_torque", std::pow(ankleTorqueSqrt, 2));
45 config.
add(
"net_wrench", std::pow(netWrenchSqrt, 2));
46 config.
add(
"pressure", std::pow(pressureSqrt, 2));
58 copRegulation_ = 1e-8;
65 copRegulation_ = copReg;
74 if(config.
has(
"cop")) { cop_ =
static_cast<double>(config(
"cop")); }
75 if(config.
has(
"cop_regulation")) { copRegulation_ =
static_cast<double>(config(
"cop_regulation")); }
76 if(config.
has(
"cop_diff")) { copDiff_ =
static_cast<double>(config(
"cop_diff")); }
82 config.
add(
"cop", cop_);
83 config.
add(
"cop_regulation", copRegulation_);
84 config.
add(
"cop_diff", copDiff_);
127 if(config.
has(
"MAX_DFZ_ADMITTANCE"))
129 mc_rtc::log::deprecated(
"StabilizerConfiguration::SafetyThresholds",
"MAX_DFZ_ADMITTANCE",
"MAX_DF_ADMITTANCE");
133 if(config.
has(
"MAX_DFZ_DAMPING"))
169 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
339 weights.
load(config);
355 weights.
load(config);
377 return safety.
save();
409 extWrench.
load(config);
415 return extWrench.
save();
422 namespace lipm_stabilizer
436 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
444 double friction = 0.7;
448 bool constrainCoP =
true;
451 bool useTargetPressure =
true;
454 Eigen::Vector2d copAdmittance = Eigen::Vector2d::Zero();
455 sva::MotionVecd copMaxVel{{0.3, 0.3, 0.3}, {0.1, 0.1, 0.1}};
456 double copVelFilterGain = 0.8;
465 double comdErrorGain = 1.;
466 double zmpdGain = 0.;
467 double dcmIntegratorTimeConstant =
469 double dcmDerivatorTimeConstant = 1.;
471 double fSumFilterTimeConstant = 20.;
474 Eigen::Vector3d comStiffness = {1000., 1000., 100.};
475 double comWeight = 1000.;
476 Eigen::Vector3d comDimWeight = Eigen::Vector3d::Ones();
477 double comHeight = 0.84;
480 Eigen::Vector3d copFzLambda = 100.0 * Eigen::Vector3d::Ones();
484 double torsoPitch = 0;
485 double torsoStiffness = 10;
486 double torsoWeight = 100;
487 Eigen::Vector3d torsoDimWeight = Eigen::Vector3d::Ones();
488 double pelvisStiffness = 10;
489 double pelvisWeight = 100;
490 Eigen::Vector3d pelvisDimWeight = Eigen::Vector3d::Ones();
492 sva::MotionVecd contactDamping{{300, 300, 300},
494 sva::MotionVecd contactStiffness = {{1, 1, 1}, {1, 1, 1}};
495 double contactWeight = 100000.;
497 double vdcFrequency = 1.;
498 double vdcStiffness = 1000.;
515 const auto & s = safetyThresholds;
529 config(
"verbose", verbose);
531 if(config.
has(
"safety_tresholds")) { safetyThresholds.
load(config(
"safety_tresholds")); }
533 if(config.
has(
"fdqp_weights")) { fdqpWeights.
load(config(
"fdqp_weights")); }
535 if(config.
has(
"fdmpc_weights")) { fdmpcWeights.
load(config(
"fdmpc_weights")); }
537 config(
"friction", friction);
538 config(
"leftFootSurface", leftFootSurface);
539 config(
"rightFootSurface", rightFootSurface);
540 config(
"torsoBodyName", torsoBodyName);
542 if(config.
has(
"admittance"))
544 auto admittance = config(
"admittance");
545 admittance(
"cop", copAdmittance);
546 admittance(
"useTargetPressure", useTargetPressure);
547 admittance(
"copFzLambda", copFzLambda);
548 admittance(
"copFzDelay", delayCoP);
549 admittance(
"maxVel", copMaxVel);
551 if(admittance.has(
"dfz"))
554 "keep the same behavior use df: [0, 0, dfz]");
555 dfAdmittance.setZero();
556 dfAdmittance.z() = admittance(
"dfz");
558 else { admittance(
"df", dfAdmittance); }
559 if(admittance.has(
"dfz_damping"))
561 mc_rtc::log::warning(
"[MC_RTC_DEPRECATED][StabilizerConfiguration] dfz_damping is now dimensional, to "
562 "keep the same behavior use df_damping: [0, 0, dfz_damping]");
564 dfDamping.z() = admittance(
"dfz_damping");
566 else { admittance(
"df_damping", dfDamping); }
568 if(config.
has(
"dcm_tracking"))
570 auto dcmTracking = config(
"dcm_tracking");
571 if(dcmTracking.has(
"gains"))
573 dcmTracking(
"gains")(
"prop", dcmPropGain);
574 dcmTracking(
"gains")(
"integral", dcmIntegralGain);
575 dcmTracking(
"gains")(
"deriv", dcmDerivGain);
576 dcmTracking(
"gains")(
"comdError", comdErrorGain);
577 dcmTracking(
"gains")(
"zmpd", zmpdGain);
579 if(dcmTracking.has(
"derivator_time_constant"))
581 mc_rtc::log::warning(
"derivator_time_constant is deprecated, use derivator_cutoff_period instead");
582 dcmTracking(
"derivator_time_constant", dcmDerivatorTimeConstant);
584 dcmTracking(
"derivator_cutoff_period", dcmDerivatorTimeConstant);
585 dcmTracking(
"integrator_time_constant", dcmIntegratorTimeConstant);
587 if(config.
has(
"dcm_bias")) { dcmBias.
load(config(
"dcm_bias")); }
588 if(config.
has(
"external_wrench")) { extWrench.
load(config(
"external_wrench")); }
589 if(config.
has(
"tasks"))
591 auto tasks = config(
"tasks");
594 tasks(
"com")(
"active_joints", comActiveJoints);
595 tasks(
"com")(
"stiffness", comStiffness);
596 tasks(
"com")(
"weight", comWeight);
597 tasks(
"com")(
"dimWeight", comDimWeight);
598 tasks(
"com")(
"height", comHeight);
601 if(tasks.has(
"torso"))
604 tasks(
"torso")(
"pitch", torsoPitch);
605 tasks(
"torso")(
"stiffness", torsoStiffness);
606 tasks(
"torso")(
"weight", torsoWeight);
607 tasks(
"torso")(
"dimWeight", torsoDimWeight);
610 if(tasks.has(
"pelvis"))
612 tasks(
"pelvis")(
"stiffness", pelvisStiffness);
613 tasks(
"pelvis")(
"weight", pelvisWeight);
614 tasks(
"pelvis")(
"dimWeight", pelvisDimWeight);
617 if(tasks.has(
"contact"))
619 tasks(
"contact")(
"constrainCoP", constrainCoP);
620 if(tasks(
"contact").has(
"damping"))
624 double d = tasks(
"contact")(
"damping");
625 contactDamping = sva::MotionVecd({d, d, d}, {d, d, d});
630 contactDamping = tasks(
"contact")(
"damping");
633 if(tasks(
"contact").has(
"stiffness"))
637 double k = tasks(
"contact")(
"stiffness");
638 contactStiffness = sva::MotionVecd({k, k, k}, {k, k, k});
643 contactStiffness = tasks(
"contact")(
"stiffness");
646 tasks(
"contact")(
"stiffness", contactStiffness);
647 tasks(
"contact")(
"weight", contactWeight);
650 if(config.
has(
"vdc"))
652 auto vdc = config(
"vdc");
653 vdc(
"frequency", vdcFrequency);
654 vdc(
"stiffness", vdcStiffness);
657 if(config.
has(
"zmpcc")) { zmpcc.
load(config(
"zmpcc")); }
658 config(
"zmpcc", zmpcc);
664 conf.
add(
"verbose", verbose);
666 conf.
add(
"safety_tresholds", safetyThresholds);
667 conf.
add(
"fdqp_weights", fdqpWeights);
668 conf.
add(
"fdmpc_weights", fdmpcWeights);
670 conf.
add(
"friction", friction);
671 conf.
add(
"leftFootSurface", leftFootSurface);
672 conf.
add(
"rightFootSurface", rightFootSurface);
673 conf.
add(
"torsoBodyName", torsoBodyName);
675 conf.
add(
"admittance");
676 conf(
"admittance").
add(
"cop", copAdmittance);
677 conf(
"admittance").
add(
"useTargetPressure", useTargetPressure);
678 conf(
"admittance").
add(
"df", dfAdmittance);
679 conf(
"admittance").
add(
"df_damping", dfDamping);
680 conf(
"admittance").
add(
"maxVel", copMaxVel);
681 conf(
"admittance").
add(
"velFilterGain", copVelFilterGain);
683 conf.
add(
"zmpcc", zmpcc);
685 conf.
add(
"dcm_tracking");
686 conf(
"dcm_tracking").
add(
"gains");
687 conf(
"dcm_tracking")(
"gains").add(
"prop", dcmPropGain);
688 conf(
"dcm_tracking")(
"gains").add(
"integral", dcmIntegralGain);
689 conf(
"dcm_tracking")(
"gains").add(
"deriv", dcmDerivGain);
690 conf(
"dcm_tracking")(
"gains").add(
"comdError", comdErrorGain);
691 conf(
"dcm_tracking")(
"gains").add(
"zmpd", zmpdGain);
692 conf(
"dcm_tracking").
add(
"derivator_cutoff_period", dcmDerivatorTimeConstant);
693 conf(
"dcm_tracking").
add(
"integrator_time_constant", dcmIntegratorTimeConstant);
695 conf.
add(
"dcm_bias", dcmBias);
696 conf.
add(
"external_wrench", extWrench);
699 conf(
"tasks").
add(
"com");
700 conf(
"tasks")(
"com").add(
"active_joints", comActiveJoints);
701 conf(
"tasks")(
"com").add(
"stiffness", comStiffness);
702 conf(
"tasks")(
"com").add(
"weight", comWeight);
703 conf(
"tasks")(
"com").add(
"dimWeight", comDimWeight);
704 conf(
"tasks")(
"com").add(
"height", comHeight);
706 conf(
"tasks").
add(
"torso");
707 conf(
"tasks")(
"torso").add(
"pitch", torsoPitch);
708 conf(
"tasks")(
"torso").add(
"stiffness", torsoStiffness);
709 conf(
"tasks")(
"torso").add(
"weight", torsoWeight);
710 conf(
"tasks")(
"torso").add(
"dimWeight", torsoDimWeight);
712 conf(
"tasks").
add(
"pelvis");
713 conf(
"tasks")(
"pelvis").add(
"stiffness", pelvisStiffness);
714 conf(
"tasks")(
"pelvis").add(
"weight", pelvisWeight);
715 conf(
"tasks")(
"pelvis").add(
"dimWeight", pelvisDimWeight);
717 conf(
"tasks").
add(
"contact");
718 conf(
"tasks")(
"contact").add(
"damping", contactDamping);
719 conf(
"tasks")(
"contact").add(
"stiffness", contactStiffness);
720 conf(
"tasks")(
"contact").add(
"weight", contactWeight);
723 conf(
"vdc").
add(
"frequency", vdcFrequency);
724 conf(
"vdc").
add(
"stiffness", vdcStiffness);
745 return stabiConf.
save();
double MAX_DF_ADMITTANCE
Definition: StabilizerConfiguration.h:107
Simplify access to values hold within a JSON file.
Definition: Configuration.h:165
std::string torsoBodyName
Definition: StabilizerConfiguration.h:483
static mc_rtc::Configuration save(const mc_rbdyn::lipm_stabilizer::FDMPCWeights &weights)
Definition: StabilizerConfiguration.h:359
mc_rbdyn::lipm_stabilizer::ExternalWrenchConfiguration ExternalWrenchConfiguration
Definition: StabilizerTask.h:41
void load(const mc_rtc::Configuration &config)
Definition: StabilizerConfiguration.h:72
double MAX_DCM_D_GAIN
Definition: StabilizerConfiguration.h:102
double MIN_DS_PRESSURE
Definition: StabilizerConfiguration.h:112
void silence() const noexcept
void clampInPlaceAndWarn(double &value, double lower, double upper, const std::string &label)
Definition: clamp.h:69
bool excludeFromDCMBiasEst
Definition: StabilizerConfiguration.h:276
bool addExpectedCoMOffset
Definition: StabilizerConfiguration.h:265
static mc_rbdyn::lipm_stabilizer::FDQPWeights load(const mc_rtc::Configuration &config)
Definition: StabilizerConfiguration.h:336
FDMPCWeights(double cop, double copReg, double copDiff)
Definition: StabilizerConfiguration.h:62
double MAX_FDC_RZ_VEL
Definition: StabilizerConfiguration.h:111
double zmpMeasureErrorStd
the standard deviaiton of the zmp estimation error [m]
Definition: StabilizerConfiguration.h:173
double ankleTorqueSqrt
Definition: StabilizerConfiguration.h:30
bool withDCMFilter
Whether the DCM filter is enabled.
Definition: StabilizerConfiguration.h:183
bool correctCoMPos
Definition: StabilizerConfiguration.h:187
double copDiff_
Definition: StabilizerConfiguration.h:70
void load(const mc_rtc::Configuration &config)
Definition: StabilizerConfiguration.h:117
void load(const mc_rtc::Configuration &config)
Definition: StabilizerConfiguration.h:527
double MAX_DCM_I_GAIN
Definition: StabilizerConfiguration.h:103
mc_rtc::Configuration save() const
Definition: StabilizerConfiguration.h:145
std::vector< std::string > comActiveJoints
Definition: StabilizerConfiguration.h:473
mc_rbdyn::lipm_stabilizer::FDQPWeights FDQPWeights
Definition: StabilizerTask.h:38
std::string leftFootSurface
Definition: StabilizerConfiguration.h:445
FDMPCWeights()
Definition: StabilizerConfiguration.h:55
mc_rtc::Configuration save() const
Definition: StabilizerConfiguration.h:661
Definition: ZMPCCConfiguration.h:14
mc_rtc::Configuration save() const
Definition: StabilizerConfiguration.h:41
StabilizerConfiguration()
Definition: StabilizerConfiguration.h:504
StabilizerConfiguration(const mc_rtc::Configuration &conf)
Definition: StabilizerConfiguration.h:506
bool correctDCM
Whether the estimated bias should be used on the dcm.
Definition: StabilizerConfiguration.h:189
double MAX_COP_ADMITTANCE
Definition: StabilizerConfiguration.h:101
static mc_rtc::Configuration save(const mc_rbdyn::lipm_stabilizer::DCMBiasEstimatorConfiguration &bias)
Definition: StabilizerConfiguration.h:394
Definition: StabilizerConfiguration.h:167
bool has(const std::string &key) const
Check if the key is part of the conf.
void clampGains()
Checks that the chosen parameters are within the parameters defined by the SafetyThresholds.
Definition: StabilizerConfiguration.h:512
static mc_rbdyn::lipm_stabilizer::StabilizerConfiguration load(const mc_rtc::Configuration &config)
Definition: StabilizerConfiguration.h:736
bool modifyCoMErr
Modify CoM depending on the error of the external wrenches in target and measurement.
Definition: StabilizerConfiguration.h:269
static mc_rtc::Configuration save(const mc_rbdyn::lipm_stabilizer::StabilizerConfiguration &stabiConf)
Definition: StabilizerConfiguration.h:743
bool modifyZMPErr
Modify ZMP depending on the error of the external wrenches in target and measurement.
Definition: StabilizerConfiguration.h:271
double copRegulation_
Definition: StabilizerConfiguration.h:69
mc_rbdyn::lipm_stabilizer::SafetyThresholds SafetyThresholds
Definition: StabilizerTask.h:39
DCMBiasEstimatorConfiguration dcmBias
Definition: StabilizerConfiguration.h:500
static mc_rtc::Configuration save(const mc_rbdyn::lipm_stabilizer::SafetyThresholds &safety)
Definition: StabilizerConfiguration.h:375
ZMPCCConfiguration zmpcc
Definition: StabilizerConfiguration.h:457
static mc_rtc::Configuration save(const mc_rbdyn::lipm_stabilizer::FDQPWeights &weights)
Definition: StabilizerConfiguration.h:343
double comOffsetLowPassCutoffPeriod
Cutoff period for the low-pass filter of CoM offset.
Definition: StabilizerConfiguration.h:284
static mc_rbdyn::lipm_stabilizer::SafetyThresholds load(const mc_rtc::Configuration &config)
Definition: StabilizerConfiguration.h:368
FDQPWeights()
Definition: StabilizerConfiguration.h:24
void load(const mc_rtc::Configuration &config)
Definition: StabilizerConfiguration.h:34
void load(const mc_rtc::Configuration &config)
Definition: ZMPCCConfiguration.h:22
void add(const std::string &key, bool value)
Add a bool element to the Configuration.
mc_rtc::Configuration save() const
Definition: StabilizerConfiguration.h:306
ExternalWrenchConfiguration extWrench
Definition: StabilizerConfiguration.h:502
double pressureSqrt
Definition: StabilizerConfiguration.h:32
mc_rtc::Configuration save() const
Definition: StabilizerConfiguration.h:204
Definition: StabilizerConfiguration.h:52
double cop_
Definition: StabilizerConfiguration.h:68
double MIN_NET_TOTAL_FORCE_ZMP
Definition: StabilizerConfiguration.h:115
void load(const mc_rtc::Configuration &config)
Definition: StabilizerConfiguration.h:191
double MAX_DCM_P_GAIN
Definition: StabilizerConfiguration.h:104
double comOffsetDerivatorTimeConstant
Time window for the stationary offset filter of the CoM offset derivator.
Definition: StabilizerConfiguration.h:288
Exception thrown by this class when something bad occurs.
Definition: Configuration.h:223
#define MC_RBDYN_DLLAPI
Definition: api.h:50
void warning(Args &&... args)
Definition: logging.h:69
Eigen::Vector2d comBiasLimit
Maximum bias in the sagital and lateral directions used to correct the CoM, should be smaller than bi...
Definition: StabilizerConfiguration.h:179
Stabilizer safety thresholds.
Definition: StabilizerConfiguration.h:98
double extWrenchSumLowPassCutoffPeriod
Cutoff period for the low-pass filter of the sum of the measured external wrenches.
Definition: StabilizerConfiguration.h:282
double clamp(double value, double lower, double upper)
Definition: clamp.h:29
double MAX_FDC_RX_VEL
Definition: StabilizerConfiguration.h:109
bool subtractMeasuredValue
Subtract the measured external wrenches instead of target ones.
Definition: StabilizerConfiguration.h:267
bool withDCMBias
Whether the DCM bias estimator is enabled (default: false for backwards compatibility)
Definition: StabilizerConfiguration.h:181
Parameters for the external wrenches.
Definition: StabilizerConfiguration.h:260
std::string rightFootSurface
Definition: StabilizerConfiguration.h:446
EIGEN_MAKE_ALIGNED_OPERATOR_NEW double dcmMeasureErrorStd
the standard deviation of the dcm estimation error, NOT including the bias [m]
Definition: StabilizerConfiguration.h:171
static mc_rbdyn::lipm_stabilizer::FDMPCWeights load(const mc_rtc::Configuration &config)
Definition: StabilizerConfiguration.h:352
Definition: StabilizerConfiguration.h:22
static mc_rtc::Configuration save(const mc_rbdyn::lipm_stabilizer::ExternalWrenchConfiguration &extWrench)
Definition: StabilizerConfiguration.h:413
FDQPWeights fdqpWeights
Definition: StabilizerConfiguration.h:441
double MAX_AVERAGE_DCM_ERROR
Definition: StabilizerConfiguration.h:100
double comOffsetErrCoMLimit
Limit of CoM offset error handled by CoM modification.
Definition: StabilizerConfiguration.h:278
SafetyThresholds safetyThresholds
Definition: StabilizerConfiguration.h:440
double MAX_FDC_RY_VEL
Definition: StabilizerConfiguration.h:110
double comOffsetLowPassCoMCutoffPeriod
Cutoff period for the low-pass filter of CoM offset to extract CoM modification.
Definition: StabilizerConfiguration.h:286
FDQPWeights(double netWrench, double ankleTorque, double pressure)
Definition: StabilizerConfiguration.h:26
MC_RTC_UTILS_DLLAPI void deprecated(const std::string &source, const std::string &old, const std::string &replace)
mc_rtc::Configuration save() const
Definition: StabilizerConfiguration.h:79
Configuration of the LIPMStabilizer. This configuration is meant to be overriden from the RobotModule...
Definition: StabilizerConfiguration.h:434
FDMPCWeights fdmpcWeights
Definition: StabilizerConfiguration.h:442
double MAX_DF_DAMPING
Definition: StabilizerConfiguration.h:108
bool modifyZMPErrD
Modify ZMP velocity depending on the error velocity of the external wrenches in target and measuremen...
Definition: StabilizerConfiguration.h:273
Definition: generic_gripper.h:14
double netWrenchSqrt
Definition: StabilizerConfiguration.h:31
mc_rbdyn::lipm_stabilizer::DCMBiasEstimatorConfiguration DCMBiasEstimatorConfiguration
Definition: StabilizerTask.h:40
double comOffsetErrZMPLimit
Limit of CoM offset error handled by ZMP modification [m].
Definition: StabilizerConfiguration.h:280
Definition: Configuration.h:55
Eigen::Vector2d biasLimit
Maximum bias in the sagital and lateral directions [m].
Definition: StabilizerConfiguration.h:177
static mc_rbdyn::lipm_stabilizer::ExternalWrenchConfiguration load(const mc_rtc::Configuration &config)
Definition: StabilizerConfiguration.h:406
double MAX_ZMPD_GAIN
Definition: StabilizerConfiguration.h:106
double biasDriftPerSecondStd
the standard deviation of the drift [m/s]
Definition: StabilizerConfiguration.h:175
double MAX_COMD_GAIN
Definition: StabilizerConfiguration.h:105
mc_rbdyn::lipm_stabilizer::StabilizerConfiguration StabilizerConfiguration
Definition: StabilizerTask.h:37
void load(const mc_rtc::Configuration &config)
Definition: StabilizerConfiguration.h:290
static mc_rbdyn::lipm_stabilizer::DCMBiasEstimatorConfiguration load(const mc_rtc::Configuration &config)
Definition: StabilizerConfiguration.h:387