36 auto & supportContact = ctl.supportContact();
37 auto & targetContact = ctl.targetContact();
39 duration_ = ctl.singleSupportDuration();
40 hasUpdatedMPCOnce_ =
false;
41 remTime_ = ctl.singleSupportDuration();
43 timeSinceLastPreviewUpdate_ = 0.;
45 if(supportContact.surfaceName ==
"LeftFootCenter")
47 ctl.leftFootRatio(1.);
54 ctl.leftFootRatio(0.);
65 swingFoot_.
reset(swingFootTask->surfacePose(), targetContact.pose, duration_, ctl.plan.swingHeight());
70 logger().addLogEntry(
"rem_phase_time", [
this]() {
return remTime_; });
71 logger().addLogEntry(
"support_xmax", [&ctl]() {
return ctl.supportContact().xmax(); });
72 logger().addLogEntry(
"support_xmin", [&ctl]() {
return ctl.supportContact().xmin(); });
73 logger().addLogEntry(
"support_ymax", [&ctl]() {
return ctl.supportContact().ymax(); });
74 logger().addLogEntry(
"support_ymin", [&ctl]() {
return ctl.supportContact().ymin(); });
75 logger().addLogEntry(
"support_zmax", [&ctl]() {
return ctl.supportContact().zmax(); });
76 logger().addLogEntry(
"support_zmin", [&ctl]() {
return ctl.supportContact().zmin(); });
77 logger().addLogEntry(
"walking_phase", []() {
return 1.; });
87 logger().removeLogEntry(
"contact_impulse");
88 logger().removeLogEntry(
"rem_phase_time");
89 logger().removeLogEntry(
"support_xmax");
90 logger().removeLogEntry(
"support_xmin");
91 logger().removeLogEntry(
"support_ymax");
92 logger().removeLogEntry(
"support_ymin");
93 logger().removeLogEntry(
"support_zmax");
94 logger().removeLogEntry(
"support_zmin");
95 logger().removeLogEntry(
"walking_phase");
103 output(
"DoubleSupport");
112 double dt = ctl.timeStep;
120 ctl.preview->integrate(
pendulum(), dt);
121 if(hasUpdatedMPCOnce_)
134 timeSinceLastPreviewUpdate_ += dt;
140 auto & targetContact = ctl.targetContact();
141 double dt = ctl.timeStep;
145 bool liftPhase = (remTime_ > duration_ / 3.);
147 if(liftPhase || !touchdownDetected)
150 swingFootTask->targetPose(swingFoot_.
pose());
151 swingFootTask->refVelB(swingFoot_.
vel());
152 swingFootTask->refAccel(swingFoot_.
accel());
165 ctl.mpc().contacts(ctl.supportContact(), ctl.targetContact(), ctl.nextContact());
166 if(ctl.isLastSSP() || ctl.pauseWalking)
168 ctl.nextDoubleSupportDuration(ctl.plan.finalDSPDuration());
169 ctl.mpc().phaseDurations(remTime_, ctl.plan.finalDSPDuration(), 0.);
173 ctl.mpc().phaseDurations(remTime_, ctl.doubleSupportDuration(), ctl.singleSupportDuration());
175 if(ctl.updatePreview())
177 timeSinceLastPreviewUpdate_ = 0.;
178 hasUpdatedMPCOnce_ =
true;
void updateSwingFoot()
Update swing foot target.
ContactState contactState()
Get contact state.
Pendulum & pendulum()
Get pendulum reference.
void addTasks(mc_solver::QPSolver &solver)
Add tasks to QP solver.
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 teardown() override
Teardown state.
bool detectTouchdown(const std::shared_ptr< mc_tasks::force::CoPTask > footTask, const Contact &contact)
Detect foot touchdown based on both force and distance.
void runState() override
Main state function, called if no transition at this cycle.
Single support phase while walking.
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.
std::shared_ptr< mc_tasks::force::CoPTask > leftFootTask
Left foot hybrid position/force control task.
std::shared_ptr< mc_tasks::force::CoPTask > rightFootTask
Right foot hybrid position/force control task.
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.
void setSwingFoot(std::shared_ptr< mc_tasks::force::CoPTask > footTask)
Configure foot task for swinging.
bool checkTransitions() override
Check transitions at beginning of control cycle.
Controller & controller()
Get controller.
void updatePreview()
Update horizontal MPC preview.