30 #include <mc_control/api.h>
31 #include <mc_control/fsm/Controller.h>
32 #include <mc_control/mc_controller.h>
33 #include <mc_planning/Pendulum.h>
34 #include <mc_rtc/logging.h>
35 #include <mc_tasks/SurfaceTransformTask.h>
36 #include <mc_tasks/lipm_stabilizer/StabilizerTask.h>
60 struct MC_CONTROL_DLLAPI
Controller :
public mc_control::fsm::Controller
62 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
75 const mc_rtc::Configuration & config,
76 mc_control::ControllerParameters params = {});
83 void reset(
const mc_control::ControllerResetData & data)
override;
90 void addGUIElements(std::shared_ptr<mc_rtc::gui::StateBuilder> gui);
104 void addLogEntries(mc_rtc::Logger & logger);
111 void leftFootRatio(
double ratio);
118 void loadFootstepPlan(std::string name);
120 void updatePlan(
const std::string & name);
127 void pauseWalkingCallback(
bool verbose =
false);
132 virtual bool run()
override;
139 void startLogSegment(
const std::string & label);
144 void stopLogSegment();
149 bool updatePreview();
154 void warnIfRobotIsInTheAir();
161 return mc_control::fsm::Controller::robot();
170 if(doubleSupportDurationOverride_ > 0.)
172 duration = doubleSupportDurationOverride_;
173 doubleSupportDurationOverride_ = -1.;
177 duration = plan.doubleSupportDuration();
187 return (supportContact().
id > targetContact().
id);
195 return (targetContact().
id > nextContact().
id);
203 return leftFootRatio_;
211 double leftFootPressure = realRobot().forceSensor(
"LeftFootForceSensor").force().z();
212 double rightFootPressure = realRobot().forceSensor(
"RightFootForceSensor").force().z();
213 leftFootPressure = std::max(0., leftFootPressure);
214 rightFootPressure = std::max(0., rightFootPressure);
215 return leftFootPressure / (leftFootPressure + rightFootPressure);
231 return plan.nextContact();
241 doubleSupportDurationOverride_ = duration;
257 return plan.prevContact();
265 return plan.singleSupportDuration();
279 std::shared_ptr<mc_tasks::lipm_stabilizer::StabilizerTask>
stabilizer()
285 void setContacts(
const std::vector<std::pair<mc_tasks::lipm_stabilizer::ContactState, sva::PTransformd>> & contacts,
286 bool fullDoF =
false);
293 return plan.supportContact();
301 return plan.targetContact();
305 bool isInOpenLoopTicker()
const;
313 bool emergencyStop =
false;
314 bool startWalking =
false;
315 bool pauseWalking =
false;
316 bool pauseWalkingRequested =
false;
318 std::vector<std::vector<double>>
323 bool isWalking =
false;
324 unsigned nbMPCFailures_ = 0;
327 std::shared_ptr<mc_tasks::lipm_stabilizer::StabilizerTask> stabilizer_;
328 mc_rbdyn::lipm_stabilizer::StabilizerConfiguration
329 defaultStabilizerConfig_;
331 mc_rtc::Configuration mpcConfig_;
335 double ctlTime_ = 0.;
336 double doubleSupportDurationOverride_ = -1.;
337 double leftFootRatio_ = 0.5;
338 std::string segmentName_ =
"";
339 unsigned nbLogSegments_ = 100;
340 std::string observerPipelineName_ =
"LIPMWalkingObserverPipeline";
mc_planning::Pendulum Pendulum
constexpr double PREVIEW_UPDATE_PERIOD
const Contact & prevContact() const
ModelPredictiveControl & mpc()
void nextDoubleSupportDuration(double duration)
mc_rbdyn::Robot & controlRobot()
double doubleSupportDuration()
double measuredLeftFootRatio()
const Contact & targetContact()
std::shared_ptr< mc_tasks::lipm_stabilizer::StabilizerTask > stabilizer()
const Contact & nextContact() const
const Contact & supportContact()
std::vector< std::vector< double > > halfSitPose
std::shared_ptr< mc_tasks::SurfaceTransformTask > swingFootTaskLeft_
const Sole & sole() const
std::shared_ptr< Preview > preview
double singleSupportDuration()
void addGUIMarkers(std::shared_ptr< mc_rtc::gui::StateBuilder > gui)
mc_planning::Pendulum & pendulum()
PlanInterpolator planInterpolator
std::shared_ptr< mc_tasks::SurfaceTransformTask > swingFootTaskRight_
ExternalPlanner externalFootstepPlanner
Handle requesting/receiving plans from an external planner.
Handle requesting/receiving a footstep plan from an external planner.
static constexpr EIGEN_MAKE_ALIGNED_OPERATOR_NEW double SAMPLING_PERIOD