38 mc_rtc::log::info(
"initial config: {}", config_.dump(
true,
true));
39 config_(
"resetFloatingBaseToPlan", resetFloatingBaseToPlan_);
40 config_(
"updateContactFramesToCurrentSurface", updateContactFramesToCurrentSurface_);
41 config_(
"resetPosture", resetPosture_);
42 config_(
"resetPendulumHeight", resetPendulumHeight_);
43 postureTaskIsActive_ =
true;
44 postureTaskWasActive_ =
true;
45 startStandingButton_ =
false;
46 if(
auto autoplayState = config_.find(
"autoplay"))
48 startStanding_ = *autoplayState;
52 startStanding_ = ctl.config()(
"autoplay",
false);
54 mc_rtc::log::info(
"Start standing is {}", startStanding_);
58 logger().addLogEntry(
"walking_phase", []() {
return -2.; });
62 gui()->removeElement({
"Walking",
"Main"},
"Pause walking");
70 logger().removeLogEntry(
"walking_phase");
74 hideStartStandingButton();
80 auto & ctl = controller();
83 postureTaskIsActive_ = (ctl.postureTask->speed().norm() > 1e-2);
84 if(postureTaskIsActive_)
86 hideStartStandingButton();
87 postureTaskWasActive_ =
true;
89 else if(postureTaskWasActive_)
91 showStartStandingButton();
92 postureTaskWasActive_ =
false;
97 showStartStandingButton();
98 postureTaskIsActive_ =
false;
99 startStanding_ =
true;
105 if(startStanding_ && !postureTaskIsActive_)
115 if(!startStandingButton_ && gui())
118 gui()->addElement({
"Walking",
"Main"}, Button(
"Start standing", [
this]() { startStanding_ =
true; }));
119 startStandingButton_ =
true;
125 if(startStandingButton_ && gui())
127 gui()->removeElement({
"Walking",
"Main"},
"Start standing");
128 startStandingButton_ =
false;
134 auto & ctl = controller();
141 if(resetFloatingBaseToPlan_)
143 auto X_0_fb = ctl.supportContact().robotTransform(ctl.controlRobot());
144 ctl.controlRobot().posW(X_0_fb);
145 ctl.realRobot().posW(X_0_fb);
146 if(ctl.controlRobot().mb().joint(0).dof() == 6)
148 ctl.controlRobot().velW(sva::MotionVecd::Zero());
149 ctl.realRobot().velW(sva::MotionVecd::Zero());
154 ctl.loadFootstepPlan(ctl.plan.name);
159 ctl.postureTask->posture(ctl.halfSitPose);
163 ctl.leftFootRatio(0.5);
164 ctl.nbMPCFailures_ = 0;
165 ctl.pauseWalking =
false;
166 ctl.pauseWalkingRequested =
false;
168 if(resetPendulumHeight_)
173 constexpr
double DEFAULT_HEIGHT = 0.8;
174 double lambda = mc_rtc::constants::GRAVITY / DEFAULT_HEIGHT;
175 ctl.pendulum().reset(lambda, ctl.controlRobot().com());
178 ctl.stopLogSegment();
mc_rtc::Logger & logger()
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Controller & controller()
std::shared_ptr< mc_rtc::gui::StateBuilder > gui()
bool checkTransitions() override
void hideStartStandingButton()
void showStartStandingButton()