GaitedFootstepMC.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_GaitedFootstepMC_h_
00003 #define INCLUDED_GaitedFootstepMC_h_
00004
00005 #include "Motion/MotionCommand.h"
00006 #include "Motion/MotionManager.h"
00007 #include "Motion/XWalkMC.h"
00008 #include "Planners/GaitedFootsteps.h"
00009 #include "Shared/get_time.h"
00010
00011
00012 class GaitedFootstepMC : public MotionCommand {
00013 public:
00014
00015 GaitedFootstepMC()
00016 : MotionCommand(), xp(), ground(), gravity(), steps(), curStep(0),
00017 xySpeed(fmat::pack(30,30)), aSpeed(0.2f), newStep(false), stepStartTime(0), stepDuration(0), contactMsg()
00018 {
00019 setGait(::config->motion.makePath("xwalk.plist"), true);
00020 if(kine==NULL) {
00021 kine = new KinematicJoint;
00022 kine->loadFile(::config->makePath(config->motion.kinematics).c_str());
00023 kine->buildChildMap(childMap,0,NumReferenceFrames);
00024 }
00025 }
00026
00027 virtual int updateOutputs();
00028 virtual int isDirty() { return curStep+1 < steps.size(); }
00029 virtual int isAlive() { return curStep+1 < steps.size(); }
00030
00031
00032 void setGait(const XWalkParameters& p, bool resetSpeeds=true) {
00033 xp=p;
00034 xp.packGroundGravity(ground,gravity);
00035 if(resetSpeeds)
00036 setSpeed(xp.getMaxXVel(),xp.getMaxYVel(),xp.getMaxAVel());
00037 }
00038
00039
00040 void setGait(const std::string& file, bool resetSpeeds=true) {
00041 xp.loadFile(file.c_str());
00042 if(resetSpeeds)
00043 setSpeed(xp.getMaxXVel(),xp.getMaxYVel(),xp.getMaxAVel());
00044 }
00045
00046
00047 void setSteps(const std::vector<GaitedFootsteps::State>& st) {
00048 steps=st;
00049 stepStartTime = get_time() / 1000.0;
00050 stepDuration = 0;
00051 curStep=-1u;
00052 advanceStep();
00053 }
00054
00055
00056
00057 void setSpeed(fmat::fmatReal x, fmat::fmatReal y, fmat::fmatReal a) {
00058 xySpeed[0]=x; xySpeed[1]=y; aSpeed=a;
00059 }
00060
00061 protected:
00062
00063 fmat::Column<2> curBodyOffset(double t);
00064
00065
00066 bool advanceStep();
00067
00068
00069 void solveIK(unsigned int leg, const IKSolver::Point& tgt);
00070
00071 virtual void doStart() {}
00072 virtual void doStop() {}
00073
00074 XWalkParameters xp;
00075 fmat::Column<3> ground;
00076 fmat::Column<3> gravity;
00077
00078 std::vector<GaitedFootsteps::State> steps;
00079 unsigned int curStep;
00080 fmat::Column<2> xySpeed;
00081 fmat::fmatReal aSpeed;
00082 bool newStep;
00083 double stepStartTime;
00084 double stepDuration;
00085 bool support[NumLegs];
00086 DriverMessaging::FixedPoints contactMsg;
00087
00088 static KinematicJoint* kine;
00089 static KinematicJoint* childMap[NumReferenceFrames];
00090 };
00091
00092
00093
00094
00095
00096
00097 #endif