00001
00007 #ifndef JWALK_H
00008 #define JWALK_H
00009
00010 #include "sensors.h"
00011 #include "actuators.h"
00012 #include "nuwalk.h"
00013 #include "alwalk.h"
00014
00015 #include "../script.h"
00016
00017 using namespace std;
00018
00019 namespace AL
00020 {
00021 class ALBroker;
00022 }
00023
00024 #define JWALK_STANDALONE 1 // set this to 1, to make JWalk a standalone AL::ALModule
00025 #define JWALK_OPTIMISER 1
00026 #define JWALK_ALMOTION 0
00027
00028 #define JWalk_VERSION_MAJOR "0"
00029 #define JWalk_VERSION_MINOR "0"
00030
00031 #if JWALK_STANDALONE
00032 class JWalk : public AL::ALModule
00033 #else
00034 class JWalk
00035 #endif
00036 {
00037 public:
00038 #if JWALK_STANDALONE
00039 JWalk(AL::ALPtr<AL::ALBroker> pBroker, const string& pName);
00040 #else
00041 JWalk();
00042 #endif
00043 virtual ~JWalk();
00044
00045 void initWalk();
00046
00047
00048 bool canUseHead();
00049 bool usingDCM();
00050 bool modeUsesDCM(JWalkModeEnum mode);
00051 int setHeadYaw(float angle, int time);
00052 int setHeadPitch(float angle, int time);
00053 void setHeadStiffness(float values[]);
00054
00055
00056 bool walkIsActive();
00057 void waitUntilFinished();
00058 void stop();
00059 void emergencyStop();
00060 void braceForImpact();
00061 void getUp();
00062 int doScript(script scripttorun, bool scripturgent);
00063 void enableFallingControl();
00064 void disableFallingControl();
00065 void checkAndRepair();
00066 int checkHealth();
00067
00068
00069 void nuWalkOnBearing(float bearing, unsigned char speed, bool dodge=false);
00070 void nuWalkToPoint(float distance, float bearing, bool dodge=false);
00071 void nuWalkToPointWithOrientation(float distance, float bearing, float finalorientation, bool dodge=false);
00072 void nuWalkToPointWithMaintainOrientation(float distance, float bearing, float desiredorientation, bool dodge=false);
00073
00074 bool nuWalkIsActive();
00075 void nuWalkStop();
00076
00077
00078 void gForward();
00079 void gBackward();
00080 void gArc(float direction);
00081 void gLeft();
00082 void gRight();
00083 void gTurnLeft();
00084 void gTurnRight();
00085 bool gIsActive();
00086 void gStop();
00087
00088
00089 void alWalkStraight(float distance);
00090 void alWalkArc(float angle, float radius);
00091 void alWalkSideways(float distance);
00092 void alWalkTurn(float angle);
00093 bool alWalkIsActive();
00094 void alWalkWaitUntilFinished();
00095 void alWalkStop();
00096
00097 int getInCommonPose();
00098 bool inCommonPose();
00099 bool inBackwardBracePose();
00100 void doPreviousWalkCall();
00101
00102 #if JWALK_STANDALONE // These functions need to be implemented when inheriting from ALModule
00103 string version();
00104 bool innerTest();
00105 #endif
00106 public:
00107 Sensors* volatile JWalkSensors;
00108 Actuators* volatile JWalkActuators;
00109 NUWalk* volatile nuWalk;
00110 ALWalk* volatile alWalk;
00111
00112 JWalkModeEnum JWalkPreviousMode;
00113 JWalkModeEnum JWalkMode;
00114 JWalkModeEnum JWalkNextMode;
00115
00116 bool JWalkWaitingForFinish;
00117 JWalkFunctionIDEnum JWalkFunctionID;
00118 float JWalkParam1, JWalkParam2, JWalkParam3;
00119
00120 float* JWalkCommonPositions;
00121 float* JWalkCommonHardnesses;
00122 private:
00123 void initSelf();
00124 void initAldebaranProxies();
00125 void initThreads();
00126 void onDCMPostProcess();
00127
00128 void changeModes(JWalkModeEnum nextmode);
00129 #if JWALK_STANDALONE // as a temporary patch for the poor organisation of locomotion and jwalk, I am adding the getup scripts to jwalk itself
00130 script *getUpBack, *getUpFront, *getUpBackFall;
00131 #endif
00132 };
00133
00134 #endif