Go to the documentation of this file.00001 #ifndef STEPPING_DEMO_CLIENT_H
00002 #define STEPPING_DEMO_CLIENT_H
00003
00004 #include <ocra-icub/IcubClient.h>
00005 #include <ocra-recipes/TrajectoryThread.h>
00006 #include <ocra-recipes/ControllerClient.h>
00007
00008 #include <ocra/util/ErrorsHelper.h>
00009
00010 enum COM_SUPPORT_POSITION
00011 {
00012 LEFT_FOOT_XY,
00013 RIGHT_FOOT_XY,
00014 CENTERED_BETWEEN_FEET_XY
00015 };
00016
00017 enum CONTROL_PHASE
00018 {
00019 MOVE_TO_LEFT_SUPPORT,
00020 MOVE_TO_RIGHT_SUPPORT,
00021 MOVE_TO_DOUBLE_SUPPORT,
00022 STEP_FORWARD
00023 };
00024
00025 enum FOOT_CONTACTS
00026 {
00027 LEFT_FOOT,
00028 RIGHT_FOOT
00029 };
00030
00031 enum MOTION_TYPE
00032 {
00033 LEFT_TO_RIGHT,
00034 STATIC_WALKING
00035 };
00036
00037 struct WalkingParams {
00038 double stepLength;
00039 bool firstStepDone;
00040 double stepHeight;
00041 };
00042
00043
00044 class SteppingDemoClient : public ocra_recipes::ControllerClient
00045 {
00046 DEFINE_CLASS_POINTER_TYPEDEFS(SteppingDemoClient)
00047
00048 public:
00049 MOTION_TYPE motionType;
00050
00051 SteppingDemoClient (std::shared_ptr<ocra::Model> modelPtr, const int loopPeriod);
00052 virtual ~SteppingDemoClient ();
00053
00054 protected:
00064 virtual bool initialize();
00065
00069 virtual void release();
00070
00074 virtual void loop();
00075
00076 private:
00077
00078 void staticWalkingLoop();
00079 void leftToRightLoop();
00080
00081 ocra_recipes::TaskConnection::Ptr LeftFootContact_BackLeft;
00082 ocra_recipes::TaskConnection::Ptr LeftFootContact_FrontLeft;
00083 ocra_recipes::TaskConnection::Ptr LeftFootContact_BackRight;
00084 ocra_recipes::TaskConnection::Ptr LeftFootContact_FrontRight;
00085
00086 ocra_recipes::TaskConnection::Ptr RightFootContact_BackLeft;
00087 ocra_recipes::TaskConnection::Ptr RightFootContact_FrontLeft;
00088 ocra_recipes::TaskConnection::Ptr RightFootContact_BackRight;
00089 ocra_recipes::TaskConnection::Ptr RightFootContact_FrontRight;
00090
00096 Eigen::Vector3d getLeftFootPosition();
00097
00103 Eigen::Vector3d getRightFootPosition();
00104
00110 Eigen::Vector3d getCoMPosition();
00111
00122 void positionCoMOver(COM_SUPPORT_POSITION newSupportPos);
00123
00130 bool isBalanced();
00131
00137 void deactivateFootContacts(FOOT_CONTACTS foot);
00138
00144 void activateFootContacts(FOOT_CONTACTS foot);
00145
00153 bool isFootInContact(FOOT_CONTACTS foot);
00154
00160 void pauseFor(double _pauseDuration);
00161
00167 bool pauseFinished();
00168
00180 bool liftFoot(FOOT_CONTACTS foot, bool isLeftFootInContact, bool isRightFootInContact);
00181
00189 bool setDownFoot(FOOT_CONTACTS foot);
00190 void stateMachineWithPauseInDoubleSupport();
00191 void stateMachineWithoutPauseInDoubleSupport();
00192
00193 double pauseTriggerTime;
00194
00195 double pauseDuration;
00196
00197 double currentTime;
00198
00199 bool isPausing;
00200
00201 bool isInLeftSupportMode;
00202
00203 bool isInRightSupportMode;
00204
00205 bool footTrajectoryStarted;
00206
00207 std::shared_ptr<ocra_recipes::TrajectoryThread> leftFoot_TrajThread;
00208 std::shared_ptr<ocra_recipes::TrajectoryThread> rightFoot_TrajThread;
00209 std::shared_ptr<ocra_recipes::TrajectoryThread> com_TrajThread;
00210
00211
00212 Eigen::Vector3d leftFootHome;
00213 Eigen::Vector3d rightFootHome;
00214 Eigen::Vector3d comHome;
00215 Eigen::Vector3d leftFootTarget;
00216 Eigen::Vector3d rightFootTarget;
00217 Eigen::Vector3d nextStep;
00218
00219 Eigen::Vector3d newCoMGoalPosition;
00220
00221
00222 double startTime;
00223 bool getInitialValues;
00224
00225 CONTROL_PHASE currentPhase;
00226 CONTROL_PHASE nextPhase;
00227 bool isMovingCoM;
00228
00229 WalkingParams walkingParams;
00230
00231 };
00232 #endif // STEPPING_DEMO_CLIENT_H