Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[StabilizerTask] Fix disabling when the robot is in the air #411

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/mc_tasks/lipm_stabilizer/StabilizerTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ struct MC_TASKS_DLLAPI StabilizerTask : public MetaTask
* @param solver Solver to which this task has been added
*/
void configure_(mc_solver::QPSolver & solver);
void disable_();

/** Ensures that the configuration is valid */
void checkConfiguration(const StabilizerConfiguration & config);
Expand Down Expand Up @@ -953,6 +954,8 @@ struct MC_TASKS_DLLAPI StabilizerTask : public MetaTask
mc_filter::ExponentialMovingAverage<Eigen::Vector3d> dcmIntegrator_;
mc_filter::LowPassCompose<Eigen::Vector3d> dcmDerivator_;
bool inTheAir_ = false; /**< Is the robot in the air? */
bool wasInTheAir_ = false; /**< Whether the robot was in the air at the previous iteration */
bool wasEnabled_ = true; /**< Whether the stabilizer was enabled before the robot was in the air */
Eigen::Vector3d dfForceError_ = Eigen::Vector3d::Zero(); /**< Force error in foot force difference control */
Eigen::Vector3d dfError_ = Eigen::Vector3d::Zero(); /**< Height error in foot force difference control */
double dt_ = 0.005; /**< Controller cycle in [s] */
Expand Down
26 changes: 26 additions & 0 deletions src/mc_tasks/lipm_stabilizer/StabilizerTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,18 @@ void StabilizerTask::enable()
configure(lastConfig_);
zmpcc_.enabled(true);
enabled_ = true;
wasEnabled_ = true;
}

void StabilizerTask::disable()
{
mc_rtc::log::info("[StabilizerTask] disabled");
disable_();
wasEnabled_ = false;
}

void StabilizerTask::disable_()
{
// Save current configuration to be reused when re-enabling
lastConfig_ = c_;
disableConfig_ = c_;
Expand Down Expand Up @@ -523,6 +530,25 @@ void StabilizerTask::checkInTheAir()
{
inTheAir_ = inTheAir_ && footT.second->measuredWrench().force().z() < c_.safetyThresholds.MIN_DS_PRESSURE;
}

if(!wasInTheAir_ && inTheAir_)
{
wasInTheAir_ = true;
if(enabled_)
{
mc_rtc::log::warning("[{}] Robot is in the air, disabling stabilizer", name());
disable_();
}
}
else if(!inTheAir_ && wasInTheAir_)
{
wasInTheAir_ = false;
if(wasEnabled_)
{
mc_rtc::log::warning("[{}] Robot is no longer in the air, re-enabling stabilizer", name());
enable();
}
}
}

void StabilizerTask::computeLeftFootRatio()
Expand Down
Loading