1 #include <mc_control/MCController.h>
2 #include <mc_rtc/gui.h>
4 #include <boost/optional.hpp>
6 #include <ExternalFootstepPlanner/Plan.h>
18 auto planningConf = config(
"allowed_planning_time");
22 if(config.has(
"leftFootLandingOffset"))
24 Eigen::Vector3d offset = config(
"leftFootLandingOffset");
27 if(config.has(
"rightFootLandingOffset"))
29 Eigen::Vector3d offset = config(
"rightFootLandingOffset");
35 const Foot supportFoot,
40 bool worldTargetChanged =
ctl_.datastore().call<
bool>(
"ExternalFootstepPlanner::WorldPositionTargetChanged");
41 bool localVelocityTargetChanged =
ctl_.datastore().call<
bool>(
"ExternalFootstepPlanner::LocalPositionTargetChanged");
42 if(worldTargetChanged && localVelocityTargetChanged)
45 "[ExternalPlanner] Both target position (world) and velocity target (world) changed, using target position");
48 if(worldTargetChanged)
51 "ExternalFootstepPlanner::WorldPositionTarget");
52 const auto goal =
utils::SE2d{target.
x, target.y, target.theta};
58 "ExternalFootstepPlanner::LocalPositionTarget");
59 const auto local_goal =
utils::SE2d{local.
x, local.y, local.theta};
65 const Foot supportFoot,
72 request.start_left_foot = {start_lf.
x, start_lf.
y, start_lf.
theta};
73 request.start_right_foot = {start_rf.
x, start_rf.
y, start_rf.
theta};
79 request.goal_left_foot = {lfGoal.x, lfGoal.y, lfGoal.theta};
80 request.goal_right_foot = {rfGoal.x, rfGoal.y, rfGoal.theta};
81 request.support_foot = supportFoot;
82 request.allowed_time = allowed_time;
84 ctl_.datastore().call<
void>(
"ExternalFootstepPlanner::RequestPlan",
static_cast<const Request &
>(request));
90 const Foot supportFoot,
106 auto convertPlan = [](
const mc_plugin::ExternalFootstepPlanner::Plan & ext_plan)
108 std::vector<lipm_walking::Contact> contacts;
110 for(
const auto & ext_contact : ext_plan.contacts)
115 contact.
surfaceName = (ext_contact.foot == Foot::Right ?
"RightFootCenter" :
"LeftFootCenter");
116 utils::SE2d pose2D = {ext_contact.pose.
x, ext_contact.pose.y, ext_contact.pose.theta};
119 contacts.push_back(contact);
125 auto plan =
ctl_.datastore().call<mc_plugin::ExternalFootstepPlanner::Plan>(
"ExternalFootstepPlanner::PopPlan");
126 return convertPlan(
plan);
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)
mc_plugin::ExternalFootstepPlanner::Request Request
void configure(const mc_rtc::Configuration &config)
External planning configuration.
double allowedTimeStanding_
double allowedTimeSingleSupport_
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.
SE2d rightFootLandingOffset_
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.
sva::PTransformd asPTransform() const