37 double phaseDuration = ctl.doubleSupportDuration();
39 duration_ = phaseDuration;
40 initLeftFootRatio_ = ctl.leftFootRatio();
41 remTime_ = (phaseDuration > ctl.timeStep) ? phaseDuration : -ctl.timeStep;
43 stopDuringThisDSP_ = ctl.pauseWalking;
44 if(phaseDuration > ctl.timeStep)
50 timeSinceLastPreviewUpdate_ = 0.;
53 const std::string & targetSurfaceName = ctl.targetContact().surfaceName;
54 auto actualTargetPose = ctl.controlRobot().surfacePose(targetSurfaceName);
55 ctl.plan.goToNextFootstep(actualTargetPose);
58 stopDuringThisDSP_ =
true;
62 if(ctl.prevContact().surfaceName ==
"LeftFootCenter")
66 targetLeftFootRatio_ = 0.;
72 targetLeftFootRatio_ = 1.;
74 if(stopDuringThisDSP_)
76 targetLeftFootRatio_ = 0.5;
80 logger().addLogEntry(
"rem_phase_time", [
this]() {
return remTime_; });
81 logger().addLogEntry(
"support_xmax",
82 [&ctl]() {
return std::max(ctl.prevContact().xmax(), ctl.supportContact().xmax()); });
83 logger().addLogEntry(
"support_xmin",
84 [&ctl]() {
return std::min(ctl.prevContact().xmin(), ctl.supportContact().xmin()); });
85 logger().addLogEntry(
"support_ymax",
86 [&ctl]() {
return std::max(ctl.prevContact().ymax(), ctl.supportContact().ymax()); });
87 logger().addLogEntry(
"support_ymin",
88 [&ctl]() {
return std::min(ctl.prevContact().ymin(), ctl.supportContact().ymin()); });
89 logger().addLogEntry(
"support_zmax",
90 [&ctl]() {
return std::max(ctl.prevContact().zmax(), ctl.supportContact().zmax()); });
91 logger().addLogEntry(
"support_zmin",
92 [&ctl]() {
return std::min(ctl.prevContact().zmin(), ctl.supportContact().zmin()); });
93 logger().addLogEntry(
"walking_phase", []() {
return 2.; });
95 if(stopDuringThisDSP_)
97 ctl.pauseWalking =
false;
107 logger().removeLogEntry(
"rem_phase_time");
108 logger().removeLogEntry(
"support_xmax");
109 logger().removeLogEntry(
"support_xmin");
110 logger().removeLogEntry(
"support_ymax");
111 logger().removeLogEntry(
"support_ymin");
112 logger().removeLogEntry(
"support_zmax");
113 logger().removeLogEntry(
"support_zmin");
114 logger().removeLogEntry(
"walking_phase");
120 double dt = ctl.timeStep;
128 double x =
clamp(remTime_ / duration_, 0., 1.);
129 ctl.leftFootRatio(x * initLeftFootRatio_ + (1. - x) * targetLeftFootRatio_);
131 ctl.preview->integrate(
pendulum(), dt);
138 timeSinceLastPreviewUpdate_ += dt;
144 if(!stopDuringThisDSP_ && remTime_ < 0.)
146 output(
"SingleSupport");
149 if(stopDuringThisDSP_ && remTime_ < -0.5)
153 ctl.plan.restorePreviousFootstep();
164 ctl.mpc().contacts(ctl.prevContact(), ctl.supportContact(), ctl.targetContact());
165 if(stopDuringThisDSP_)
167 ctl.mpc().phaseDurations(0., remTime_, 0.);
171 ctl.mpc().phaseDurations(0., remTime_, ctl.singleSupportDuration());
173 if(ctl.updatePreview())
175 timeSinceLastPreviewUpdate_ = 0.;
179 LOG_WARNING(
"No capture trajectory, resuming walking");
180 stopDuringThisDSP_ =
false;
double clamp(double v, double vMin, double vMax)
Clamp a value in a given interval.
ContactState contactState()
Get contact state.
Pendulum & pendulum()
Get pendulum reference.
void addTasks(mc_solver::QPSolver &solver)
Add tasks to QP solver.
void updatePreview()
Update horizontal MPC preview.
void completeIPM(const Contact &plane)
Complete inverted pendulum inputs (ZMP and natural frequency) from contact plane. ...
void run()
Update QP task targets.
Stabilizer & stabilizer()
Get stabilizer.
void runState() override
Main state function, called if no transition at this cycle.
void resetCoMHeight(double height, const Contact &contact)
Reset CoM height above a given contact plane.
constexpr double PREVIEW_UPDATE_PERIOD
Preview update period, same as MPC sampling period.
void start() override
Start state.
mc_rtc::Logger & logger()
Get logger.
void setContact(std::shared_ptr< mc_tasks::force::CoPTask > footTask, const Contact &contact)
Configure foot task for contact at a given location.
Main controller namespace.
void removeTasks(mc_solver::QPSolver &solver)
Remove tasks from QP solver.
Controller & controller()
Get controller.
void teardown() override
Teardown state.
bool checkTransitions() override
Check transitions at beginning of control cycle.
Double support phase while walking.