00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef NUWALK_H
00011 #define NUWALK_H
00012
00013 #include "jwalkincludes.h"
00014 #include "step.h"
00015 #include "pidcontroller.h"
00016
00017 class Actuators;
00018 class JWalk;
00019
00020 class WalkPrimitive;
00021
00022 struct action_t
00023 {
00024 StepTypeEnum Type;
00025 float Direction;
00026 };
00027
00028 enum GWalkDirectionEnum
00029 {
00030 GWALK_DIRECTION_UNDEFINED,
00031 GWALK_DIRECTION_FORWARD,
00032 GWALK_DIRECTION_BACKWARD,
00033 GWALK_DIRECTION_ARC,
00034 GWALK_DIRECTION_LEFT,
00035 GWALK_DIRECTION_RIGHT,
00036 GWALK_DIRECTION_TURN_LEFT,
00037 GWALK_DIRECTION_TURN_RIGHT,
00038 GWALK_NUM_DIRECTIONS
00039 };
00040
00041 class NUWalk
00042 {
00043 public:
00044 NUWalk(JWalk* pjwalk);
00045 ~NUWalk();
00046
00047
00048 void onBearing(float bearing, bool dodge=false);
00049 void toPoint(float distance, float bearing, bool dodge=false);
00050 void toPointWithOrientation(float distance, float bearing, float finalorientation, bool dodge=false);
00051 void toPointWithMaintainOrientation(float distance, float bearing, float desiredorientation, bool dodge=false);
00052
00053
00054 void goForward();
00055 void goBackward();
00056 void goLeft();
00057 void goRight();
00058 void goTurnLeft();
00059 void goTurnRight();
00060
00061 void doWalk();
00062
00063 bool walkIsActive();
00064 void stop();
00065 void emergencyStop();
00066 private:
00067
00068 void initPrimitives();
00069
00070 void enableWalk();
00071 void determineNextStep();
00072 void selectNextStep(action_t action);
00073 void selectStartStep(action_t action);
00074 void selectNextGStep();
00075 void selectStartGStep();
00076
00077 void avoidObstacles(action_t* action);
00078 void avoidObstaclesForwardWalk(action_t* action);
00079 void avoidObstaclesBackwardWalk(action_t* action);
00080 void avoidObstaclesSidewardWalk(action_t* action);
00081
00082 void avoidCollisions(action_t* action);
00083
00084 void doStopStep();
00085 void selectStopStep();
00086
00087
00088 void getActionOnBearing(action_t* action, float bearing);
00089
00090 void getActionToPoint(action_t* action, float distance, float bearing);
00091 float calculateStraightPathTime();
00092 float calculateArcPathTime();
00093 float calculateBackwardPathTime();
00094 float calculateTurnStopBackwardPathTime();
00095 float calculateSidewardPathTime();
00096 float calculateTurnStopSidewardPathTime();
00097 void setStraightAction(action_t* action);
00098 void setArcAction(action_t* action);
00099 void setBackwardAction(action_t* action);
00100 void setTurnStopBackwardAction(action_t* action);
00101 void setSidewardAction(action_t* action);
00102 void setTurnStopSidewardAction(action_t* action);
00103
00104 void getActionToPointWithOrientation(action_t* action, float distance, float bearing, float finalorientation);
00105 float calculateArcArcPathTime();
00106 float calculateStraightWOrientationPathTime();
00107 float calculateTurnPathTime();
00108 float calculateBackwardWOrientationPathTime();
00109 float calculateSidewardWOrientationPathTime();
00110 void setArcArcAction(action_t* action);
00111 void setStraightWOrientationAction(action_t* action);
00112 void setTurnAction(action_t* action);
00113 void setBackwardWOrientationAction(action_t* action);
00114 void setSidewardWOrientationAction(action_t* action);
00115
00116 void getActionToPointWithMaintainOrientation(action_t* action, float distance, float bearing, float desiredorientation);
00117 float calculateStraightWMaintainPathTime();
00118 float calculateBackwardWMaintainPathTime();
00119 float calculateSidewardWMaintainPathTime();
00120 void setStraightWMaintainAction(action_t* action);
00121 void setBackwardWMaintainAction(action_t* action);
00122 void setSidewardWMaintainAction(action_t* action);
00123
00124 float getPreviousDirection();
00125 float getDesiredDirection(action_t* action);
00126 bool sameSign(float angle1, float angle2);
00127 float wrapAngle(float angle);
00128 public:
00129 float* DefaultPositions;
00130 float* DefaultHardnesses;
00131 Step* CurrentStep;
00132 Step* PreviousStep;
00133 private:
00134 JWalk* jwalk;
00135 Actuators* actuators;
00136
00137 WalkPrimitive* Primitives[TYPE_NUM_TYPES];
00138
00139 float WalkR;
00140 float WalkBearing;
00141 float WalkFinalOrientation;
00142 float WalkDesiredOrientation;
00143 float WalkSpeed;
00144 bool WalkDodge;
00145
00146 float TargetDistance;
00147 float TargetBearing;
00148 float TargetRelativeX;
00149 float TargetRelativeY;
00150 float TargetRelativeOrientation;
00151
00152 float PathStraightSpeed;
00153 float PathBackwardSpeed;
00154 float PathArcSpeed;
00155 float PathSidewardSpeed;
00156 float PathTurnSpeed;
00157 float PathStopTime;
00158
00159 float PathMinArcRadius;
00160 float PathMaxArcRadius;
00161 float PathPositionAccuracy;
00162 float PathBearingAccuracy;
00163 float PathInfPathTime;
00164
00165 GWalkDirectionEnum GWalkDirection;
00166
00167 float* CurrentPositions;
00168 float* CurrentHardnesses;
00169
00170 bool WalkEnabled;
00171 bool WalkWaitingToStop;
00172 bool WalkStopped;
00173 };
00174
00175 #endif
00176