00001 #ifndef ROBOTER_H_ 00002 #define ROBOTER_H_ 00003 00004 //#include "global.h" 00005 #include "Servo.h" 00006 #include "StateSpace.h" 00007 00008 /*************************** 00009 * modes for main function * 00010 ***************************/ 00011 #define MAIN_MODE_STOP 0 // do nothing 00012 #define MAIN_MODE_WALK_POLICY 1 // walk current policy 00013 #define MAIN_MODE_EXPLORE_FEEDBACK 2 // explore environment 00014 #define MAIN_MODE_READ_V24 3 // process serial command 00015 #define MAIN_MODE_LEARN 4 // learning only mode (without walking) 00016 00017 00018 #define LED_POWER 0x00 00019 #define LED_WALK 0x01 00020 #define LED_LEARN 0x02 00021 #define LED_EXPLORATION 0x03 00022 00023 #define SWITCH_WALK 1 00024 #define SWITCH_RANDOM_STATE 2 00025 #define SWITCH_INV_FB_0 3 00026 #define SWITCH_ENABLE_EXPLORATION 4 00027 #define SWITCH_FULL_EXP_AT_START 5 00028 #define SWITCH_V24 6 00029 #define SWITCH_VDBE_EGREEDY 7 00030 #define SWITCH_GAMMA 8 00031 00032 // possible future pin assignments 00033 #define SWITCH_RAM 9 00034 #define SWITCH_RAM_VALUE 1 // 1:serial RAM (64kB) - 0:internal memoryRAM (2kB) 00035 //#define SWITCH_V24 8 00036 00037 00038 /************************ 00039 * function prototypes * 00040 ************************/ 00041 struct Controller { 00042 public: 00043 void init(); 00044 void msDelay (int n); 00045 void powerOnLED(unsigned char _ledID, bool _status); 00046 void setDefaultPolicy(); 00047 void gotoStateWithoutSavingFeedback(unsigned char _row, unsigned char _column); 00048 unsigned char getSwitchState (unsigned char _switch); 00049 void blinkLED (unsigned char led_id, unsigned int count, unsigned int delay); 00050 00051 // Servos 00052 Servo servo_x; 00053 Servo servo_y; 00054 Servo servo_z; 00055 00056 // The state space 00057 StateSpace states; 00058 00059 // the position memory 00060 unsigned char currentX, currentY; 00061 00062 // modes for main function 00063 unsigned char newMainMode; 00064 unsigned char mainMode; 00065 00066 // Autostart 00067 bool autoStart; 00068 00069 void enableV24Interrupt(); 00070 void disableV24Interrupt(); 00071 00072 private: 00073 void initLEDs(); 00074 00075 }; 00076 00077 00078 #endif /*ROBOTER_H_*/