ExternalPlanner.h
Go to the documentation of this file.
1 #pragma once
2 #include <mc_control/MCController.h>
3 
4 #include <ExternalFootstepPlanner/Plan.h>
5 #include <ExternalFootstepPlanner/Request.h>
8 
9 namespace mc_control
10 {
11 struct MCController;
12 } // namespace mc_control
13 
14 namespace lipm_walking
15 {
16 
24 {
26  using Request = mc_plugin::ExternalFootstepPlanner::Request;
27  using Foot = mc_plugin::ExternalFootstepPlanner::Foot;
28 
29  enum State
30  {
34  };
35 
36  ExternalPlanner(mc_control::MCController & ctl);
37 
43  void configure(const mc_rtc::Configuration & config);
44 
45  bool planningRequested() const
46  {
47  return ctl_.datastore().call<bool>("ExternalFootstepPlanner::PlanningRequested");
48  }
49 
50  // clang-format off
82  // clang-format on
83  void requestPlan(const State state,
84  const Foot supportFoot,
85  const utils::SE2d & start_lf,
86  const utils::SE2d & start_rf,
87  double allowed_time);
88 
90  {
91  // FIXME should handle cancelling the request on the planner side
92  requested_ = false;
93  }
94 
95  bool planRequested(State state) const noexcept
96  {
97  return state_ == state && requested_;
98  }
99 
100  bool hasPlan(State state) const
101  {
102  return state_ == state && ctl_.datastore().call<bool>("ExternalFootstepPlanner::HasPlan");
103  }
104 
110  std::vector<lipm_walking::Contact> plan();
111 
112  State state() const
113  {
114  return state_;
115  }
116 
125  void leftFootLandingOffset(const SE2d & offset)
126  {
127  leftFootLandingOffset_ = offset;
128  }
129 
130  void rightFootLandingOffset(const SE2d & offset)
131  {
132  rightFootLandingOffset_ = offset;
133  }
134 
135  void allowedTimeSingleSupport(const double time)
136  {
138  }
139 
140  double allowedTimeSingleSupport() const noexcept
141  {
143  }
144 
145  void allowedTimeStanding(const double time)
146  {
147  allowedTimeStanding_ = time;
148  }
149 
150  double allowedTimeStanding() const noexcept
151  {
152  return allowedTimeStanding_;
153  }
154 
155  void activate()
156  {
157  ctl_.datastore().call<void>("ExternalFootstepPlanner::Activate");
158  }
159 
160  void deactivate()
161  {
162  ctl_.datastore().call<void>("ExternalFootstepPlanner::Deactivate");
163  }
164 
165 protected:
172  const Foot supportFoot,
173  const utils::SE2d & start_lf,
174  const utils::SE2d & start_rf,
175  const utils::SE2d & targetWorld,
176  double allowed_time);
177 
187  const Foot supportFoot,
188  const utils::SE2d & start_lf,
189  const utils::SE2d & start_rf,
190  const utils::SE2d & localTarget,
191  double allowed_time);
192 
193 protected:
194  mc_control::MCController & ctl_;
195  State state_ = State::Standing;
196  bool requested_ = false;
198  double allowedTimeStanding_ = 2.0;
199 
209 };
210 
211 } // namespace lipm_walking
utils::SE2d SE2d
Handle requesting/receiving a footstep plan from an external planner.
void leftFootLandingOffset(const SE2d &offset)
Offset between the left foot and the world target frame, expressed in world target frame.
void requestPlanLocalPositionTarget(const State state, const Foot supportFoot, const utils::SE2d &start_lf, const utils::SE2d &start_rf, const utils::SE2d &localTarget, double allowed_time)
Request a plan in local frame.
void requestPlan(const State state, const Foot supportFoot, const utils::SE2d &start_lf, const utils::SE2d &start_rf, double allowed_time)
Request a plan to the plugin.
ExternalPlanner(mc_control::MCController &ctl)
double allowedTimeSingleSupport() const noexcept
bool planRequested(State state) const noexcept
mc_plugin::ExternalFootstepPlanner::Request Request
void allowedTimeSingleSupport(const double time)
void configure(const mc_rtc::Configuration &config)
External planning configuration.
void rightFootLandingOffset(const SE2d &offset)
void allowedTimeStanding(const double time)
bool hasPlan(State state) const
mc_control::MCController & ctl_
void requestPlanWorldPositionTarget(const State state, const Foot supportFoot, const utils::SE2d &start_lf, const utils::SE2d &start_rf, const utils::SE2d &targetWorld, double allowed_time)
Request a plan with a target expressed in world frame.
mc_plugin::ExternalFootstepPlanner::Foot Foot
std::vector< lipm_walking::Contact > plan()
Convert plugin's plan to lipm_walking plan format.
SE2d leftFootLandingOffset_
Landing offset of the feet w.r.t target frame, expressed in target frame.
double allowedTimeStanding() const noexcept