├── ReadMe.md ├── Phoenix ├── readme.txt ├── Chr3_RC_SSC32 │ ├── Chr3_RC_SSC32.ino │ └── Hex_Cfg.h ├── THex_PS2_SSC32 │ ├── THex_PS2_SSC32.ino │ └── Hex_Cfg.h ├── Phoenix_PS2_SSC32 │ ├── Phoenix_PS2_SSC32.ino │ └── Hex_Cfg.h ├── THex4_PS2_SSC32 │ ├── THex4_PS2_SSC32.ino │ └── Hex_Cfg.h ├── THex_Serial_SSC32 │ ├── THex_Serial_SSC32.ino │ └── Hex_Cfg.h ├── Chr3_Commander_SSC32 │ └── Chr3_Commander_SSC32.ino ├── PhantomX_DIYXbee_AX12 │ ├── PhantomX_DIYXbee_AX12.ino │ ├── PyPoseTest.ppr │ └── PyPoseGen.h ├── PhantomX_Commander_AX12 │ ├── PhantomX_Commander_AX12.ino │ ├── PyPoseTest.ppr │ └── PyPoseGen.h ├── LSQuadA_PS2_SSC32 │ ├── LSQuadA_PS2_SSC32.ino │ └── Hex_Cfg.h ├── Chr3_PS2_ServoEx │ └── Chr3_PS2_ServoEx.ino ├── PhantomX_Commander_AX12_Stock │ ├── PhantomX_Commander_AX12_Stock.ino │ ├── PyPoseTest.ppr │ └── PyPoseGen.h ├── PhantomX_V2_Commander_AX12_Stock │ └── PhantomX_V2_Commander_AX12_Stock.ino ├── Chr3_PS2_Orion │ ├── Chr3_PS2_Orion.ino │ └── Hex_Cfg.h ├── Mantis_BMPS2_Orion_Stock │ ├── Mantis_BMPS2_Orion_Stock.ino │ └── Quad_Cfg.h ├── PhXQuadV2_Commander_AX12_Stock │ ├── PhXQuadV2_Commander_AX12_Stock.ino │ └── Quad_Cfg.h └── Phoenix.h ├── ServoEx ├── ServoEx.zip ├── examples │ └── Sweep │ │ └── Sweep.pde ├── keywords.txt └── ServoEx.h ├── I2CEEProm ├── I2CEEProm.h ├── keywords.txt └── I2CEEProm.cpp ├── .gitattributes ├── .gitignore ├── Phoenix_Driver_AX12 ├── BioloidEx.h └── BioloidEX.cpp ├── Phoenix_Input_RC ├── PCInt.h └── Phoenix_Input_RC.h └── Phoenix_Input_DIYXbee └── diyxbee.h /ReadMe.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KurtE/Arduino_Phoenix_Parts/HEAD/ReadMe.md -------------------------------------------------------------------------------- /Phoenix/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KurtE/Arduino_Phoenix_Parts/HEAD/Phoenix/readme.txt -------------------------------------------------------------------------------- /ServoEx/ServoEx.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KurtE/Arduino_Phoenix_Parts/HEAD/ServoEx/ServoEx.zip -------------------------------------------------------------------------------- /I2CEEProm/I2CEEProm.h: -------------------------------------------------------------------------------- 1 | #ifndef _I2CEEPROM_h_ 2 | #define _I2CEEPROM_h_ 3 | #include 4 | // SETTINGS 5 | #define EE24LC512MAXBYTES 64000 6 | 7 | class I2CEEPromClass /*: public TwoWire - Change when MPIDE is 1.0 */ 8 | { 9 | public: 10 | void begin(); 11 | 12 | void writeTo(uint16_t, uint8_t); 13 | void writeTo(uint16_t, uint8_t*, uint8_t); 14 | 15 | uint8_t readFrom(uint16_t); 16 | 17 | }; 18 | 19 | extern I2CEEPromClass I2CEEPROM; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /I2CEEProm/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For I2CEEPROM 3 | ####################################### 4 | 5 | ####################################### 6 | # Methods and Functions (KEYWORD2) 7 | ####################################### 8 | 9 | begin KEYWORD2 10 | writeTo KEYWORD2 11 | readFrom KEYWORD2 12 | 13 | ####################################### 14 | # Datatypes (KEYWORD1) 15 | ####################################### 16 | 17 | I2CEEProm KEYWORD1 18 | 19 | ####################################### 20 | # Constants (LITERAL1) 21 | ####################################### 22 | 23 | -------------------------------------------------------------------------------- /ServoEx/examples/Sweep/Sweep.pde: -------------------------------------------------------------------------------- 1 | // Sweep 2 | // by BARRAGAN 3 | // This example code is in the public domain. 4 | // Modified by Kurt to use the ServoEx library 5 | 6 | 7 | #include 8 | 9 | ServoEx myservo; // create servo object to control a servo 10 | // a maximum of eight servo objects can be created 11 | 12 | int pos = 0; // variable to store the servo position 13 | 14 | void setup() 15 | { 16 | myservo.attach(13); // attaches the servo on pin 13 to the servo object 17 | } 18 | 19 | 20 | void loop() 21 | { 22 | if (myservo.moving()) 23 | return; // last move is still active 24 | pos = (pos == 0)? 180 : 0; 25 | myservo.move(pos, 2500); 26 | } 27 | -------------------------------------------------------------------------------- /ServoEx/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map MServo 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ServoEx KEYWORD1 10 | ServoGroupMove KEYWORD1 11 | 12 | ####################################### 13 | # Methods and Functions (KEYWORD2) 14 | ####################################### 15 | attach KEYWORD2 16 | detach KEYWORD2 17 | write KEYWORD2 18 | read KEYWORD2 19 | attached KEYWORD2 20 | writeMicroseconds KEYWORD2 21 | readMicroseconds KEYWORD2 22 | 23 | #new members 24 | move KEYWORD2 25 | moving KEYWORD2 26 | 27 | #ServoGroupMove functions 28 | begin KEYWORD2 29 | commit KEYWORD2 30 | abort KEYWORD2 31 | moving KEYWORD2 32 | wait KEYWORD2 33 | ####################################### 34 | # Constants (LITERAL1) 35 | ####################################### 36 | -------------------------------------------------------------------------------- /Phoenix/Chr3_RC_SSC32/Chr3_RC_SSC32.ino: -------------------------------------------------------------------------------- 1 | 2 | //============================================================================= 3 | //Project Lynxmotion Phoenix 4 | //Description: Phoenix software 5 | //Software version: V2.0 6 | //Date: 29-10-2009 7 | //Programmer: Jeroen Janssen [aka Xan] 8 | // Kurt Eckhardt(KurtE) converted to C and Arduino 9 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 10 | // 11 | // This version of the Phoenix code was ported over to the Arduino Environement 12 | // and is specifically configured for the Lynxmotion BotBoarduino 13 | // 14 | //============================================================================= 15 | // 16 | //KNOWN BUGS: 17 | // - Lots ;) 18 | // 19 | //============================================================================= 20 | // Header Files 21 | //============================================================================= 22 | 23 | #define DEFINE_HEX_GLOBALS 24 | #if ARDUINO>99 25 | #include 26 | #else 27 | #endif 28 | #include 29 | #include 30 | //#include 31 | 32 | #include "Hex_CFG.h" 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | -------------------------------------------------------------------------------- /Phoenix/THex_PS2_SSC32/THex_PS2_SSC32.ino: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Lynxmotion BotBoarduino 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | #include 28 | #include 29 | #include 30 | 31 | #include "Hex_Cfg.h" 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | -------------------------------------------------------------------------------- /Phoenix/Phoenix_PS2_SSC32/Phoenix_PS2_SSC32.ino: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Lynxmotion BotBoarduino 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | #include 28 | #include 29 | #include 30 | 31 | #include "Hex_CFG.h" 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | -------------------------------------------------------------------------------- /Phoenix/THex4_PS2_SSC32/THex4_PS2_SSC32.ino: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Lynxmotion BotBoarduino 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | #include 28 | #include 29 | #include 30 | 31 | #include "Hex_Cfg.h" 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | -------------------------------------------------------------------------------- /Phoenix/THex_Serial_SSC32/THex_Serial_SSC32.ino: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Lynxmotion BotBoarduino 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | #include 28 | #include 29 | #include 30 | 31 | #include "Hex_Cfg.h" 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | -------------------------------------------------------------------------------- /Phoenix/Chr3_Commander_SSC32/Chr3_Commander_SSC32.ino: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Lynxmotion BotBoarduino 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | #include 28 | #include 29 | #include 30 | 31 | #include "Hex_Cfg.h" 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | -------------------------------------------------------------------------------- /Phoenix/PhantomX_DIYXbee_AX12/PhantomX_DIYXbee_AX12.ino: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | #include 28 | #include 29 | #include 30 | 31 | #include "Hex_Cfg.h" 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | -------------------------------------------------------------------------------- /Phoenix/PhantomX_Commander_AX12/PhantomX_Commander_AX12.ino: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | #include 28 | #include 29 | #include 30 | 31 | #include "Hex_Cfg.h" 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | -------------------------------------------------------------------------------- /Phoenix/LSQuadA_PS2_SSC32/LSQuadA_PS2_SSC32.ino: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Lynxmotion BotBoarduino 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include "Hex_CFG.h" 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | -------------------------------------------------------------------------------- /Phoenix/Chr3_PS2_ServoEx/Chr3_PS2_ServoEx.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | //============================================================================= 4 | //Project Lynxmotion Phoenix 5 | //Description: Phoenix software 6 | //Software version: V2.0 7 | //Date: 29-10-2009 8 | //Programmer: Jeroen Janssen [aka Xan] 9 | // Kurt Eckhardt(KurtE) converted to C and Arduino 10 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 11 | // 12 | // This version of the Phoenix code was ported over to the Arduino Environement 13 | // and is specifically configured for the Lynxmotion BotBoarduino 14 | // 15 | //============================================================================= 16 | // 17 | //KNOWN BUGS: 18 | // - Lots ;) 19 | // 20 | //============================================================================= 21 | // Header Files 22 | //============================================================================= 23 | 24 | #define DEFINE_HEX_GLOBALS 25 | #if ARDUINO>99 26 | #include 27 | #else 28 | #endif 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | #include "Hex_Cfg.h" 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | -------------------------------------------------------------------------------- /Phoenix/PhantomX_Commander_AX12_Stock/PhantomX_Commander_AX12_Stock.ino: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // Warning:: This configuration does not check voltages, so you should be careful to 15 | // not allow the lipo to discharge too far. 16 | // 17 | // This configuration should hopefully run on a stock PhantomX, without any 18 | // of my changes. 19 | // 20 | //KNOWN BUGS: 21 | // - Lots ;) 22 | // 23 | //============================================================================= 24 | // Header Files 25 | //============================================================================= 26 | 27 | #define DEFINE_HEX_GLOBALS 28 | #if ARDUINO>99 29 | #include 30 | #else 31 | #endif 32 | #include 33 | #include 34 | #include 35 | 36 | #include "Hex_Cfg.h" 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | -------------------------------------------------------------------------------- /Phoenix/PhantomX_V2_Commander_AX12_Stock/PhantomX_V2_Commander_AX12_Stock.ino: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // Warning:: This configuration does not check voltages, so you should be careful to 15 | // not allow the lipo to discharge too far. 16 | // 17 | // This configuration should hopefully run on a stock PhantomX, without any 18 | // of my changes. 19 | // 20 | //KNOWN BUGS: 21 | // - Lots ;) 22 | // 23 | //============================================================================= 24 | // Header Files 25 | //============================================================================= 26 | 27 | #define DEFINE_HEX_GLOBALS 28 | #if ARDUINO>99 29 | #include 30 | #else 31 | #endif 32 | #include 33 | #include 34 | #include 35 | 36 | #include "Hex_Cfg.h" 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | -------------------------------------------------------------------------------- /I2CEEProm/I2CEEProm.cpp: -------------------------------------------------------------------------------- 1 | // [Include files] 2 | #if ARDUINO>99 3 | #include // Arduino 1.0 4 | #else 5 | #include // Arduino 0022 or 23 6 | #define write send 7 | #define read receive 8 | #endif 9 | #include 10 | #include "i2cEEProm.h" 11 | 12 | I2CEEPromClass I2CEEPROM; 13 | 14 | // ########## SETTINGS ########################################### 15 | #define DEVICEADDRESS 0x50 // 0b0101 0 a2 a1 a0 16 | 17 | // ########## IMPLEMENTATION ##################################### 18 | void I2CEEPromClass::begin() 19 | { 20 | Wire.begin(); 21 | } 22 | // ---------------------------------------------------------------- 23 | void I2CEEPromClass::writeTo(uint16_t wAddr, uint8_t b) 24 | { 25 | 26 | Wire.beginTransmission(DEVICEADDRESS); 27 | Wire.write( (wAddr >> 8) & 0xFF ); 28 | Wire.write( (wAddr >> 0) & 0xFF ); 29 | Wire.write(b); 30 | Wire.endTransmission(); 31 | delay(5); 32 | } 33 | // ---------------------------------------------------------------- 34 | void I2CEEPromClass::writeTo(uint16_t wAddr, uint8_t *pb, uint8_t cb) 35 | { 36 | 37 | Wire.beginTransmission(DEVICEADDRESS); 38 | Wire.write( (wAddr >> 8) & 0xFF ); 39 | Wire.write( (wAddr >> 0) & 0xFF ); 40 | while (cb--) 41 | { 42 | Wire.write(*pb++); 43 | } 44 | Wire.endTransmission(); 45 | delay(5); 46 | } 47 | 48 | // ---------------------------------------------------------------- 49 | uint8_t I2CEEPromClass::readFrom(uint16_t wAddr) 50 | { 51 | uint8_t u8retVal = 0; 52 | Wire.beginTransmission(DEVICEADDRESS); 53 | Wire.write( (wAddr >> 8) & 0xFF ); 54 | Wire.write( (wAddr >> 0) & 0xFF ); 55 | Wire.endTransmission(); 56 | delay(5); 57 | Wire.requestFrom(DEVICEADDRESS, 1); 58 | u8retVal = Wire.read(); 59 | return u8retVal ; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /Phoenix/PhantomX_DIYXbee_AX12/PyPoseTest.ppr: -------------------------------------------------------------------------------- 1 | Test:18:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024 2 | Pose=R4:512, 511, 711, 595, 300, 899, 510, 510, 712, 596, 300, 900, 511, 510, 712, 800, 300, 970 3 | Pose=R5:512, 511, 711, 312, 201, 712, 509, 510, 712, 312, 201, 712, 511, 510, 711, 799, 207, 967 4 | Pose=R6:512, 512, 654, 224, 45, 506, 510, 512, 661, 225, 43, 506, 511, 510, 662, 799, 44, 967 5 | Pose=_Wag_6:511, 511, 297, 710, 113, 906, 628, 326, 260, 777, 368, 940, 663, 327, 306, 682, 62, 958 6 | Pose=_wag_1:512, 514, 280, 696, 50, 924, 492, 509, 280, 730, 42, 979, 509, 513, 273, 708, 47, 967 7 | Pose=R1:513, 513, 226, 796, 52, 971, 510, 510, 229, 795, 50, 970, 511, 510, 227, 796, 52, 970 8 | Pose=R2:512, 511, 226, 594, 52, 899, 509, 510, 229, 596, 50, 900, 511, 510, 428, 800, 124, 970 9 | Pose=R3:512, 511, 712, 595, 197, 899, 510, 510, 711, 596, 200, 900, 511, 510, 550, 800, 242, 970 10 | Pose=_wag_3:511, 512, 296, 710, 113, 906, 492, 509, 280, 730, 42, 981, 663, 327, 308, 682, 47, 967 11 | Pose=_wag_2:511, 511, 311, 696, 112, 920, 492, 508, 280, 731, 42, 979, 665, 326, 182, 795, 47, 967 12 | Pose=_wag_5:511, 512, 300, 710, 114, 906, 639, 331, 267, 779, 52, 651, 663, 327, 308, 682, 62, 962 13 | Pose=_wag_4:511, 512, 312, 712, 113, 906, 645, 331, 267, 772, 254, 767, 663, 327, 308, 682, 47, 967 14 | Pose=_wag_0:547, 514, 286, 719, 51, 935, 488, 509, 230, 788, 17, 977, 491, 518, 234, 723, 0, 921 15 | Seq=Wag: _wag_0|500, _wag_1|500, _wag_2|500, _wag_3|500, _wag_4|500, _wag_5|500, _Wag_6|500, _wag_5|500, _Wag_6|500, _wag_5|500, _Wag_6|500, _wag_5|500, _wag_4|500, _wag_3|500, _wag_2|500, _wag_1|500, _wag_0|500 16 | Seq=Rollover: R1|500, R2|500, R3|500, R4|500, R5|500, R6|500 17 | Nuke=Lizard 3DOF,6,++++++++++++++++++,50,50,50,50,50,50,0,0,2,4,6,1,3,5,14,16,18,13,15,17,8,10,12,7,9,11 18 | -------------------------------------------------------------------------------- /Phoenix/PhantomX_Commander_AX12/PyPoseTest.ppr: -------------------------------------------------------------------------------- 1 | Test:18:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024 2 | Pose=R4:512, 511, 711, 595, 300, 899, 510, 510, 712, 596, 300, 900, 511, 510, 712, 800, 300, 970 3 | Pose=R5:512, 511, 711, 312, 201, 712, 509, 510, 712, 312, 201, 712, 511, 510, 711, 799, 207, 967 4 | Pose=R6:512, 512, 654, 224, 45, 506, 510, 512, 661, 225, 43, 506, 511, 510, 662, 799, 44, 967 5 | Pose=_Wag_6:511, 511, 297, 710, 113, 906, 628, 326, 260, 777, 368, 940, 663, 327, 306, 682, 62, 958 6 | Pose=_wag_1:512, 514, 280, 696, 50, 924, 492, 509, 280, 730, 42, 979, 509, 513, 273, 708, 47, 967 7 | Pose=R1:513, 513, 226, 796, 52, 971, 510, 510, 229, 795, 50, 970, 511, 510, 227, 796, 52, 970 8 | Pose=R2:512, 511, 226, 594, 52, 899, 509, 510, 229, 596, 50, 900, 511, 510, 428, 800, 124, 970 9 | Pose=R3:512, 511, 712, 595, 197, 899, 510, 510, 711, 596, 200, 900, 511, 510, 550, 800, 242, 970 10 | Pose=_wag_3:511, 512, 296, 710, 113, 906, 492, 509, 280, 730, 42, 981, 663, 327, 308, 682, 47, 967 11 | Pose=_wag_2:511, 511, 311, 696, 112, 920, 492, 508, 280, 731, 42, 979, 665, 326, 182, 795, 47, 967 12 | Pose=_wag_5:511, 512, 300, 710, 114, 906, 639, 331, 267, 779, 52, 651, 663, 327, 308, 682, 62, 962 13 | Pose=_wag_4:511, 512, 312, 712, 113, 906, 645, 331, 267, 772, 254, 767, 663, 327, 308, 682, 47, 967 14 | Pose=_wag_0:547, 514, 286, 719, 51, 935, 488, 509, 230, 788, 17, 977, 491, 518, 234, 723, 0, 921 15 | Seq=Wag: _wag_0|500, _wag_1|500, _wag_2|500, _wag_3|500, _wag_4|500, _wag_5|500, _Wag_6|500, _wag_5|500, _Wag_6|500, _wag_5|500, _Wag_6|500, _wag_5|500, _wag_4|500, _wag_3|500, _wag_2|500, _wag_1|500, _wag_0|500 16 | Seq=Rollover: R1|500, R2|500, R3|500, R4|500, R5|500, R6|500 17 | Nuke=Lizard 3DOF,6,++++++++++++++++++,50,50,50,50,50,50,0,0,2,4,6,1,3,5,14,16,18,13,15,17,8,10,12,7,9,11 18 | -------------------------------------------------------------------------------- /Phoenix/PhantomX_Commander_AX12_Stock/PyPoseTest.ppr: -------------------------------------------------------------------------------- 1 | Test:18:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024 2 | Pose=R4:512, 511, 711, 595, 300, 899, 510, 510, 712, 596, 300, 900, 511, 510, 712, 800, 300, 970 3 | Pose=R5:512, 511, 711, 312, 201, 712, 509, 510, 712, 312, 201, 712, 511, 510, 711, 799, 207, 967 4 | Pose=R6:512, 512, 654, 224, 45, 506, 510, 512, 661, 225, 43, 506, 511, 510, 662, 799, 44, 967 5 | Pose=_Wag_6:511, 511, 297, 710, 113, 906, 628, 326, 260, 777, 368, 940, 663, 327, 306, 682, 62, 958 6 | Pose=_wag_1:512, 514, 280, 696, 50, 924, 492, 509, 280, 730, 42, 979, 509, 513, 273, 708, 47, 967 7 | Pose=R1:513, 513, 226, 796, 52, 971, 510, 510, 229, 795, 50, 970, 511, 510, 227, 796, 52, 970 8 | Pose=R2:512, 511, 226, 594, 52, 899, 509, 510, 229, 596, 50, 900, 511, 510, 428, 800, 124, 970 9 | Pose=R3:512, 511, 712, 595, 197, 899, 510, 510, 711, 596, 200, 900, 511, 510, 550, 800, 242, 970 10 | Pose=_wag_3:511, 512, 296, 710, 113, 906, 492, 509, 280, 730, 42, 981, 663, 327, 308, 682, 47, 967 11 | Pose=_wag_2:511, 511, 311, 696, 112, 920, 492, 508, 280, 731, 42, 979, 665, 326, 182, 795, 47, 967 12 | Pose=_wag_5:511, 512, 300, 710, 114, 906, 639, 331, 267, 779, 52, 651, 663, 327, 308, 682, 62, 962 13 | Pose=_wag_4:511, 512, 312, 712, 113, 906, 645, 331, 267, 772, 254, 767, 663, 327, 308, 682, 47, 967 14 | Pose=_wag_0:547, 514, 286, 719, 51, 935, 488, 509, 230, 788, 17, 977, 491, 518, 234, 723, 0, 921 15 | Seq=Wag: _wag_0|500, _wag_1|500, _wag_2|500, _wag_3|500, _wag_4|500, _wag_5|500, _Wag_6|500, _wag_5|500, _Wag_6|500, _wag_5|500, _Wag_6|500, _wag_5|500, _wag_4|500, _wag_3|500, _wag_2|500, _wag_1|500, _wag_0|500 16 | Seq=Rollover: R1|500, R2|500, R3|500, R4|500, R5|500, R6|500 17 | Nuke=Lizard 3DOF,6,++++++++++++++++++,50,50,50,50,50,50,0,0,2,4,6,1,3,5,14,16,18,13,15,17,8,10,12,7,9,11 18 | -------------------------------------------------------------------------------- /Phoenix/Chr3_PS2_Orion/Chr3_PS2_Orion.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | //============================================================================= 4 | //Project Lynxmotion Phoenix 5 | //Description: Phoenix software 6 | //Software version: V2.0 7 | //Date: 29-10-2009 8 | //Programmer: Jeroen Janssen [aka Xan] 9 | // Kurt Eckhardt(KurtE) converted to C and Arduino 10 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 11 | // 12 | // This version of the Phoenix code was ported over to the Arduino Environement 13 | // and is specifically configured for the Lynxmotion BotBoarduino 14 | // 15 | //============================================================================= 16 | // 17 | //KNOWN BUGS: 18 | // - Lots ;) 19 | // 20 | //============================================================================= 21 | // Header Files 22 | //============================================================================= 23 | 24 | #define DEFINE_HEX_GLOBALS 25 | #if ARDUINO>99 26 | #include 27 | #else 28 | #endif 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | #include 37 | #include "Hex_Cfg.h" 38 | #include 39 | #include 40 | #include 41 | 42 | // Have a little initial setup code that allows us to check BTNS and hang for update of arc32... 43 | #define OPT_SKETCHSETUP 44 | void SketchSetup(void) { 45 | // Lets enable buttons, 46 | pinMode(2, INPUT); 47 | pinMode(4, INPUT); 48 | if (!digitalRead(2) || !digitalRead(4)) { 49 | // Looks like we should just hang here! 50 | pinMode(A0, OUTPUT); 51 | for(;;) { 52 | digitalWrite(A0, !digitalRead(A0)); 53 | delay(250); 54 | } 55 | } 56 | } 57 | 58 | #include 59 | 60 | -------------------------------------------------------------------------------- /Phoenix/Mantis_BMPS2_Orion_Stock/Mantis_BMPS2_Orion_Stock.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | #include 6 | 7 | #include 8 | 9 | 10 | //============================================================================= 11 | //Project Lynxmotion Phoenix 12 | //Description: Phoenix software 13 | //Software version: V2.0 14 | //Date: 29-10-2009 15 | //Programmer: Jeroen Janssen [aka Xan] 16 | // Kurt Eckhardt(KurtE) converted to C and Arduino 17 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 18 | // 19 | // This version of the Phoenix code was ported over to the Arduino Environement 20 | // and is specifically configured for the Orion Robotics Orion sheild. 21 | // 22 | //============================================================================= 23 | // 24 | //KNOWN BUGS: 25 | // - Lots ;) 26 | // 27 | //============================================================================= 28 | // Header Files 29 | //============================================================================= 30 | 31 | #define DEFINE_HEX_GLOBALS 32 | #include 33 | 34 | #include 35 | 36 | 37 | 38 | #include "Quad_Cfg.h" 39 | 40 | #include 41 | // Speed, Steps, Lifted, Front Down, Lifted Factor, Half Height, On Ground, 42 | // Quad extra: COGAngleStart, COGAngleStep, CogRadius, COGCCW 43 | // { RR, RF, LR, , LF} 44 | #define ADD_GAITS 45 | #define PYPOSE_GAIT_SPEED 98 46 | PHOENIXGAIT APG_EXTRA[] = { 47 | {PYPOSE_GAIT_SPEED, 8, 2, 1, 2, 6, 1, 0, 0,0, true, {7, 1, 3, 5}}, // ripple 48 | {PYPOSE_GAIT_SPEED, 4, 2, 1, 2, 2, 1, 0, 0, 0, true,{3, 1, 1, 3}}, // Amble 49 | {PYPOSE_GAIT_SPEED, 6, 3, 2, 2, 3, 2, 0, 0,0, true, {1, 4, 4, 1}} }; // Smooth Amble 50 | 51 | 52 | #include 53 | #include 54 | #include 55 | 56 | -------------------------------------------------------------------------------- /Phoenix/PhXQuadV2_Commander_AX12_Stock/PhXQuadV2_Commander_AX12_Stock.ino: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // Warning:: This configuration does not check voltages, so you should be careful to 15 | // not allow the lipo to discharge too far. 16 | // 17 | // This configuration should hopefully run on a stock PhantomX, without any 18 | // of my changes. 19 | // 20 | //KNOWN BUGS: 21 | // - Lots ;) 22 | // 23 | //============================================================================= 24 | // Header Files 25 | //============================================================================= 26 | 27 | #define DEFINE_HEX_GLOBALS 28 | #if ARDUINO>99 29 | #include 30 | #else 31 | #endif 32 | 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | 40 | #include "Quad_Cfg.h" 41 | 42 | #include 43 | // Speed, Steps, Lifted, Front Down, Lifted Factor, Half Height, On Ground, 44 | // Quad extra: COGAngleStart, COGAngleStep, CogRadius, COGCCW 45 | // { RR, RF, LR, , LF} 46 | #define ADD_GAITS 47 | #define PYPOSE_GAIT_SPEED 60 48 | PHOENIXGAIT APG_EXTRA[] = { 49 | {PYPOSE_GAIT_SPEED, 8, 2, 1, 2, 6, 1, 0, 0,0, true, {7, 1, 3, 5}}, // ripple 50 | {PYPOSE_GAIT_SPEED, 4, 2, 1, 2, 2, 1, 0, 0, 0, true,{3, 1, 1, 3}}, // Amble 51 | {PYPOSE_GAIT_SPEED, 6, 3, 2, 2, 3, 2, 0, 0,0, true, {1, 4, 4, 1}} }; // Smooth Amble 52 | 53 | 54 | #include 55 | #include 56 | #include 57 | 58 | -------------------------------------------------------------------------------- /Phoenix/PhantomX_Commander_AX12/PyPoseGen.h: -------------------------------------------------------------------------------- 1 | #ifndef TEST_POSES 2 | #define TEST_POSES 3 | 4 | #include 5 | 6 | PROGMEM prog_uint16_t R4[] = {18, 512, 511, 711, 595, 300, 899, 510, 510, 712, 596, 300, 900, 511, 510, 712, 800, 300, 970}; 7 | PROGMEM prog_uint16_t R5[] = {18, 512, 511, 711, 312, 201, 712, 509, 510, 712, 312, 201, 712, 511, 510, 711, 799, 207, 967}; 8 | PROGMEM prog_uint16_t R6[] = {18, 512, 512, 654, 224, 45, 506, 510, 512, 661, 225, 43, 506, 511, 510, 662, 799, 44, 967}; 9 | PROGMEM prog_uint16_t _Wag_6[] = {18, 511, 511, 297, 710, 113, 906, 628, 326, 260, 777, 368, 940, 663, 327, 306, 682, 62, 958}; 10 | PROGMEM prog_uint16_t _wag_1[] = {18, 512, 514, 280, 696, 50, 924, 492, 509, 280, 730, 42, 979, 509, 513, 273, 708, 47, 967}; 11 | PROGMEM prog_uint16_t R1[] = {18, 513, 513, 226, 796, 52, 971, 510, 510, 229, 795, 50, 970, 511, 510, 227, 796, 52, 970}; 12 | PROGMEM prog_uint16_t R2[] = {18, 512, 511, 226, 594, 52, 899, 509, 510, 229, 596, 50, 900, 511, 510, 428, 800, 124, 970}; 13 | PROGMEM prog_uint16_t R3[] = {18, 512, 511, 712, 595, 197, 899, 510, 510, 711, 596, 200, 900, 511, 510, 550, 800, 242, 970}; 14 | PROGMEM prog_uint16_t _wag_3[] = {18, 511, 512, 296, 710, 113, 906, 492, 509, 280, 730, 42, 981, 663, 327, 308, 682, 47, 967}; 15 | PROGMEM prog_uint16_t _wag_2[] = {18, 511, 511, 311, 696, 112, 920, 492, 508, 280, 731, 42, 979, 665, 326, 182, 795, 47, 967}; 16 | PROGMEM prog_uint16_t _wag_5[] = {18, 511, 512, 300, 710, 114, 906, 639, 331, 267, 779, 52, 651, 663, 327, 308, 682, 62, 962}; 17 | PROGMEM prog_uint16_t _wag_4[] = {18, 511, 512, 312, 712, 113, 906, 645, 331, 267, 772, 254, 767, 663, 327, 308, 682, 47, 967}; 18 | PROGMEM prog_uint16_t _wag_0[] = {18, 547, 514, 286, 719, 51, 935, 488, 509, 230, 788, 17, 977, 491, 518, 234, 723, 0, 921}; 19 | 20 | PROGMEM transition_t Wag[] = {{0,17} ,{_wag_0,500} ,{_wag_1,500} ,{_wag_2,500} ,{_wag_3,500} ,{_wag_4,500} ,{_wag_5,500} ,{_Wag_6,500} ,{_wag_5,500} ,{_Wag_6,500} ,{_wag_5,500} ,{_Wag_6,500} ,{_wag_5,500} ,{_wag_4,500} ,{_wag_3,500} ,{_wag_2,500} ,{_wag_1,500} ,{_wag_0,500} }; 21 | PROGMEM transition_t Rollover[] = {{0,6} ,{R1,500} ,{R2,500} ,{R3,500} ,{R4,500} ,{R5,500} ,{R6,500} }; 22 | 23 | #ifdef EXPORT_POSE_LIST 24 | PROGMEM transition_t *PoseList[] = { Wag ,Rollover }; 25 | 26 | #endif 27 | #endif 28 | -------------------------------------------------------------------------------- /Phoenix/PhantomX_DIYXbee_AX12/PyPoseGen.h: -------------------------------------------------------------------------------- 1 | #ifndef TEST_POSES 2 | #define TEST_POSES 3 | 4 | #include 5 | 6 | PROGMEM prog_uint16_t R4[] = {18, 512, 511, 711, 595, 300, 899, 510, 510, 712, 596, 300, 900, 511, 510, 712, 800, 300, 970}; 7 | PROGMEM prog_uint16_t R5[] = {18, 512, 511, 711, 312, 201, 712, 509, 510, 712, 312, 201, 712, 511, 510, 711, 799, 207, 967}; 8 | PROGMEM prog_uint16_t R6[] = {18, 512, 512, 654, 224, 45, 506, 510, 512, 661, 225, 43, 506, 511, 510, 662, 799, 44, 967}; 9 | PROGMEM prog_uint16_t _Wag_6[] = {18, 511, 511, 297, 710, 113, 906, 628, 326, 260, 777, 368, 940, 663, 327, 306, 682, 62, 958}; 10 | PROGMEM prog_uint16_t _wag_1[] = {18, 512, 514, 280, 696, 50, 924, 492, 509, 280, 730, 42, 979, 509, 513, 273, 708, 47, 967}; 11 | PROGMEM prog_uint16_t R1[] = {18, 513, 513, 226, 796, 52, 971, 510, 510, 229, 795, 50, 970, 511, 510, 227, 796, 52, 970}; 12 | PROGMEM prog_uint16_t R2[] = {18, 512, 511, 226, 594, 52, 899, 509, 510, 229, 596, 50, 900, 511, 510, 428, 800, 124, 970}; 13 | PROGMEM prog_uint16_t R3[] = {18, 512, 511, 712, 595, 197, 899, 510, 510, 711, 596, 200, 900, 511, 510, 550, 800, 242, 970}; 14 | PROGMEM prog_uint16_t _wag_3[] = {18, 511, 512, 296, 710, 113, 906, 492, 509, 280, 730, 42, 981, 663, 327, 308, 682, 47, 967}; 15 | PROGMEM prog_uint16_t _wag_2[] = {18, 511, 511, 311, 696, 112, 920, 492, 508, 280, 731, 42, 979, 665, 326, 182, 795, 47, 967}; 16 | PROGMEM prog_uint16_t _wag_5[] = {18, 511, 512, 300, 710, 114, 906, 639, 331, 267, 779, 52, 651, 663, 327, 308, 682, 62, 962}; 17 | PROGMEM prog_uint16_t _wag_4[] = {18, 511, 512, 312, 712, 113, 906, 645, 331, 267, 772, 254, 767, 663, 327, 308, 682, 47, 967}; 18 | PROGMEM prog_uint16_t _wag_0[] = {18, 547, 514, 286, 719, 51, 935, 488, 509, 230, 788, 17, 977, 491, 518, 234, 723, 0, 921}; 19 | 20 | PROGMEM transition_t Wag[] = {{0,17} ,{_wag_0,500} ,{_wag_1,500} ,{_wag_2,500} ,{_wag_3,500} ,{_wag_4,500} ,{_wag_5,500} ,{_Wag_6,500} ,{_wag_5,500} ,{_Wag_6,500} ,{_wag_5,500} ,{_Wag_6,500} ,{_wag_5,500} ,{_wag_4,500} ,{_wag_3,500} ,{_wag_2,500} ,{_wag_1,500} ,{_wag_0,500} }; 21 | PROGMEM transition_t Rollover[] = {{0,6} ,{R1,500} ,{R2,500} ,{R3,500} ,{R4,500} ,{R5,500} ,{R6,500} }; 22 | 23 | #ifdef EXPORT_POSE_LIST 24 | PROGMEM transition_t *PoseList[] = { Wag ,Rollover }; 25 | 26 | #endif 27 | #endif 28 | -------------------------------------------------------------------------------- /Phoenix/PhantomX_Commander_AX12_Stock/PyPoseGen.h: -------------------------------------------------------------------------------- 1 | #ifndef TEST_POSES 2 | #define TEST_POSES 3 | 4 | #include 5 | 6 | PROGMEM prog_uint16_t R4[] = {18, 512, 511, 711, 595, 300, 899, 510, 510, 712, 596, 300, 900, 511, 510, 712, 800, 300, 970}; 7 | PROGMEM prog_uint16_t R5[] = {18, 512, 511, 711, 312, 201, 712, 509, 510, 712, 312, 201, 712, 511, 510, 711, 799, 207, 967}; 8 | PROGMEM prog_uint16_t R6[] = {18, 512, 512, 654, 224, 45, 506, 510, 512, 661, 225, 43, 506, 511, 510, 662, 799, 44, 967}; 9 | PROGMEM prog_uint16_t _Wag_6[] = {18, 511, 511, 297, 710, 113, 906, 628, 326, 260, 777, 368, 940, 663, 327, 306, 682, 62, 958}; 10 | PROGMEM prog_uint16_t _wag_1[] = {18, 512, 514, 280, 696, 50, 924, 492, 509, 280, 730, 42, 979, 509, 513, 273, 708, 47, 967}; 11 | PROGMEM prog_uint16_t R1[] = {18, 513, 513, 226, 796, 52, 971, 510, 510, 229, 795, 50, 970, 511, 510, 227, 796, 52, 970}; 12 | PROGMEM prog_uint16_t R2[] = {18, 512, 511, 226, 594, 52, 899, 509, 510, 229, 596, 50, 900, 511, 510, 428, 800, 124, 970}; 13 | PROGMEM prog_uint16_t R3[] = {18, 512, 511, 712, 595, 197, 899, 510, 510, 711, 596, 200, 900, 511, 510, 550, 800, 242, 970}; 14 | PROGMEM prog_uint16_t _wag_3[] = {18, 511, 512, 296, 710, 113, 906, 492, 509, 280, 730, 42, 981, 663, 327, 308, 682, 47, 967}; 15 | PROGMEM prog_uint16_t _wag_2[] = {18, 511, 511, 311, 696, 112, 920, 492, 508, 280, 731, 42, 979, 665, 326, 182, 795, 47, 967}; 16 | PROGMEM prog_uint16_t _wag_5[] = {18, 511, 512, 300, 710, 114, 906, 639, 331, 267, 779, 52, 651, 663, 327, 308, 682, 62, 962}; 17 | PROGMEM prog_uint16_t _wag_4[] = {18, 511, 512, 312, 712, 113, 906, 645, 331, 267, 772, 254, 767, 663, 327, 308, 682, 47, 967}; 18 | PROGMEM prog_uint16_t _wag_0[] = {18, 547, 514, 286, 719, 51, 935, 488, 509, 230, 788, 17, 977, 491, 518, 234, 723, 0, 921}; 19 | 20 | PROGMEM transition_t Wag[] = {{0,17} ,{_wag_0,500} ,{_wag_1,500} ,{_wag_2,500} ,{_wag_3,500} ,{_wag_4,500} ,{_wag_5,500} ,{_Wag_6,500} ,{_wag_5,500} ,{_Wag_6,500} ,{_wag_5,500} ,{_Wag_6,500} ,{_wag_5,500} ,{_wag_4,500} ,{_wag_3,500} ,{_wag_2,500} ,{_wag_1,500} ,{_wag_0,500} }; 21 | PROGMEM transition_t Rollover[] = {{0,6} ,{R1,500} ,{R2,500} ,{R3,500} ,{R4,500} ,{R5,500} ,{R6,500} }; 22 | 23 | #ifdef EXPORT_POSE_LIST 24 | PROGMEM transition_t *PoseList[] = { Wag ,Rollover }; 25 | 26 | #endif 27 | #endif 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | [Dd]ebug/ 46 | [Rr]elease/ 47 | *_i.c 48 | *_p.c 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.vspscc 63 | .builds 64 | *.dotCover 65 | 66 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 67 | #packages/ 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | 76 | # Visual Studio profiler 77 | *.psess 78 | *.vsp 79 | 80 | # ReSharper is a .NET coding add-in 81 | _ReSharper* 82 | 83 | # Installshield output folder 84 | [Ee]xpress 85 | 86 | # DocProject is a documentation generator add-in 87 | DocProject/buildhelp/ 88 | DocProject/Help/*.HxT 89 | DocProject/Help/*.HxC 90 | DocProject/Help/*.hhc 91 | DocProject/Help/*.hhk 92 | DocProject/Help/*.hhp 93 | DocProject/Help/Html2 94 | DocProject/Help/html 95 | 96 | # Click-Once directory 97 | publish 98 | 99 | # Others 100 | [Bb]in 101 | [Oo]bj 102 | sql 103 | TestResults 104 | *.Cache 105 | ClientBin 106 | stylecop.* 107 | ~$* 108 | *.dbmdl 109 | Generated_Code #added for RIA/Silverlight projects 110 | 111 | # Backup & report files from converting an old project file to a newer 112 | # Visual Studio version. Backup files are not needed, because we have git ;-) 113 | _UpgradeReport_Files/ 114 | Backup*/ 115 | UpgradeLog*.XML 116 | 117 | 118 | 119 | ############ 120 | ## Windows 121 | ############ 122 | 123 | # Windows image file caches 124 | Thumbs.db 125 | 126 | # Folder config file 127 | Desktop.ini 128 | 129 | 130 | ############# 131 | ## Python 132 | ############# 133 | 134 | *.py[co] 135 | 136 | # Packages 137 | *.egg 138 | *.egg-info 139 | dist 140 | build 141 | eggs 142 | parts 143 | bin 144 | var 145 | sdist 146 | develop-eggs 147 | .installed.cfg 148 | 149 | # Installer logs 150 | pip-log.txt 151 | 152 | # Unit test / coverage reports 153 | .coverage 154 | .tox 155 | 156 | #Translations 157 | *.mo 158 | 159 | #Mr Developer 160 | .mr.developer.cfg 161 | 162 | # Mac crap 163 | .DS_Store 164 | -------------------------------------------------------------------------------- /Phoenix_Driver_AX12/BioloidEx.h: -------------------------------------------------------------------------------- 1 | /* 2 | BioloidController.h - ArbotiX Library for Bioloid Pose Engine 3 | Copyright (c) 2008-2012 Michael E. Ferguson. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef BioloidEx_h 21 | #define BioloidEx_h 22 | 23 | /* poses: 24 | * PROGMEM prog_uint16_t name[ ] = {4,512,512,482,542}; // first number is # of servos 25 | * sequences: 26 | * PROGMEM transition_t name[] = {{NULL,count},{pose_name,1000},...} 27 | */ 28 | 29 | #include 30 | 31 | /* pose engine runs at 30Hz (33ms between frames) 32 | recommended values for interpolateSetup are of the form X*BIOLOID_FRAME_LENGTH - 1 */ 33 | #define BIOLOID_FRAME_LENGTH 20 34 | /* we need some extra resolution, use 13 bits, rather than 10, during interpolation */ 35 | #define BIOLOID_SHIFT 3 36 | 37 | /** a structure to hold transitions **/ 38 | typedef struct{ 39 | unsigned int * pose; // addr of pose to transition to 40 | int time; // time for transition 41 | } transition_t; 42 | 43 | /** Bioloid Controller Class for mega324p/644p clients. **/ 44 | class BioloidControllerEx 45 | { 46 | public: 47 | /* For compatibility with legacy code */ 48 | BioloidControllerEx(long baud); // baud usually 1000000 49 | 50 | /* New-style constructor/setup */ 51 | BioloidControllerEx() {}; 52 | void setup(int servo_cnt); 53 | 54 | /* Pose Manipulation */ 55 | void loadPose( const unsigned int * addr ); // load a named pose from FLASH 56 | void readPose(); // read a pose in from the servos 57 | void writePose(); // write a pose out to the servos 58 | int getCurPose(int id); // get a servo value in the current pose 59 | int getNextPose(int id); // get a servo value in the next pose 60 | void setNextPose(int id, int pos); // set a servo value in the next pose 61 | void setNextPoseByIndex(int index, int pos); // set a servo value by index for next pose 62 | void setId(int index, int id); // set the id of a particular storage index 63 | int getId(int index); // get the id of a particular storage index 64 | 65 | /* Pose Engine */ 66 | void interpolateSetup(int time); // calculate speeds for smooth transition 67 | int interpolateStep(boolean fWait=true); // move forward one step in current interpolation 68 | unsigned char interpolating; // are we in an interpolation? 0=No, 1=Yes 69 | unsigned char runningSeq; // are we running a sequence? 0=No, 1=Yes 70 | int poseSize; // how many servos are in this pose, used by Sync() 71 | 72 | // Kurt's Hacks 73 | uint8_t frameLength; // Allow variable frame lengths, to test... 74 | 75 | /* to interpolate: 76 | * bioloid.loadPose(myPose); 77 | * bioloid.interpolateSetup(67); 78 | * while(bioloid.interpolating > 0){ 79 | * bioloid.interpolateStep(); 80 | * delay(1); 81 | * } 82 | */ 83 | 84 | /* Sequence Engine */ 85 | void playSeq( const transition_t * addr ); // load a sequence and play it from FLASH 86 | void play(); // keep moving forward in time 87 | unsigned char playing; // are we playing a sequence? 0=No, 1=Yes 88 | 89 | /* to run the sequence engine: 90 | * bioloid.playSeq(walk); 91 | * while(bioloid.playing){ 92 | * bioloid.play(); 93 | * } 94 | */ 95 | 96 | private: 97 | unsigned int * pose_; // the current pose, updated by Step(), set out by Sync() 98 | unsigned int * nextpose_; // the destination pose, where we put on load 99 | int * speed_; // speeds for interpolation 100 | unsigned char * id_; // servo id for this index 101 | 102 | // unsigned long lastframe_; // time last frame was sent out 103 | unsigned long nextframe_; // 104 | transition_t * sequence; // sequence we are running 105 | int transitions; // how many transitions we have left to load 106 | 107 | }; 108 | #endif 109 | 110 | -------------------------------------------------------------------------------- /Phoenix_Input_RC/PCInt.h: -------------------------------------------------------------------------------- 1 | // This is a completely mucked up version of the PinChangeInt.h library... 2 | #ifndef PCInt_h 3 | #define PCInt_h 4 | #if defined(ARDUINO) && ARDUINO >= 100 5 | #include 6 | #else 7 | #include 8 | #include 9 | #endif 10 | /* 11 | * an extension to the interrupt support for arduino. 12 | * add pin change interrupts to the external interrupts, giving a way 13 | * for users to have interrupts drive off of any pin. 14 | * Refer to avr-gcc header files, arduino source and atmega datasheet. 15 | */ 16 | 17 | /* 18 | * Theory: all IO pins on Atmega168 are covered by Pin Change Interrupts. 19 | * The PCINT corresponding to the pin must be enabled and masked, and 20 | * an ISR routine provided. Since PCINTs are per port, not per pin, the ISR 21 | * must use some logic to actually implement a per-pin interrupt service. 22 | */ 23 | 24 | /* Pin to interrupt map: 25 | // #define NO_PINCHANGE_0 // No Pin changes on 0-7 - Typically Analog pins A0-A5. 26 | // #define NO_PINCHANGE_1 // No Pin changes on 9-15 - On non-mega: D8-13 27 | // #define NO_PINCHANGE_2 // No Pin Changes on 16-23 - non-mega: D0-7 28 | // #define NO_PINCHANGE_3 // No Pin Changes on 24-31 - Arbotix ... 29 | * D0-D7 = PCINT 16-23 = PCIR2 = PD = PCIE2 = pcmsk2 30 | * D8-D13 = PCINT 0-5 = PCIR0 = PB = PCIE0 = pcmsk0 31 | * A0-A5 (D14-D19) = PCINT 8-13 = PCIR1 = PC = PCIE1 = pcmsk1 32 | * On Arbotix Atmega644p - Rough idea of which pins map: 33 | * Pin change NO_PINCHANGE_0(0-7) are on pins A0-A7 34 | * NO_PINCHANGE_1(8-15) to digial pins 0-7 35 | * NO_PINCHANGE_2(16-23) to 16-23 36 | * NO_PINCHANGE_3(24-31) to 8-15 37 | * 38 | * On Leonardo, much more restrictions on which pins support Pin Change Interrupts. I believe they are 39 | * 8-11, and 14-17 are on ICSP(MISO, SCK, MISO, RXLED), also Analog 8-10 which map to digital pins 8-10 40 | * 41 | */ 42 | 43 | // Data associated with each Pin Change interrupt... 44 | typedef void (*PCINTFUNCPTR)(uint8_t, uint8_t, unsigned long); 45 | 46 | 47 | 48 | volatile uint8_t *port_to_pcmask[] = { 49 | &PCMSK0, 50 | &PCMSK1, 51 | &PCMSK2 52 | #ifdef PCINT3_vect 53 | ,&PCMSK3 54 | #endif 55 | }; 56 | 57 | #define CNTPINCHANGES (sizeof(port_to_pcmask)/sizeof(port_to_pcmask[0])*8) 58 | static uint8_t PCintMode[CNTPINCHANGES]; // what mode RISING, FALLING, CHange 59 | static uint8_t bUserData[CNTPINCHANGES]; // Data passed back to the user to identify interrupt... 60 | volatile static PCINTFUNCPTR PCintFunc[CNTPINCHANGES] = { 61 | NULL }; // Pointer to function to call 62 | 63 | 64 | volatile static uint8_t PCintLast[3]; 65 | uint8_t bPCIndexToPortIndexOffset = 0; // 0 is not valid but won't screw us... 66 | 67 | /* 68 | * attach an interrupt to a specific pin using pin change interrupts. 69 | */ 70 | void PCattachInterrupt(uint8_t pin, PCINTFUNCPTR userFunc, uint8_t ident, uint8_t mode) { 71 | // See if this pin has a PCICR register associated with it. 72 | volatile uint8_t *pcmask = digitalPinToPCMSK(pin); 73 | if (!pcmask) 74 | return; // nope 75 | 76 | // Now get the slot number... 77 | uint8_t bPCIRBit = digitalPinToPCICRbit(pin); 78 | uint8_t bPCMSKBit = digitalPinToPCMSKbit(pin); // this gets us to the right pin to update... 79 | uint8_t slot = bPCIRBit * 8 + bPCMSKBit; // Have our slot now 80 | 81 | // See if we need to guess on the PC Int number to index of Ports... 82 | if (bPCIndexToPortIndexOffset == 0) { 83 | uint16_t uwPinPort = (uint16_t)portOutputRegister(digitalPinToPort(pin)); 84 | for (int8_t i=0; i < 6; i++) { // The actual sizes are not exported but assume this will be big enough... 85 | uint16_t uwPort = pgm_read_word(&port_to_output_PGM[i]); 86 | if (uwPort == uwPinPort) { 87 | bPCIndexToPortIndexOffset = i - bPCIRBit; 88 | break; 89 | } 90 | } 91 | } 92 | 93 | 94 | // Now lets save away the passed in information... 95 | PCintMode[slot] = mode; 96 | PCintFunc[slot] = userFunc; 97 | bUserData[slot] = ident; 98 | 99 | // Now lets enable the interrupt 100 | *pcmask |= (0x01 << bPCMSKBit); // Set the appropriate bit in the Pin Change Mask 101 | // enable the interrupt 102 | PCICR |= (0x01 << bPCIRBit); // Enable the interrupt associated with that pin 103 | } 104 | 105 | void PCdetachInterrupt(uint8_t pin) { 106 | // See if this pin has a PCICR register associated with it. 107 | volatile uint8_t *pcmask = digitalPinToPCMSK(pin); 108 | if (!pcmask) 109 | return; // nope 110 | 111 | // Now get the slot number... 112 | uint8_t bPCIRBit = digitalPinToPCICRbit(pin); 113 | uint8_t bPCMSKBit = digitalPinToPCMSKbit(pin); // this gets us to the right pin to update... 114 | //uint8_t slot = bPCIRBit * 8 + bPCMSKBit; // Have our slot now 115 | 116 | // disable the mask. 117 | *pcmask &= ~(0x01 << bPCMSKBit); 118 | // if that's the last one, disable the interrupt. 119 | if (*pcmask == 0) { 120 | PCICR &= ~(0x01 << bPCIRBit); 121 | } 122 | } 123 | 124 | // common code for isr handler. "port" is the PCINT number. 125 | // there isn't really a good way to back-map ports and masks to pins. 126 | static void PCint(uint8_t bPCInterruptIndex) { 127 | uint8_t bPinMask; 128 | uint8_t curr; 129 | uint8_t mask; 130 | uint8_t pin; 131 | unsigned long ulTime; 132 | 133 | // get the pin states for the indicated port. 134 | ulTime = micros(); // get the time of the interrupt as quickly as we can. 135 | 136 | // In Setup we took a big guess on a mapping from the "Port" 137 | curr = *portInputRegister(bPCInterruptIndex+ bPCIndexToPortIndexOffset); 138 | mask = curr ^ PCintLast[bPCInterruptIndex]; 139 | PCintLast[bPCInterruptIndex] = curr; 140 | // mask is pins that have changed. screen out non pcint pins. 141 | if ((mask &= *port_to_pcmask[bPCInterruptIndex]) == 0) { 142 | return; 143 | } 144 | bPinMask = 0x01; 145 | for (uint8_t i=0; i < 8; i++) { 146 | if (bPinMask & mask) { 147 | pin = bPCInterruptIndex * 8 + i; 148 | // Trigger interrupt if mode is CHANGE, or if mode is RISING and 149 | // the bit is currently high, or if mode is FALLING and bit is low. 150 | if ((PCintMode[pin] == CHANGE 151 | || ((PCintMode[pin] == RISING) && (curr & bPinMask)) 152 | || ((PCintMode[pin] == FALLING) && !(curr & bPinMask))) 153 | && (PCintFunc[pin] != NULL)) { 154 | PCintFunc[pin](bUserData[pin], curr & bPinMask, ulTime); 155 | } 156 | } 157 | bPinMask <<= 1; 158 | } 159 | } 160 | 161 | #if defined(PCINT0_vect) && !defined(NO_PINCHANGE_0) 162 | ISR(PCINT0_vect) { 163 | PCint(0); 164 | } 165 | #endif 166 | 167 | #if defined(PCINT1_vect) && !defined(NO_PINCHANGE_1) 168 | ISR(PCINT1_vect) { 169 | PCint(1); 170 | } 171 | #endif 172 | 173 | #if defined(PCINT2_vect) && !defined(NO_PINCHANGE_2) 174 | ISR(PCINT2_vect) { 175 | PCint(2); 176 | } 177 | #endif 178 | 179 | #if defined(PCINT3_vect) && !defined(NO_PINCHANGE_3) 180 | ISR(PCINT3_vect) { 181 | PCint(3); 182 | } 183 | #endif 184 | 185 | #endif 186 | 187 | -------------------------------------------------------------------------------- /Phoenix_Driver_AX12/BioloidEX.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | BioloidController.cpp - ArbotiX Library for Bioloid Pose Engine 3 | Copyright (c) 2008-2012 Michael E. Ferguson. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "BioloidEx.h" 21 | #include 22 | 23 | /* initializes serial1 transmit at baud, 8-N-1 */ 24 | BioloidControllerEx::BioloidControllerEx(long baud){ 25 | int i; 26 | // setup storage 27 | id_ = (unsigned char *) malloc(AX12_MAX_SERVOS * sizeof(unsigned char)); 28 | pose_ = (unsigned int *) malloc(AX12_MAX_SERVOS * sizeof(unsigned int)); 29 | nextpose_ = (unsigned int *) malloc(AX12_MAX_SERVOS * sizeof(unsigned int)); 30 | speed_ = (int *) malloc(AX12_MAX_SERVOS * sizeof(int)); 31 | // initialize 32 | for(i=0;i> BIOLOID_SHIFT; 100 | checksum += (temp&0xff) + (temp>>8) + id_[i]; 101 | ax12write(id_[i]); 102 | ax12write(temp&0xff); 103 | ax12write(temp>>8); 104 | } 105 | ax12write(0xff - (checksum % 256)); 106 | setRX(0); 107 | } 108 | 109 | /* set up for an interpolation from pose to nextpose over TIME 110 | milliseconds by setting servo speeds. */ 111 | void BioloidControllerEx::interpolateSetup(int time){ 112 | int i; 113 | int frames = (time/frameLength) + 1; 114 | nextframe_ = millis() + frameLength; 115 | // set speed each servo... 116 | for(i=0;i pose_[i]){ 118 | speed_[i] = (nextpose_[i] - pose_[i])/frames + 1; 119 | } 120 | else{ 121 | speed_[i] = (pose_[i]-nextpose_[i])/frames + 1; 122 | } 123 | } 124 | interpolating = 1; 125 | } 126 | /* interpolate our pose, this should be called at about 30Hz. */ 127 | #define WAIT_SLOP_FACTOR 10 128 | int BioloidControllerEx::interpolateStep(boolean fWait){ 129 | if(interpolating == 0) return 0x7fff; 130 | int i; 131 | int complete = poseSize; 132 | if (!fWait) { 133 | if (millis() < (nextframe_ - WAIT_SLOP_FACTOR)) { 134 | return (millis() - nextframe_); // We still have some time to do something... 135 | } 136 | } 137 | while(millis() < nextframe_) ; 138 | nextframe_ = millis() + frameLength; 139 | // update each servo 140 | for(i=0;i 0){ 147 | if(diff < speed_[i]){ 148 | pose_[i] = nextpose_[i]; 149 | complete--; 150 | } 151 | else 152 | pose_[i] += speed_[i]; 153 | } 154 | else{ 155 | if((-diff) < speed_[i]){ 156 | pose_[i] = nextpose_[i]; 157 | complete--; 158 | } 159 | else 160 | pose_[i] -= speed_[i]; 161 | } 162 | } 163 | } 164 | if(complete <= 0) interpolating = 0; 165 | writePose(); 166 | return 0; 167 | } 168 | 169 | /* get a servo value in the current pose */ 170 | int BioloidControllerEx::getCurPose(int id){ 171 | for(int i=0; i> BIOLOID_SHIFT); 174 | } 175 | return -1; 176 | } 177 | /* get a servo value in the next pose */ 178 | int BioloidControllerEx::getNextPose(int id){ 179 | for(int i=0; i> BIOLOID_SHIFT); 182 | } 183 | return -1; 184 | } 185 | /* set a servo value in the next pose */ 186 | void BioloidControllerEx::setNextPose(int id, int pos){ 187 | for(int i=0; itime); 206 | sequence++; 207 | // load a transition 208 | loadPose((const unsigned int *)pgm_read_word_near(&sequence->pose)); 209 | interpolateSetup(pgm_read_word_near(&sequence->time)); 210 | transitions--; 211 | playing = 1; 212 | } 213 | /* keep playing our sequence */ 214 | void BioloidControllerEx::play(){ 215 | if(playing == 0) return; 216 | if(interpolating > 0){ 217 | interpolateStep(); 218 | } 219 | else{ // move onto next pose 220 | sequence++; 221 | if(transitions > 0){ 222 | loadPose((const unsigned int *)pgm_read_word_near(&sequence->pose)); 223 | interpolateSetup(pgm_read_word_near(&sequence->time)); 224 | transitions--; 225 | } 226 | else{ 227 | playing = 0; 228 | } 229 | } 230 | } 231 | 232 | 233 | 234 | -------------------------------------------------------------------------------- /ServoEx/ServoEx.h: -------------------------------------------------------------------------------- 1 | /* 2 | ServoEx.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 3 | Copyright (c) 2009 Michael Margolis. All right reserved. 4 | 5 | This version was extended by Kurt Eckhardt to allow for timed moves, including a group move where 6 | one or more servos are told to go a new end point and that they should take a specific time to 7 | get there. 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this library; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | /* 25 | 26 | A servo is activated by creating an instance of the ServoEx class passing the desired pin to the attach() method. 27 | The Servos are pulsed in the background using the value most recently written using the write() method 28 | 29 | Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached. 30 | Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four. 31 | The sequence used to sieze timers is defined in timers.h 32 | 33 | The methods are: 34 | 35 | ServoEx - Class for manipulating servo motors connected to Arduino pins. 36 | 37 | attach(pin ) - Attaches a servo motor to an i/o pin. 38 | attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds 39 | default min is 544, max is 2400 40 | 41 | write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds) 42 | writeMicroseconds() - Sets the servo pulse width in microseconds 43 | read() - Gets the last written servo pulse width as an angle between 0 and 180. 44 | readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release) 45 | attached() - Returns true if there is a servo attached. 46 | detach() - Stops an attached servos from pulsing its i/o pin. 47 | 48 | New methods: 49 | moving - Returns true if the servo is still moving to it's new location. 50 | move - Move the one servo to a new location... 51 | 52 | New Class cServoGroupMove - used to start a new group move. There is one instance of this class 53 | defined ServoGroupMove. 54 | 55 | The methods are: 56 | 57 | start - Starts a group move. The servos are not moved until the commit call 58 | commit - Commits the moves(write, writeMicroseconds) that happened since start 59 | 60 | moving - Returns a bitmask of the servos that are still moving. The bits are in the order 61 | the servos were created. 62 | wait - Waits for all of the servos defined in the mask are to their end points. 63 | 64 | */ 65 | 66 | #ifndef _Servo_Group_Move_h_ 67 | #define _Servo_Group_Move_h_ 68 | 69 | #include 70 | 71 | /* 72 | * Defines for 16 bit timers used with ServoEx library 73 | * 74 | * If _useTimerX is defined then TimerX is a 16 bit timer on the curent board 75 | * timer16_Sequence_t enumerates the sequence that the timers should be allocated 76 | * _Nbr_16timers indicates how many 16 bit timers are available. 77 | * 78 | */ 79 | 80 | // Say which 16 bit timers can be used and in what order 81 | #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 82 | #define _useTimer5 83 | #define _useTimer1 84 | #define _useTimer3 85 | #define _useTimer4 86 | typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ; 87 | 88 | #elif defined(__AVR_ATmega32U4__) 89 | #define _useTimer1 90 | typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ; 91 | 92 | #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) 93 | #define _useTimer3 94 | #define _useTimer1 95 | typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ; 96 | 97 | #elif defined(__AVR_ATmega128__) ||defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__) 98 | #define _useTimer3 99 | #define _useTimer1 100 | typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ; 101 | 102 | #else // everything else 103 | #define _useTimer1 104 | typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ; 105 | #endif 106 | 107 | #define Servo_VERSION 2 // software version of this library 108 | 109 | #define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo 110 | #define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo 111 | #define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached 112 | #define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microseconds 113 | 114 | #define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer 115 | #define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) 116 | 117 | #define INVALID_SERVO 255 // flag indicating an invalid servo index 118 | 119 | typedef struct { 120 | uint8_t nbr :6 ; // a pin number from 0 to 63 121 | uint8_t isActive :1 ; // true if this channel is enabled, pin not pulsed if false 122 | } ServoPin_t ; 123 | 124 | typedef struct { 125 | ServoPin_t Pin; 126 | unsigned int ticks; // Current Tick count 127 | unsigned int ticksNew; // New end point tick count 128 | int ticksDelta; // How much to change per servo cycle 129 | unsigned int ticksPending; // New pending value that commit will use. 130 | } servo_t; 131 | 132 | class ServoEx 133 | { 134 | public: 135 | ServoEx(); 136 | uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure 137 | uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes. 138 | void detach(); 139 | void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds 140 | void writeMicroseconds(int value); // Write pulse width in microseconds 141 | int read(); // returns current pulse width as an angle between 0 and 180 degrees 142 | int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release) 143 | bool attached(); // return true if this servo is attached, otherwise false 144 | bool moving(); // return true if the servo is still moving 145 | void move(int value, unsigned int MoveTime); // A one servo group move... 146 | private: 147 | #if defined(__arm__) 148 | uint16_t min_ticks; 149 | uint16_t max_ticks; 150 | #else 151 | int8_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH 152 | int8_t max; // maximum is this value times 4 added to MAX_PULSE_WIDTH 153 | #endif 154 | uint8_t servoIndex; // index into the channel data for this servo 155 | }; 156 | 157 | 158 | class cServoGroupMove { 159 | public: 160 | // Constructor. Set up variables. 161 | // Warning: currently this is limited to 32 servos... 162 | //ServoGroupMove(); 163 | 164 | void start(void); // Start a group move 165 | void commit(unsigned int wMoveTime); // how long in milliseconds the move should take 166 | void abort(void); // Abort any moves that may be active 167 | 168 | uint32_t moving(void); // returns bit mask for which servos are active. 169 | void wait(uint32_t ulSGMMask); 170 | 171 | }; 172 | 173 | extern cServoGroupMove ServoGroupMove; 174 | 175 | #endif -------------------------------------------------------------------------------- /Phoenix/Mantis_BMPS2_Orion_Stock/Quad_Cfg.h: -------------------------------------------------------------------------------- 1 | //==================================================================== 2 | //Project Lynxmotion Phoenix 3 | //Description: 4 | // This is the hardware configuration file for the 5 | // Orion Robotics Mantis Quad using their Serial PS2 6 | // 7 | //==================================================================== 8 | #ifndef QUAD_CFG_H 9 | #define QUAD_CFG_H 10 | 11 | #define QUADMODE // We are building for quad support... 12 | #define DBGSerial Serial 13 | //================================================================================================================================== 14 | // Define which input classes we will use. If we wish to use more than one we need to define USEMULTI - This will define a forwarder 15 | // type implementation, that the Inputcontroller will need to call. There will be some negotion for which one is in contol. 16 | // 17 | // If this is not defined, The included Controller should simply implement the InputController Class... 18 | //================================================================================================================================== 19 | 20 | // Global defines to control which configuration we are using. Note: Only define one of these... 21 | // 22 | // Which type of control(s) do you want to compile in 23 | #ifdef USEXBEE // some options only valid if running with XBEE stuff 24 | #define XBEE_DEBUG_OUTPUT // use our xbee serial class to do debug stuff 25 | #define DBGSerial XBDSerial 26 | #endif 27 | //#define DBGSerial Serial 28 | 29 | // Define other optional compnents to be included or not... 30 | #define BALANCE_DELAY 25 // don't add as much as the default here. 31 | 32 | //=================================================================== 33 | // Debug Options 34 | #ifdef DBGSerial 35 | #define OPT_TERMINAL_MONITOR 36 | #endif 37 | 38 | //#define DEBUG_IOPINS 39 | #ifdef DEBUG_IOPINS 40 | #define DebugToggle(pin) {digitalWrite(pin, !digitalRead(pin));} 41 | #define DebugWrite(pin, state) {digitalWrite(pin, state);} 42 | #else 43 | #define DebugToggle(pin) {;} 44 | #define DebugWrite(pin, state) {;} 45 | #endif 46 | 47 | 48 | // Also define that we are using the AX12 driver 49 | 50 | //================================================================================================================================== 51 | //================================================================================================================================== 52 | //================================================================================================================================== 53 | // PhantomX 54 | //================================================================================================================================== 55 | //[SERIAL CONNECTIONS] 56 | 57 | //==================================================================== 58 | // XBEE on non mega??? 59 | #define XBeeSerial Serial 60 | #define XBEE_BAUD 38400 61 | #define DISP_VOLTAGE // User wants the Battery voltage to be displayed... 62 | #define DISP_VOLTAGE_TIME 1000 // how often to check and report in millis 63 | //-------------------------------------------------------------------- 64 | //[Arbotix Pin Numbers] 65 | #define SOUND_PIN 3 // Sound is on The orion shield pin 3 66 | #define PS2_PIN 6 // Their serial PS2 receiver is plugged into pin 6 67 | 68 | // Define minimum voltage that we will allow the servos to run 69 | #define cTurnOffVol 650 // 6.5 70 | #define cTurnOnVol 700 // 7v - optional part to say if voltage goes back up, turn it back on... 71 | 72 | //==================================================================== 73 | #define DEFAULT_GAIT_SPEED 50 // Default gait speed - Will depend on what Servos you are using... 74 | #define DEFAULT_SLOW_GAIT 50 // Had a couple different speeds... 75 | 76 | //==================================================================== 77 | 78 | 79 | //-------------------------------------------------------------------- 80 | // Define which pins(sevo IDS go with which joint 81 | 82 | #define cRRCoxaPin 4 //Rear Right leg Hip Horizontal 83 | #define cRRFemurPin 5 //Rear Right leg Hip Vertical 84 | #define cRRTibiaPin 6 //Rear Right leg Knee 85 | 86 | #define cRFCoxaPin 8 //Front Right leg Hip Horizontal 87 | #define cRFFemurPin 9 //Front Right leg Hip Vertical 88 | #define cRFTibiaPin 10 //Front Right leg Knee 89 | 90 | #define cLRCoxaPin 16 //Rear Left leg Hip Horizontal 91 | #define cLRFemurPin 17 //Rear Left leg Hip Vertical 92 | #define cLRTibiaPin 18 //Rear Left leg Knee 93 | 94 | #define cLFCoxaPin 20 //Front Left leg Hip Horizontal 95 | #define cLFFemurPin 21 //Front Left leg Hip Vertical 96 | #define cLFTibiaPin 22 //Front Left leg Knee 97 | 98 | 99 | //-------------------------------------------------------------------- 100 | //[MIN/MAX ANGLES] - We will let the Orion controller handle Min Max and servo inversions. 101 | #define SERVOS_DO_MINMAX // the servo controller will take care of this 102 | 103 | #define cRRCoxaInv 0 104 | #define cRFCoxaInv 0 105 | #define cLRCoxaInv 0 106 | #define cLFCoxaInv 0 107 | #define cRRFemurInv 0 108 | #define cRFFemurInv 0 109 | #define cLRFemurInv 0 110 | #define cLFFemurInv 0 111 | #define cRRTibiaInv 1 112 | #define cRFTibiaInv 1 113 | #define cLRTibiaInv 1 114 | #define cLFTibiaInv 1 115 | 116 | 117 | //-------------------------------------------------------------------- 118 | //[LEG DIMENSIONS] 119 | //Universal dimensions for each leg in mm 120 | 121 | #define cXXCoxaLength 60 // Mantis leg dimensions. 122 | #define cXXFemurLength 113 123 | #define cXXTibiaLength 173 124 | 125 | #define cRRCoxaLength cXXCoxaLength //Right Rear leg 126 | #define cRRFemurLength cXXFemurLength 127 | #define cRRTibiaLength cXXTibiaLength 128 | 129 | #define cRFCoxaLength cXXCoxaLength //Rigth front leg 130 | #define cRFFemurLength cXXFemurLength 131 | #define cRFTibiaLength cXXTibiaLength 132 | 133 | #define cLRCoxaLength cXXCoxaLength //Left Rear leg 134 | #define cLRFemurLength cXXFemurLength 135 | #define cLRTibiaLength cXXTibiaLength 136 | 137 | #define cLFCoxaLength cXXCoxaLength //Left front leg 138 | #define cLFFemurLength cXXFemurLength 139 | #define cLFTibiaLength cXXTibiaLength 140 | 141 | //-------------------------------------------------------------------- 142 | //[BODY DIMENSIONS] 143 | #define cRRCoxaAngle1 -450 //Default Coxa setup angle, decimals = 1 144 | #define cRFCoxaAngle1 450 //Default Coxa setup angle, decimals = 1 145 | #define cLRCoxaAngle1 -450 //Default Coxa setup angle, decimals = 1 146 | #define cLFCoxaAngle1 450 //Default Coxa setup angle, decimals = 1 147 | 148 | #define X_COXA 60 // MM between front and back legs /2 149 | #define Y_COXA 60 // MM between front/back legs /2 150 | 151 | #define cRROffsetX -X_COXA //Distance X from center of the body to the Right Rear coxa 152 | #define cRROffsetZ Y_COXA //Distance Z from center of the body to the Right Rear coxa 153 | 154 | #define cRFOffsetX -X_COXA //Distance X from center of the body to the Right Front coxa 155 | #define cRFOffsetZ -Y_COXA //Distance Z from center of the body to the Right Front coxa 156 | 157 | #define cLROffsetX X_COXA //Distance X from center of the body to the Left Rear coxa 158 | #define cLROffsetZ Y_COXA //Distance Z from center of the body to the Left Rear coxa 159 | 160 | #define cLFOffsetX X_COXA //Distance X from center of the body to the Left Front coxa 161 | #define cLFOffsetZ -Y_COXA //Distance Z from center of the body to the Left Front coxa 162 | 163 | //-------------------------------------------------------------------- 164 | //[START POSITIONS FEET] 165 | #define cHexInitXZ 170 166 | #define CHexInitXZCos60 147 //92 // COS(60) = .866 167 | #define CHexInitXZSin60 85 // 92 // sin(60) = .5g 168 | #define CHexInitY 45 //30 169 | 170 | // Lets try some multi leg positions depending on height settings. 171 | #define CNT_HEX_INITS 3 172 | #define MAX_BODY_Y 250 173 | // For Inits we may want to tell system actual angles we are initiing servos to... 174 | // In some cases like some quads may not want legs straight out... 175 | #define cRRInitCoxaAngle1 -300 //Default Coxa setup angle, decimals = 1 176 | #define cRFInitCoxaAngle1 300 //Default Coxa setup angle, decimals = 1 177 | #define cLRInitCoxaAngle1 -300 //Default Coxa setup angle, decimals = 1 178 | #define cLFInitCoxaAngle1 300 //Default Coxa setup angle, decimals = 1 179 | 180 | 181 | #ifdef DEFINE_HEX_GLOBALS 182 | const byte g_abHexIntXZ[] PROGMEM = {cHexInitXZ, 150, 120}; 183 | const byte g_abHexMaxBodyY[] PROGMEM = { 80, 120, MAX_BODY_Y}; 184 | #else 185 | extern const byte g_abHexIntXZ[] PROGMEM; 186 | extern const byte g_abHexMaxBodyY[] PROGMEM; 187 | #endif 188 | 189 | #define cRRInitPosX CHexInitXZCos60 //Start positions of the Right Rear leg 190 | #define cRRInitPosY CHexInitY 191 | #define cRRInitPosZ CHexInitXZSin60 192 | 193 | #define cRFInitPosX CHexInitXZCos60 //Start positions of the Right Front leg 194 | #define cRFInitPosY CHexInitY 195 | #define cRFInitPosZ -CHexInitXZSin60 196 | 197 | #define cLRInitPosX CHexInitXZCos60 //Start positions of the Left Rear leg 198 | #define cLRInitPosY CHexInitY 199 | #define cLRInitPosZ CHexInitXZSin60 200 | 201 | #define cLFInitPosX CHexInitXZCos60 //Start positions of the Left Front leg 202 | #define cLFInitPosY CHexInitY 203 | #define cLFInitPosZ -CHexInitXZSin60 204 | //-------------------------------------------------------------------- 205 | #endif // HEX_CFG_H 206 | -------------------------------------------------------------------------------- /Phoenix_Input_DIYXbee/diyxbee.h: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | // DIYXBee.h XBee Support for the DIY Remote control 3 | // [Packets sent from Remote to Robot] 4 | //============================================================================= 5 | #ifndef _DIYXBEE_H_ 6 | #define _DIYXBEE_H_ 7 | 8 | #if ARDUINO>99 9 | #include // Arduino 1.0 10 | #else 11 | #include // Arduino 0022 12 | #endif 13 | 14 | #define XBEEDATAVERSION 1 // Data version... 15 | 16 | //#define XBEE_TRANS_READY 0x01 // Transmitter is ready for requests. 17 | // Optional Word to use in ATDL command 18 | //#define XBEE_TRANS_NOTREADY 0x02 // Transmitter is exiting transmitting on the sent DL 19 | // No Extra bytes. 20 | #define XBEE_TRANS_DATA 0x03 // Data Packet from Transmitter to Robot* 21 | // Packet data described below. Will only be sent when the robot sends 22 | // the remote a XBEE_RECV_REQ_DATA packet and we must return sequence number 23 | //#define XBEE_TRANS_NEW 0x04 // New Data Available 24 | // No extra data. Will only be sent when we are in NEW only mode 25 | #define XBEE_ENTER_SSC_MODE 0x05 // The controller is letting robot know to enter SSC echo mode 26 | // while in this mode the robot will try to be a pass through to the robot. This code assumes 27 | // cSSC_IN/cSSC_OUT. The robot should probalby send a XBEE_SSC_MODE_EXITED when it decides 28 | // to leave this mode... 29 | // When packet is received, fPacketEnterSSCMode will be set to TRUE. Handlers should probalby 30 | // get robot to a good state and then call XBeeHandleSSCMode, which will return when some exit 31 | // condition is reached. Start of with $$ command as to signal exit 32 | #define XBEE_REQ_SN_NI 0x06 // Request the serial number and NI string 33 | 34 | //#define XBEE_TRANS_CHANGED_DATA 0x07 // We transmite a bit mask with which fields changed plus the bytes that changes 35 | 36 | //#define XBEE_TRANS_NOTHIN_CHANGED 0x08 // 37 | //#define XBEE_TRANS_DATA_VERSION 0x09 // What format of data this transmitter supports. 38 | // 1- New format supports changed data packets... 39 | #define XBEE_DEBUG_ATTACH 0x0A // Debug Attach - used to say send debug info to display 40 | #define XBEE_DEBUG_DETACH 0x0B // End debug output messages... 41 | #define XBEE_DEBUG_STRING 0x0C // Debug Text sent from Debug App... 42 | 43 | //[Packets sent from Robot to remote] 44 | //#define XBEE_RECV_REQ_DATA 0x80 // Request Data Packet* 45 | // Old Format No extra bytes: expect to receive XBEE_TRANS_DATA_PACKET 46 | // New Format 1 extra byte to signal - Will Return 1 of 3 messages... 47 | //#define XBEE_RECV_REQ_NEW 0x81 // Request Only New data 48 | // No Extra bytes goes into New only mode and we will typically 49 | // wait until Remote says it has new data before asking for data. 50 | // In new mode, the remote may choose to choose a threshold of how big a change 51 | // needs to be before sending the XBEE_TRANS_NEW value. 52 | //#define XBEE_RECV_REQ_NEW_OFF 0x82 // We will request data when we want it 53 | //#define XBEE_RECV_NEW_THRESH 0x83 // Set new Data thresholds 54 | // currently not implemented 55 | #define XBEE_RECV_DISP_VAL 0x84 // Display a value on line 2 56 | // If is 0 then we will display the number contained in 57 | // If not zero, then it is a count of bytes in a string to display. 58 | #define XBEE_RECV_DISP_STR 0x85 // Display a string value on line 2 59 | #define XBEE_PLAY_SOUND 0x86 // Will make sounds on the remote... 60 | // - 2 bytes per sound: Duration <0-255>, Sound: to make fit in byte... 61 | #define XBEE_SSC_MODE_EXITED 0x87 // a message sent back to the controller when 62 | // it has left SSC-mode. 63 | #define XBEE_SEND_SN_NI_DATA 0x88 // Response for REQ_SN_NI - will return 64 | // 4 bytes - SNH 65 | // 4 bytes - SNL 66 | // up to 20 bytes(probably 14) for NI 67 | #define XBEE_RECV_DISP_VAL0 0x89 // Display a 2nd value on line 2 - Col 0 on mine 68 | #define XBEE_RECV_DISP_VAL1 0x8A // Display a 2nd value on line 2 69 | #define XBEE_RECV_DISP_VAL2 0x8B // Display a value on line 2 - Cal 70 | 71 | #define XBEE_RECV_REQ_DATA2 0x90 // New format... 72 | 73 | //[XBEE_TRANS_DATA] - has 8 extra bytes 74 | // 0 - Buttons High 75 | // 1 - Buttons Low 76 | // 2 - Right Joystick L/R 77 | // 3 - Right Joystick U/D 78 | // 4 - Left Joystick L/R 79 | // 5 - Left Joystick U/D 80 | // 6 - Right Slider 81 | // 7 - Left Slider 82 | 83 | // OK Lets define some structures... 84 | 85 | // Main data packet 86 | // Main data packet 87 | typedef struct _diypacketOrig { 88 | uint16_t wButtons; // the 16 buttons 89 | uint8_t bRJoyLR; // right joystick X (LR) 90 | uint8_t bRJoyUD; // ..Y (UD) 91 | uint8_t bLJoyLR; // Left Joystick X (LR) 92 | uint8_t bLJoyUD; // Y (UD) 93 | uint8_t bRSlider; // Right Slider 94 | uint8_t bLSlider; // Left Slider 95 | } 96 | DIYPACKETORIG; 97 | // Main data packet 98 | typedef union { 99 | uint8_t ab[12]; 100 | struct { 101 | uint16_t wButtons; // the 16 buttons 102 | uint8_t bRJoyLR; // right joystick X (LR) 103 | uint8_t bRJoyUD; // ..Y (UD) 104 | uint8_t bLJoyLR; // Left Joystick X (LR) 105 | uint8_t bLJoyUD; // Y (UD) 106 | uint8_t bRSlider; // Right Slider 107 | uint8_t bLSlider; // Left Slider 108 | // Added values since first version 109 | uint8_t bRPot; // top Pot on right joystick 110 | uint8_t bLPot; // ... Left joystick 111 | uint8_t bMSlider; // Middle Slider 112 | uint8_t bButtons2; // Extra buttons on new DIY... 113 | } 114 | s; 115 | } 116 | DIYPACKET; 117 | 118 | typedef DIYPACKET *PDIYPACKET; 119 | 120 | 121 | enum { 122 | PKT_BTNLOW=0, // Low Buttons 0-7 123 | PKT_BTNHI, // High buttons 8-F 124 | PKT_RJOYLR, // Right Joystick Up/Down 125 | PKT_RJOYUD, // Right joystick left/Right 126 | PKT_LJOYLR, // Left joystick Left/Right 127 | PKT_LJOYUD, // Left joystick Up/Down 128 | PKT_RSLIDER, // right slider 129 | PKT_LSLIDER, // Left slider 130 | PKT_RPOT, // Right Pot 131 | PKT_LPOT, // Left Pot 132 | PKT_MSLIDER, // Middle Slider 133 | PKT_BTNS2 // Extra buttons like on top of joystick 134 | }; 135 | 136 | 137 | typedef unsigned long ulong; 138 | 139 | // Now define some static state stuff 140 | typedef struct _diystate 141 | { 142 | // state information 143 | boolean fPacketValid; 144 | boolean fNewPacket; 145 | boolean fDataPacketsReceived; 146 | boolean fPacketTimeOut; 147 | uint8_t cbPacketSize; // what was the size of the last data packet received. 148 | // More internal to function... 149 | uint8_t bPacketNum; 150 | uint8_t bTxStatusLast; // status of our last TX message. 151 | uint8_t bAPIPacket[33]; // Api packet 152 | uint16_t wAPIDL; // current destination. 153 | uint16_t wDBGDL; // Debug Destination. 154 | 155 | // Other information, could make static to file... 156 | ulong ulLastPacket; 157 | 158 | } 159 | DIYSTATE; 160 | 161 | #ifdef XBEE_DEBUG_OUTPUT 162 | // Merge in the Debug stuff here... 163 | #define XBEE_DEBUG_MAX_OUTPUT 80 164 | #define XBEE_DEBUG_MAX_INPUT 24 165 | class XBeeDebugSerial : 166 | public Stream 167 | { 168 | private: 169 | uint8_t _abOut[XBEE_DEBUG_MAX_OUTPUT]; 170 | uint8_t _cbOut; 171 | uint8_t _abIn[XBEE_DEBUG_MAX_INPUT]; 172 | uint8_t _cbIn; // simple only one message processed 173 | uint8_t _iIn; // index to next character to return 174 | 175 | public: 176 | // public methods 177 | XBeeDebugSerial(); 178 | ~XBeeDebugSerial(); 179 | void begin(long speed); 180 | 181 | virtual size_t write(uint8_t byte); 182 | virtual int read(); 183 | virtual int available(); 184 | virtual int peek(); 185 | virtual void flush(); 186 | 187 | using Print::write; 188 | 189 | // Function for our XBee code to call to put the data into the input buffer 190 | void SetInputText(uint8_t *pb, uint8_t cb); 191 | 192 | }; 193 | 194 | extern XBeeDebugSerial XBDSerial; 195 | #endif //XBEE_DEBUG_OUTPUT 196 | 197 | 198 | 199 | extern DIYSTATE g_diystate; 200 | 201 | // Forward references some may be moved to external files later 202 | extern void InitXBee(); // assume hard coded for now to UART2... 203 | extern void SendXBeePacket(uint16_t wDL, uint8_t bPHType, uint8_t cbExtra, uint8_t *pbExtra); 204 | extern void XBeeOutputVal(uint16_t w); 205 | extern boolean ReceiveXBeePacket(PDIYPACKET pdiyp); 206 | 207 | #define XBeeOutputString(pString) {SendXBeePacket(g_diystate.wAPIDL, XBEE_RECV_DISP_STR, strlen(pString), (uint8_t*)pString);} 208 | extern void XBeeOutputStringF(const __FlashStringHelper *pString); 209 | #define XBEE_MAX_NOTES 5 210 | extern void XBeePlaySounds(uint8_t cNotes, ...); 211 | 212 | extern void APISendXBeeGetCmd(char c1, char c2); // use this to send other commands as well 213 | extern uint16_t GetXBeeHVal (char c1, char c2); 214 | #define GetXBeeMY() GetXBeeHVal ('M', 'Y') 215 | #define GetXBeeDL() GetXBeeHVal ('D', 'L') 216 | extern void SetXBeeHexVal(char c1, char c2, unsigned long _lval); 217 | 218 | // These functions are the ones to actually talk to the hardware. Should try to make sure 219 | // all of the other functions talk through these... 220 | extern void ClearXBeeInputBuffer(void); 221 | extern boolean XBeeCheckForQueuedBytes(void); 222 | extern void WaitForXBeeTransmitComplete(void); 223 | 224 | extern void ClearInputBuffer(void); 225 | 226 | #if defined(XBeeSerial) 227 | #undef cXBEE_IN 228 | #undef cXBEE_OUT 229 | 230 | #else 231 | extern SoftwareSerial XBeeSoftSerial; 232 | #define XBeeSerial XBeeSoftSerial 233 | #endif 234 | 235 | // Define Some internal debug pin support 236 | #ifdef OPT_DEBUGPINS 237 | #define DEBUGTOGGLE(pin) digitalWrite(pin, !digitalRead(pin)) 238 | #else 239 | #define DEBUGTOGGLE(pin) 240 | #endif 241 | #ifndef DEBUG_PINS_FIRST 242 | #define DEBUG_PINS_FIRST 2 243 | #endif 244 | 245 | 246 | 247 | #endif // _DIYXBEE_H_ 248 | 249 | 250 | -------------------------------------------------------------------------------- /Phoenix_Input_RC/Phoenix_Input_RC.h: -------------------------------------------------------------------------------- 1 | //==================================================================== 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix, control file. 4 | //The control input subroutine for the phoenix software is placed in this file. 5 | //Can be used with V2.0 and above 6 | //Configuration version: V1.0 7 | // 8 | //Hardware setup: RC version 9 | // 10 | //==================================================================== 11 | 12 | // Include the Pin Change code. Can also tell it not to define some Interrupt vectors... 13 | #define NO_PINCHANGE_0 // No Pin changes on 0-7 - Typically Analog pins A0-A5. 14 | // #define NO_PINCHANGE_1 // No Pin changes on 9-15 - On non-mega: D8-13 15 | // #define NO_PINCHANGE_2 // No Pin Changes on 16-23 - non-mega: D0-7 16 | #include "PCInt.h" 17 | 18 | //[CONSTANTS] 19 | enum {RCC_RLR=0, RCC_RUD, RCC_LUD, RCC_LLR, RCC_SWITCH, RCC_KNOB}; 20 | #define WALKMODE 0 21 | #define TRANSLATEMODE 1 22 | #define ROTATEMODE 2 23 | #define SINGLELEGMODE 3 24 | #define GPPLAYERMODE 4 25 | 26 | 27 | #define cTravelDeadZone 4 //The deadzone for the analog input from the remote 28 | #define MAXRCERRORCNT 5 // How many times through the loop will we go before shutting off robot? 29 | 30 | //============================================================================= 31 | // Global - Local to this file only... 32 | //============================================================================= 33 | 34 | // Define an instance of the Input Controller... 35 | InputController g_InputController; // Our Input controller 36 | word g_awRCTimes[RCPIN_COUNT] = {0,0,0, 0, 0, 0}; // to the reciver's channels in the order listed here 37 | static unsigned long g_alRisingEdge[RCPIN_COUNT]; 38 | uint8_t g_bRCValidBits; 39 | boolean g_fRCDataChanged = false; 40 | boolean _fSwitchOn; 41 | boolean _fSwitchOnPrev; 42 | 43 | 44 | static short g_BodyYOffset; 45 | static short g_bRCErrorCnt; 46 | static short g_BodyYShift; 47 | static byte ControlMode; 48 | static bool DoubleHeightOn; 49 | static bool DoubleTravelOn; 50 | static bool WalkMethod; 51 | byte GPSeq; //Number of the sequence 52 | 53 | // some external or forward function references. 54 | extern void PinChanged(uint8_t iRCChannel, uint8_t bPinState, unsigned long ulTime); // one of our pins changed state. 55 | 56 | //============================================================================== 57 | // This is The function that is called by the Main program to initialize 58 | //the input controller, which in this case is the PS2 controller 59 | //process any commands. 60 | //============================================================================== 61 | 62 | // If both PS2 and XBee are defined then we will become secondary to the xbee 63 | void InputController::Init(void) 64 | { 65 | g_BodyYOffset = 0; 66 | g_BodyYShift = 0; 67 | g_bRCErrorCnt = 0; // error count 68 | 69 | ControlMode = WALKMODE; 70 | DoubleHeightOn = false; 71 | DoubleTravelOn = false; 72 | WalkMethod = false; 73 | 74 | // Lets setup the Pin Change Interrupts here... 75 | g_bRCValidBits = 0; 76 | for (byte i=0; i 1500); 125 | } 126 | 127 | if (g_awRCTimes[RCC_KNOB] < 1300) { 128 | if (ControlMode != WALKMODE) { 129 | MSound(1, 50, 2000); //sound SOUND_PIN, [50\4000] 130 | ControlMode = WALKMODE; 131 | } 132 | } else if (g_awRCTimes[RCC_KNOB] < 1500) { 133 | if (ControlMode != TRANSLATEMODE) { 134 | MSound(1, 50, 2000); //sound SOUND_PIN, [50\4000] 135 | ControlMode = TRANSLATEMODE; 136 | } 137 | } else if (g_awRCTimes[RCC_KNOB] < 1700) { 138 | if (ControlMode != ROTATEMODE) { 139 | MSound(1, 50, 2000); //sound SOUND_PIN, [50\4000] 140 | ControlMode = ROTATEMODE; 141 | } 142 | } else { 143 | if (ControlMode != SINGLELEGMODE) { 144 | ControlMode=SINGLELEGMODE; 145 | MSound(1, 50, 2000); //sound SOUND_PIN, [50\4000] 146 | g_InControlState.SelectedLeg = 0; 147 | } 148 | } 149 | 150 | _fSwitchOnPrev = _fSwitchOn; 151 | _fSwitchOn = (g_awRCTimes[RCC_SWITCH] > 1500); 152 | 153 | if (_fSwitchOn != _fSwitchOnPrev) { // Select Button Test 154 | if (ControlMode == WALKMODE) { 155 | //Switch gates 156 | g_InControlState.GaitType = g_InControlState.GaitType+1; // Go to the next gait... 157 | if (g_InControlState.GaitType RC_VALID_MAX)) { 237 | // Received some bad data, lets remember this and setup such that caller can do something appropriate. 238 | g_bRCValidBits = 0; // We have no valid data... 239 | } else { 240 | g_bRCValidBits |= 1 << iRCChannel; 241 | if (w != g_awRCTimes[iRCChannel]) { 242 | g_awRCTimes[iRCChannel] = w; 243 | g_fRCDataChanged = true; 244 | } 245 | } 246 | } 247 | } 248 | 249 | 250 | -------------------------------------------------------------------------------- /Phoenix/Phoenix_PS2_SSC32/Hex_Cfg.h: -------------------------------------------------------------------------------- 1 | 2 | //==================================================================== 3 | //Project Lynxmotion Phoenix 4 | //Description: 5 | // This is the hardware configuration file for the Hex Robot. 6 | // This Header file is specific for Phoenix with 3 DOF 7 | // 8 | // This version of the Configuration file is set up to run on the 9 | // Lynxmotion BotboardDuino board, which is similar to the Arduino Duemilanove 10 | // 11 | // This version of configuration file assumes that the servos will be controlled 12 | // by a Lynxmotion Servo controller SSC-32 and the user is using a Lynxmotion 13 | // PS2 to control the robot. 14 | // 15 | //Date: March 18, 2012 16 | //Programmer: Kurt (aka KurtE) 17 | // 18 | // 19 | //NEW IN V1.0 20 | // - First Release 21 | // 22 | //==================================================================== 23 | #ifndef HEX_CFG_PHOENIX3_H 24 | #define HEX_CFG_PHOENIX3_H 25 | //[CONDITIONAL COMPILING] - COMMENT IF NOT WANTED 26 | // Define other optional compnents to be included or not... 27 | #define OPT_TERMINAL_MONITOR 28 | 29 | #ifdef OPT_TERMINAL_MONITOR // turning off terminal monitor will turn these off as well... 30 | //#define OPT_SSC_FORWARDER // only useful if terminal monitor is enabled 31 | #define OPT_FIND_SERVO_OFFSETS // Only useful if terminal monitor is enabled 32 | #endif 33 | 34 | #define OPT_GPPLAYER 35 | 36 | // Which type of control(s) do you want to compile in 37 | #define DBGSerial Serial 38 | //#define DEBUG_IOPINS 39 | 40 | #if defined(UBRR1H) 41 | #define SSCSerial Serial1 42 | #else 43 | #endif 44 | 45 | #define USEPS2 46 | 47 | //================================================================================================================================== 48 | //================================================================================================================================== 49 | //================================================================================================================================== 50 | // THex-3 51 | //================================================================================================================================== 52 | #define USE_SSC32 53 | //#define cSSC_BINARYMODE 1 // Define if your SSC-32 card supports binary mode. 54 | 55 | //[SERIAL CONNECTIONS] 56 | 57 | 58 | // Warning I will undefine some components as the non-megas don't have enough memory... 59 | //#undef OPT_FIND_SERVO_OFFSETS 60 | 61 | #define cSSC_BAUD 38400 //SSC32 BAUD rate 62 | 63 | //-------------------------------------------------------------------- 64 | //[Botboarduino Pin Numbers] 65 | #define SOUND_PIN 5 // Botboarduino JR pin number 66 | #define PS2_DAT 6 67 | #define PS2_CMD 7 68 | #define PS2_SEL 8 69 | #define PS2_CLK 9 70 | // If we are using a SSC-32 then: 71 | // If were are running on an Arduino Mega we will use one of the hardware serial port, default to Serial1 above. 72 | // If on Non mega, if the IO pins are set to 0, we will overload the hardware Serial port 73 | // Else we will user SoftwareSerial to talk to the SSC-32 74 | #define cSSC_OUT 12 //Output pin for (SSC32 RX) on BotBoard (Yellow) 75 | #define cSSC_IN 13 //Input pin for (SSC32 TX) on BotBoard (Blue) 76 | 77 | //==================================================================== 78 | //[SSC PIN NUMBERS] 79 | #define cRRCoxaPin 0 //Rear Right leg Hip Horizontal 80 | #define cRRFemurPin 1 //Rear Right leg Hip Vertical 81 | #define cRRTibiaPin 2 //Rear Right leg Knee 82 | #define cRRTarsPin 3 // Tar 83 | 84 | #define cRMCoxaPin 4 //Middle Right leg Hip Horizontal 85 | #define cRMFemurPin 5 //Middle Right leg Hip Vertical 86 | #define cRMTibiaPin 6 //Middle Right leg Knee 87 | #define cRMTarsPin 7 // Tar 88 | 89 | #define cRFCoxaPin 8 //Front Right leg Hip Horizontal 90 | #define cRFFemurPin 9 //Front Right leg Hip Vertical 91 | #define cRFTibiaPin 10 //Front Right leg Knee 92 | #define cRFTarsPin 11 // Tar 93 | 94 | #define cLRCoxaPin 16 //Rear Left leg Hip Horizontal 95 | #define cLRFemurPin 17 //Rear Left leg Hip Vertical 96 | #define cLRTibiaPin 18 //Rear Left leg Knee 97 | #define cLRTarsPin 19 // Tar 98 | 99 | #define cLMCoxaPin 20 //Middle Left leg Hip Horizontal 100 | #define cLMFemurPin 21 //Middle Left leg Hip Vertical 101 | #define cLMTibiaPin 22 //Middle Left leg Knee 102 | #define cLMTarsPin 23 // Tar 103 | 104 | #define cLFCoxaPin 24 //Front Left leg Hip Horizontal 105 | #define cLFFemurPin 25 //Front Left leg Hip Vertical 106 | #define cLFTibiaPin 26 //Front Left leg Knee 107 | #define cLFTarsPin 27 // Tar 108 | 109 | 110 | //-------------------------------------------------------------------- 111 | //[MIN/MAX ANGLES] 112 | #define cRRCoxaMin1 -260 //Mechanical limits of the Right Rear Leg, decimals = 1 113 | #define cRRCoxaMax1 740 114 | #define cRRFemurMin1 -1010 115 | #define cRRFemurMax1 950 116 | #define cRRTibiaMin1 -1060 117 | #define cRRTibiaMax1 770 118 | 119 | #define cRMCoxaMin1 -530 //Mechanical limits of the Right Middle Leg, decimals = 1 120 | #define cRMCoxaMax1 530 121 | #define cRMFemurMin1 -1010 122 | #define cRMFemurMax1 950 123 | #define cRMTibiaMin1 -1060 124 | #define cRMTibiaMax1 770 125 | 126 | #define cRFCoxaMin1 -580 //Mechanical limits of the Right Front Leg, decimals = 1 127 | #define cRFCoxaMax1 740 128 | #define cRFFemurMin1 -1010 129 | #define cRFFemurMax1 950 130 | #define cRFTibiaMin1 -1060 131 | #define cRFTibiaMax1 770 132 | 133 | #define cLRCoxaMin1 -740 //Mechanical limits of the Left Rear Leg, decimals = 1 134 | #define cLRCoxaMax1 260 135 | #define cLRFemurMin1 -950 136 | #define cLRFemurMax1 1010 137 | #define cLRTibiaMin1 -770 138 | #define cLRTibiaMax1 1060 139 | 140 | #define cLMCoxaMin1 -530 //Mechanical limits of the Left Middle Leg, decimals = 1 141 | #define cLMCoxaMax1 530 142 | #define cLMFemurMin1 -950 143 | #define cLMFemurMax1 1010 144 | #define cLMTibiaMin1 -770 145 | #define cLMTibiaMax1 1060 146 | 147 | #define cLFCoxaMin1 -740 //Mechanical limits of the Left Front Leg, decimals = 1 148 | #define cLFCoxaMax1 580 149 | #define cLFFemurMin1 -950 150 | #define cLFFemurMax1 1010 151 | #define cLFTibiaMin1 -770 152 | #define cLFTibiaMax1 1060 153 | 154 | 155 | //-------------------------------------------------------------------- 156 | //[LEG DIMENSIONS] 157 | //Universal dimensions for each leg in mm 158 | #define cXXCoxaLength 29 // This is for TH3-R legs 159 | #define cXXFemurLength 76 160 | #define cXXTibiaLength 106 161 | #define cXXTarsLength 85 // 4DOF only... 162 | 163 | #define cRRCoxaLength cXXCoxaLength //Right Rear leg 164 | #define cRRFemurLength cXXFemurLength 165 | #define cRRTibiaLength cXXTibiaLength 166 | #define cRRTarsLength cXXTarsLength //4DOF ONLY 167 | 168 | #define cRMCoxaLength cXXCoxaLength //Right middle leg 169 | #define cRMFemurLength cXXFemurLength 170 | #define cRMTibiaLength cXXTibiaLength 171 | #define cRMTarsLength cXXTarsLength //4DOF ONLY 172 | 173 | #define cRFCoxaLength cXXCoxaLength //Rigth front leg 174 | #define cRFFemurLength cXXFemurLength 175 | #define cRFTibiaLength cXXTibiaLength 176 | #define cRFTarsLength cXXTarsLength //4DOF ONLY 177 | 178 | #define cLRCoxaLength cXXCoxaLength //Left Rear leg 179 | #define cLRFemurLength cXXFemurLength 180 | #define cLRTibiaLength cXXTibiaLength 181 | #define cLRTarsLength cXXTarsLength //4DOF ONLY 182 | 183 | #define cLMCoxaLength cXXCoxaLength //Left middle leg 184 | #define cLMFemurLength cXXFemurLength 185 | #define cLMTibiaLength cXXTibiaLength 186 | #define cLMTarsLength cXXTarsLength //4DOF ONLY 187 | 188 | #define cLFCoxaLength cXXCoxaLength //Left front leg 189 | #define cLFFemurLength cXXFemurLength 190 | #define cLFTibiaLength cXXTibiaLength 191 | #define cLFTarsLength cXXTarsLength //4DOF ONLY 192 | 193 | 194 | //-------------------------------------------------------------------- 195 | //[BODY DIMENSIONS] 196 | #define cRRCoxaAngle1 -600 //Default Coxa setup angle, decimals = 1 197 | #define cRMCoxaAngle1 0 //Default Coxa setup angle, decimals = 1 198 | #define cRFCoxaAngle1 600 //Default Coxa setup angle, decimals = 1 199 | #define cLRCoxaAngle1 -600 //Default Coxa setup angle, decimals = 1 200 | #define cLMCoxaAngle1 0 //Default Coxa setup angle, decimals = 1 201 | #define cLFCoxaAngle1 600 //Default Coxa setup angle, decimals = 1 202 | 203 | #define cRROffsetX -43 //Distance X from center of the body to the Right Rear coxa 204 | #define cRROffsetZ 82 //Distance Z from center of the body to the Right Rear coxa 205 | #define cRMOffsetX -63 //Distance X from center of the body to the Right Middle coxa 206 | #define cRMOffsetZ 0 //Distance Z from center of the body to the Right Middle coxa 207 | #define cRFOffsetX -43 //Distance X from center of the body to the Right Front coxa 208 | #define cRFOffsetZ -82 //Distance Z from center of the body to the Right Front coxa 209 | 210 | #define cLROffsetX 43 //Distance X from center of the body to the Left Rear coxa 211 | #define cLROffsetZ 82 //Distance Z from center of the body to the Left Rear coxa 212 | #define cLMOffsetX 63 //Distance X from center of the body to the Left Middle coxa 213 | #define cLMOffsetZ 0 //Distance Z from center of the body to the Left Middle coxa 214 | #define cLFOffsetX 43 //Distance X from center of the body to the Left Front coxa 215 | #define cLFOffsetZ -82 //Distance Z from center of the body to the Left Front coxa 216 | 217 | //-------------------------------------------------------------------- 218 | //[START POSITIONS FEET] 219 | #define cHexInitXZ 105 220 | #define CHexInitXZCos60 53 // COS(60) = .5 221 | #define CHexInitXZSin60 91 // sin(60) = .866 222 | #define CHexInitY 25 223 | 224 | #define cRRInitPosX CHexInitXZCos60 //Start positions of the Right Rear leg 225 | #define cRRInitPosY CHexInitY 226 | #define cRRInitPosZ CHexInitXZSin60 227 | 228 | #define cRMInitPosX cHexInitXZ //Start positions of the Right Middle leg 229 | #define cRMInitPosY CHexInitY 230 | #define cRMInitPosZ 0 231 | 232 | #define cRFInitPosX CHexInitXZCos60 //Start positions of the Right Front leg 233 | #define cRFInitPosY CHexInitY 234 | #define cRFInitPosZ -CHexInitXZSin60 235 | 236 | #define cLRInitPosX CHexInitXZCos60 //Start positions of the Left Rear leg 237 | #define cLRInitPosY CHexInitY 238 | #define cLRInitPosZ CHexInitXZSin60 239 | 240 | #define cLMInitPosX cHexInitXZ //Start positions of the Left Middle leg 241 | #define cLMInitPosY CHexInitY 242 | #define cLMInitPosZ 0 243 | 244 | #define cLFInitPosX CHexInitXZCos60 //Start positions of the Left Front leg 245 | #define cLFInitPosY CHexInitY 246 | #define cLFInitPosZ -CHexInitXZSin60 247 | 248 | #endif CFG_HEX_H 249 | 250 | 251 | 252 | -------------------------------------------------------------------------------- /Phoenix/LSQuadA_PS2_SSC32/Hex_Cfg.h: -------------------------------------------------------------------------------- 1 | //==================================================================== 2 | //Project Lynxmotion Phoenix 3 | //Description: 4 | // This is the hardware configuration for a Lynxmotion Symetrical Quad 5 | // using type A legs. 6 | // 7 | // This version of the Configuration file is set up to run on the 8 | // Lynxmotion BotboardDuino board, which is similar to the Arduino Duemilanove 9 | // 10 | // This version of configuration file assumes that the servos will be controlled 11 | // by a Lynxmotion Servo controller SSC-32 and the user is using a Lynxmotion 12 | // PS2 to control the robot. 13 | // 14 | // 15 | //NEW IN V1.0 16 | // - First Release 17 | // 18 | //==================================================================== 19 | #ifndef LSQUADA_CFG_H 20 | #define LSQUADA_CFG_H 21 | 22 | 23 | // Which type of control(s) do you want to compile in 24 | 25 | //#define DEBUG 26 | 27 | #ifdef __AVR__ 28 | #if defined(UBRR1H) 29 | #define SSCSerial Serial1 30 | #define XBeeSerial Serial3 //Serial2 31 | #else 32 | #define XBeeSerial Serial 33 | #define DontAllowDebug 34 | #endif 35 | #else 36 | // For non AVR processors like Teensy assume Serial1... 37 | #define SSCSerial Serial1 38 | #endif 39 | 40 | //================================================================================================================================== 41 | // Define which input classes we will use. If we wish to use more than one we need to define USEMULTI - This will define a forwarder 42 | // type implementation, that the Inputcontroller will need to call. There will be some negotion for which one is in contol. 43 | // 44 | // If this is not defined, The included Controller should simply implement the InputController Class... 45 | //================================================================================================================================== 46 | #define QUADMODE // We are building for quad support... 47 | 48 | //#define USEMULTI 49 | //#define USEXBEE // only allow to be defined on Megas... 50 | #define USEPS2 51 | //#define USECOMMANDER 52 | //#define USESERIAL 53 | 54 | // Do we want Debug Serial Output? 55 | #define DBGSerial Serial 56 | 57 | // Some configurations will not allow this so if one of them undefine it 58 | #if (defined USEXBEE) || (defined USECOMMANDER) 59 | #ifdef DontAllowDebug 60 | #undef DBGSerial 61 | #endif 62 | #endif 63 | 64 | #ifdef USESERIAL 65 | #undef DBGSerial 66 | #endif 67 | 68 | #ifdef DBGSerial 69 | #define OPT_TERMINAL_MONITOR // Only allow this to be defined if we have a debug serial port 70 | #endif 71 | 72 | #ifdef OPT_TERMINAL_MONITOR 73 | //#define OPT_SSC_FORWARDER // only useful if terminal monitor is enabled 74 | #define OPT_FIND_SERVO_OFFSETS // Only useful if terminal monitor is enabled 75 | #endif 76 | 77 | //#define OPT_GPPLAYER 78 | 79 | #define USE_SSC32 80 | //#define cSSC_BINARYMODE // Define if your SSC-32 card supports binary mode. 81 | #define cSSC_BAUD 38400 //SSC32 BAUD rate 82 | 83 | // Debug options 84 | //#define DEBUG_IOPINS // used to control if we are going to use IO pins for debug support 85 | 86 | //================================================================================================================================== 87 | //================================================================================================================================== 88 | //================================================================================================================================== 89 | // Lynxmotion Symetrical Quad 90 | //================================================================================================================================== 91 | 92 | //[Assuming Botboarduino for this one 93 | #define SOUND_PIN 5 // Botboarduino JR pin number 94 | 95 | // PS2 definitions 96 | #define PS2_DAT 6 97 | #define PS2_CMD 7 98 | #define PS2_SEL 8 99 | #define PS2_CLK 9 100 | 101 | #define cSSC_OUT 10 //Output pin for (SSC32 RX) on BotBoard (Yellow) 102 | #define cSSC_IN 11 //Input pin for (SSC32 TX) on BotBoard (Blue) 103 | // XBee was defined to use a hardware Serial port 104 | #define XBEE_BAUD 38400 105 | #define SERIAL_BAUD 38400 106 | 107 | // Define Analog pin and minimum voltage that we will allow the servos to run 108 | #define cVoltagePin 0 // Use our Analog pin jumper here... 109 | #define cTurnOffVol 470 // 4.7v 110 | #define cTurnOnVol 550 // 5.5V - optional part to say if voltage goes back up, turn it back on... 111 | 112 | //==================================================================== 113 | //[SSC32 Pin Numbers] 114 | #define cRRCoxaPin 0 //Rear Right leg Hip Horizontal 115 | #define cRRFemurPin 1 //Rear Right leg Hip Vertical 116 | #define cRRTibiaPin 2 //Rear Right leg Knee 117 | #define cRRTarsPin 3 // Tar 118 | 119 | #define cRFCoxaPin 8 //Front Right leg Hip Horizontal 120 | #define cRFFemurPin 9 //Front Right leg Hip Vertical 121 | #define cRFTibiaPin 10 //Front Right leg Knee 122 | #define cRFTarsPin 11 // Tar 123 | 124 | #define cLRCoxaPin 16 //Rear Left leg Hip Horizontal 125 | #define cLRFemurPin 17 //Rear Left leg Hip Vertical 126 | #define cLRTibiaPin 18 //Rear Left leg Knee 127 | #define cLRTarsPin 19 // Tar 128 | 129 | #define cLFCoxaPin 24 //Front Left leg Hip Horizontal 130 | #define cLFFemurPin 25 //Front Left leg Hip Vertical 131 | #define cLFTibiaPin 26 //Front Left leg Knee 132 | #define cLFTarsPin 27 // Tar 133 | 134 | //-------------------------------------------------------------------- 135 | //[SERVO PULSE INVERSE] 136 | #define cRRCoxaInv 1 137 | #define cRRFemurInv 0 138 | #define cRRTibiaInv 0 139 | #define cRRTarsInv 0 140 | 141 | #define cRFCoxaInv 1 142 | #define cRFFemurInv 1 143 | #define cRFTibiaInv 1 144 | #define cRFTarsInv 1 145 | 146 | #define cLRCoxaInv 0 147 | #define cLRFemurInv 1 148 | #define cLRTibiaInv 1 149 | #define cLRTarsInv 1 150 | 151 | #define cLFCoxaInv 0 152 | #define cLFFemurInv 0 153 | #define cLFTibiaInv 0 154 | #define cLFTarsInv 0 155 | 156 | //-------------------------------------------------------------------- 157 | //[MIN/MAX ANGLES] 158 | #define cRRCoxaMin1 -650 //Mechanical limits of the Right Rear Leg 159 | #define cRRCoxaMax1 650 160 | #define cRRFemurMin1 -1050 161 | #define cRRFemurMax1 750 162 | #define cRRTibiaMin1 -420 163 | #define cRRTibiaMax1 900 164 | #define cRRTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 165 | #define cRRTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 166 | 167 | #define cRFCoxaMin1 -650 //Mechanical limits of the Right Front Leg 168 | #define cRFCoxaMax1 650 169 | #define cRFFemurMin1 -1050 170 | #define cRFFemurMax1 750 171 | #define cRFTibiaMin1 -420 172 | #define cRFTibiaMax1 900 173 | #define cRFTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 174 | #define cRFTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 175 | 176 | #define cLRCoxaMin1 -650 //Mechanical limits of the Left Rear Leg 177 | #define cLRCoxaMax1 650 178 | #define cLRFemurMin1 -1050 179 | #define cLRFemurMax1 750 180 | #define cLRTibiaMin1 -420 181 | #define cLRTibiaMax1 900 182 | #define cLRTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 183 | #define cLRTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 184 | 185 | #define cLFCoxaMin1 -650 //Mechanical limits of the Left Front Leg 186 | #define cLFCoxaMax1 650 187 | #define cLFFemurMin1 -1050 188 | #define cLFFemurMax1 750 189 | #define cLFTibiaMin1 -420 190 | #define cLFTibiaMax1 900 191 | #define cLFTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 192 | #define cLFTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 193 | 194 | //-------------------------------------------------------------------- 195 | //[LEG DIMENSIONS] 196 | //Universal dimensions for each leg in mm 197 | #define cXXCoxaLength 29 // This is for CH3-R with Type 3 legs 198 | #define cXXFemurLength 57 199 | #define cXXTibiaLength 141 200 | #define cXXTarsLength 85 // 4DOF only... 201 | 202 | #define cRRCoxaLength cXXCoxaLength //Right Rear leg 203 | #define cRRFemurLength cXXFemurLength 204 | #define cRRTibiaLength cXXTibiaLength 205 | #define cRRTarsLength cXXTarsLength //4DOF ONLY 206 | 207 | #define cRFCoxaLength cXXCoxaLength //Rigth front leg 208 | #define cRFFemurLength cXXFemurLength 209 | #define cRFTibiaLength cXXTibiaLength 210 | #define cRFTarsLength cXXTarsLength //4DOF ONLY 211 | 212 | #define cLRCoxaLength cXXCoxaLength //Left Rear leg 213 | #define cLRFemurLength cXXFemurLength 214 | #define cLRTibiaLength cXXTibiaLength 215 | #define cLRTarsLength cXXTarsLength //4DOF ONLY 216 | 217 | #define cLFCoxaLength cXXCoxaLength //Left front leg 218 | #define cLFFemurLength cXXFemurLength 219 | #define cLFTibiaLength cXXTibiaLength 220 | #define cLFTarsLength cXXTarsLength //4DOF ONLY 221 | 222 | 223 | //-------------------------------------------------------------------- 224 | //[BODY DIMENSIONS] 225 | #define cRRCoxaAngle1 -450 //Default Coxa setup angle, decimals = 1 226 | #define cRFCoxaAngle1 450 //Default Coxa setup angle, decimals = 1 227 | #define cLRCoxaAngle1 -450 //Default Coxa setup angle, decimals = 1 228 | #define cLFCoxaAngle1 450 //Default Coxa setup angle, decimals = 1 229 | 230 | #define cRROffsetX -54 //Distance X from center of the body to the Right Rear coxa 231 | #define cRROffsetZ 54 //Distance Z from center of the body to the Right Rear coxa 232 | #define cRFOffsetX -54 //Distance X from center of the body to the Right Front coxa 233 | #define cRFOffsetZ -54 //Distance Z from center of the body to the Right Front coxa 234 | 235 | #define cLROffsetX 54 //Distance X from center of the body to the Left Rear coxa 236 | #define cLROffsetZ 54 //Distance Z from center of the body to the Left Rear coxa 237 | #define cLFOffsetX 54 //Distance X from center of the body to the Left Front coxa 238 | #define cLFOffsetZ -54 //Distance Z from center of the body to the Left Front coxa 239 | 240 | //-------------------------------------------------------------------- 241 | //[START POSITIONS FEET] 242 | #define cHexInitXZ 110 243 | #define CHexInitXZCos60 55 // COS(60) = .5 244 | #define CHexInitXZSin60 95 // sin(60) = .866 245 | #define CHexInitXZ45 78 // Sin and cos(45) .7071 246 | #define CHexInitY 60 //30 247 | 248 | #if 1 249 | #define cRRInitPosX CHexInitXZ45 //Start positions of the Right Rear leg 250 | #define cRRInitPosY CHexInitY 251 | #define cRRInitPosZ CHexInitXZ45 252 | 253 | #define cRFInitPosX CHexInitXZ45 //Start positions of the Right Front leg 254 | #define cRFInitPosY CHexInitY 255 | #define cRFInitPosZ -CHexInitXZ45 256 | 257 | #define cLRInitPosX CHexInitXZ45 //Start positions of the Left Rear leg 258 | #define cLRInitPosY CHexInitY 259 | #define cLRInitPosZ CHexInitXZ45 260 | 261 | #define cLFInitPosX CHexInitXZ45 //Start positions of the Left Front leg 262 | #define cLFInitPosY CHexInitY 263 | #define cLFInitPosZ -CHexInitXZ45 264 | 265 | 266 | #else 267 | #define cRRInitPosX cHexInitXZ //Start positions of the Right Rear leg 268 | #define cRRInitPosY CHexInitY 269 | #define cRRInitPosZ 0 270 | 271 | #define cRFInitPosX cHexInitXZ //Start positions of the Right Front leg 272 | #define cRFInitPosY CHexInitY 273 | #define cRFInitPosZ 0 274 | 275 | #define cLRInitPosX CHexInitXZCos60 //Start positions of the Left Rear leg 276 | #define cLRInitPosY CHexInitY 277 | #define cLRInitPosZ 0 278 | 279 | #define cLFInitPosX cHexInitXZ //Start positions of the Left Front leg 280 | #define cLFInitPosY CHexInitY 281 | #define cLFInitPosZ 0 282 | #endif 283 | //-------------------------------------------------------------------- 284 | //[Tars factors used in formula to calc Tarsus angle relative to the ground] 285 | #define cTarsConst 720 //4DOF ONLY 286 | #define cTarsMulti 2 //4DOF ONLY 287 | #define cTarsFactorA 70 //4DOF ONLY 288 | #define cTarsFactorB 60 //4DOF ONLY 289 | #define cTarsFactorC 50 //4DOF ONLY 290 | 291 | #endif CFG_HEX_H 292 | 293 | -------------------------------------------------------------------------------- /Phoenix/Phoenix.h: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | // 5 | //Programmer: Jeroen Janssen [aka Xan] 6 | // Kurt Eckhardt(KurtE) converted to C and Arduino 7 | // Kare Halvorsen aka Zenta - Makes everything work correctly! 8 | // 9 | // This version of the Phoenix code was ported over to the Arduino Environement 10 | // 11 | // 12 | // Phoenix.h - This is the first header file that is needed to build 13 | // a Phoenix program for a specific Hex Robot. 14 | // 15 | // 16 | // This file assumes that the main source file either directly or through include 17 | // file has defined all of the configuration information for the specific robot. 18 | // Each robot will also need to include: 19 | // 20 | //============================================================================= 21 | // 22 | //KNOWN BUGS: 23 | // - Lots ;) 24 | // 25 | //============================================================================= 26 | //============================================================================== 27 | #ifndef _PHOENIX_CORE_H_ 28 | #define _PHOENIX_CORE_H_ 29 | #include 30 | //#include 31 | #if defined(__SAM3X8E__) 32 | #define PROGMEM 33 | #define pgm_read_byte(x) (*((char *)x)) 34 | // #define pgm_read_word(x) (*((short *)(x & 0xfffffffe))) 35 | #define pgm_read_word(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) 36 | #define pgm_read_byte_near(x) (*((char *)x)) 37 | #define pgm_read_byte_far(x) (*((char *)x)) 38 | // #define pgm_read_word_near(x) (*((short *)(x & 0xfffffffe)) 39 | // #define pgm_read_word_far(x) (*((short *)(x & 0xfffffffe))) 40 | #define pgm_read_word_near(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) 41 | #define pgm_read_word_far(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x)))) 42 | #define PSTR(x) x 43 | #endif 44 | 45 | #ifdef USEXBEE 46 | #include "diyxbee.h" 47 | #endif 48 | 49 | //============================================================================= 50 | //[CONSTANTS] 51 | //============================================================================= 52 | #define BUTTON_DOWN 0 53 | #define BUTTON_UP 1 54 | 55 | #define c1DEC 10 56 | #define c2DEC 100 57 | #define c4DEC 10000 58 | #define c6DEC 1000000 59 | 60 | #ifdef QUADMODE 61 | enum { 62 | cRR=0, cRF, cLR, cLF, CNT_LEGS}; 63 | #else 64 | enum { 65 | cRR=0, cRM, cRF, cLR, cLM, cLF, CNT_LEGS}; 66 | #endif 67 | 68 | #define WTIMERTICSPERMSMUL 64 // BAP28 is 16mhz need a multiplyer and divider to make the conversion with /8192 69 | #define WTIMERTICSPERMSDIV 125 // 70 | #define USEINT_TIMERAV 71 | 72 | 73 | // BUGBUG: to make Dynamic first pass simpl make it a variable. 74 | extern byte NUM_GAITS; 75 | #define SmDiv 4 //"Smooth division" factor for the smooth control function, a value of 3 to 5 is most suitable 76 | extern void GaitSelect(void); 77 | extern short SmoothControl (short CtrlMoveInp, short CtrlMoveOut, byte CtrlDivider); 78 | 79 | 80 | 81 | //----------------------------------------------------------------------------- 82 | // Define Global variables 83 | //----------------------------------------------------------------------------- 84 | extern boolean g_fDebugOutput; 85 | extern boolean g_fEnableServos; // Hack to allow me to turn servo processing off... 86 | extern boolean g_fRobotUpsideDown; // Is the robot upside down? 87 | 88 | 89 | extern void MSound(byte cNotes, ...); 90 | extern boolean CheckVoltage(void); 91 | 92 | extern word GetLegsXZLength(void); 93 | extern void AdjustLegPositions(word XZLength1); 94 | extern void AdjustLegPositionsToBodyHeight(); 95 | extern void ResetLegInitAngles(void); 96 | extern void RotateLegInitAngles (int iDeltaAngle); 97 | extern long GetCmdLineNum(byte **ppszCmdLine); 98 | 99 | // debug handler... 100 | extern boolean g_fDBGHandleError; 101 | 102 | #ifdef c4DOF 103 | extern const byte cTarsLength[] PROGMEM; 104 | #endif 105 | 106 | #ifdef OPT_BACKGROUND_PROCESS 107 | #define DoBackgroundProcess() g_ServoDriver.BackgroundProcess() 108 | #else 109 | #define DoBackgroundProcess() 110 | #endif 111 | 112 | #ifdef DEBUG_IOPINS 113 | #define DebugToggle(pin) {digitalWrite(pin, !digitalRead(pin));} 114 | #define DebugWrite(pin, state) {digitalWrite(pin, state);} 115 | #else 116 | #define DebugToggle(pin) {;} 117 | #define DebugWrite(pin, state) {;} 118 | #endif 119 | 120 | 121 | 122 | #ifdef __AVR__ 123 | #if not defined(UBRR1H) 124 | #if cSSC_IN != 0 125 | extern SoftwareSerial SSCSerial; 126 | #endif 127 | #endif 128 | #endif 129 | #if defined(__PIC32MX__) 130 | #if defined F 131 | #undef F 132 | #endif 133 | #define F(X) (X) 134 | #endif 135 | 136 | 137 | 138 | //============================================================================= 139 | //============================================================================= 140 | // Define the class(s) for our Input controllers. 141 | //============================================================================= 142 | //============================================================================= 143 | class InputController { 144 | public: 145 | virtual void Init(void); 146 | virtual void ControlInput(void); 147 | virtual void AllowControllerInterrupts(boolean fAllow); 148 | 149 | #ifdef OPT_TERMINAL_MONITOR_IC // Allow Input controller to define stuff as well 150 | void ShowTerminalCommandList(void); 151 | boolean ProcessTerminalCommand(byte *psz, byte bLen); 152 | #endif 153 | 154 | private: 155 | } 156 | ; 157 | 158 | // Define a function that allows us to define which controllers are to be used. 159 | extern void RegisterInputController(InputController *pic); 160 | 161 | 162 | 163 | typedef struct _Coord3D { 164 | long x; 165 | long y; 166 | long z; 167 | } 168 | COORD3D; 169 | 170 | //============================================================================== 171 | // Define Gait structure/class - Hopefully allow specific robots to define their 172 | // own gaits and/or define which of the standard ones they want. 173 | //============================================================================== 174 | typedef struct _PhoenixGait { 175 | short NomGaitSpeed; //Nominal speed of the gait 176 | byte StepsInGait; //Number of steps in gait 177 | byte NrLiftedPos; //Number of positions that a single leg is lifted [1-3] 178 | byte FrontDownPos; //Where the leg should be put down to ground 179 | byte LiftDivFactor; //Normaly: 2, when NrLiftedPos=5: 4 180 | byte TLDivFactor; //Number of steps that a leg is on the floor while walking 181 | byte HalfLiftHeight; // How high to lift at halfway up. 182 | 183 | #ifdef QUADMODE 184 | // Extra information used in the Quad balance mode 185 | word COGAngleStart1; // COG shifting starting angle 186 | word COGAngleStep1; // COG Angle Steps in degrees 187 | byte COGRadius; // COG Radius; the amount the body shifts 188 | boolean COGCCW; // COG Gait sequence runs counter clock wise 189 | #endif 190 | byte GaitLegNr[CNT_LEGS]; //Init position of the leg 191 | #ifdef DISPLAY_GAIT_NAMES 192 | PGM_P pszName; // The gait name 193 | #endif 194 | } 195 | PHOENIXGAIT; 196 | 197 | #ifdef DISPLAY_GAIT_NAMES 198 | #define GAITNAME(name) ,name 199 | #else 200 | #define GAITNAME(name) 201 | #endif 202 | 203 | //============================================================================== 204 | // class ControlState: This is the main structure of data that the Control 205 | // manipulates and is used by the main Phoenix Code to make it do what is 206 | // requested. 207 | //============================================================================== 208 | typedef struct _InControlState { 209 | boolean fRobotOn; //Switch to turn on Phoenix 210 | boolean fPrev_RobotOn; //Previous loop state 211 | //Body position 212 | COORD3D BodyPos; 213 | COORD3D BodyRotOffset; // Body rotation offset; 214 | 215 | //Body Inverse Kinematics 216 | COORD3D BodyRot1; // X -Pitch, Y-Rotation, Z-Roll 217 | 218 | //[gait] 219 | byte GaitType; //Gait type 220 | byte GaitStep; //Actual current step in gait 221 | PHOENIXGAIT gaitCur; // Definition of the current gait 222 | 223 | short LegLiftHeight; //Current Travel height 224 | COORD3D TravelLength; // X-Z or Length, Y is rotation. 225 | 226 | #ifdef cTurretRotPin 227 | // Turret information 228 | int TurretRotAngle1; // Rotation of turrent in 10ths of degree 229 | int TurretTiltAngle1; // the tile for the turret 230 | #endif 231 | 232 | //[Single Leg Control] 233 | #ifdef OPT_SINGLELEG 234 | byte SelectedLeg; 235 | COORD3D SLLeg; // 236 | boolean fSLHold; //Single leg control mode 237 | #endif 238 | 239 | //[Balance] 240 | boolean BalanceMode; 241 | 242 | //[TIMING] 243 | byte InputTimeDelay; //Delay that depends on the input to get the "sneaking" effect 244 | word SpeedControl; //Adjustible Delay 245 | byte ForceGaitStepCnt; // new to allow us to force a step even when not moving 246 | 247 | #ifdef OPT_DYNAMIC_ADJUST_LEGS 248 | short aCoxaInitAngle1[CNT_LEGS]; 249 | #endif 250 | 251 | // 252 | 253 | } 254 | INCONTROLSTATE; 255 | 256 | //============================================================================== 257 | //============================================================================== 258 | // Define the class(s) for Servo Drivers. 259 | //============================================================================== 260 | //============================================================================== 261 | class ServoDriver { 262 | public: 263 | void Init(void); 264 | 265 | uint16_t GetBatteryVoltage(void); 266 | 267 | #ifdef OPT_GPPLAYER 268 | inline boolean FIsGPEnabled(void) { 269 | return _fGPEnabled; 270 | }; 271 | boolean FIsGPSeqDefined(uint8_t iSeq); 272 | inline boolean FIsGPSeqActive(void) { 273 | return _fGPActive; 274 | }; 275 | void GPStartSeq(uint8_t iSeq); // 0xff - says to abort... 276 | void GPPlayer(void); 277 | uint8_t GPNumSteps(void); // How many steps does the current sequence have 278 | uint8_t GPCurStep(void); // Return which step currently on... 279 | void GPSetSpeedMultiplyer(short sm) ; // Set the Speed multiplier (100 is default) 280 | #endif 281 | void BeginServoUpdate(void); // Start the update 282 | #ifdef c4DOF 283 | void OutputServoInfoForLeg(byte LegIndex, short sCoxaAngle1, short sFemurAngle1, short sTibiaAngle1, short sTarsAngle1); 284 | #else 285 | void OutputServoInfoForLeg(byte LegIndex, short sCoxaAngle1, short sFemurAngle1, short sTibiaAngle1); 286 | #endif 287 | #ifdef cTurretRotPin 288 | void OutputServoInfoForTurret(short sRotateAngle1, short sTiltAngle1); 289 | #endif 290 | void CommitServoDriver(word wMoveTime); 291 | void FreeServos(void); 292 | 293 | void IdleTime(void); // called when the main loop when the robot is not on 294 | 295 | // Allow for background process to happen... 296 | #ifdef OPT_BACKGROUND_PROCESS 297 | void BackgroundProcess(void); 298 | #endif 299 | 300 | #ifdef OPT_TERMINAL_MONITOR 301 | void ShowTerminalCommandList(void); 302 | boolean ProcessTerminalCommand(byte *psz, byte bLen); 303 | #endif 304 | 305 | private: 306 | 307 | #ifdef OPT_GPPLAYER 308 | boolean _fGPEnabled; // IS GP defined for this servo driver? 309 | boolean _fGPActive; // Is a sequence currently active - May change later when we integrate in sequence timing adjustment code 310 | uint8_t _iSeq; // current sequence we are running 311 | short _sGPSM; // Speed multiplier +-200 312 | #endif 313 | 314 | } 315 | ; 316 | 317 | //============================================================================== 318 | //============================================================================== 319 | // Define global class objects 320 | //============================================================================== 321 | //============================================================================== 322 | extern ServoDriver g_ServoDriver; // our global servo driver class 323 | extern InputController g_InputController; // Our Input controller 324 | extern INCONTROLSTATE g_InControlState; // State information that controller changes 325 | 326 | 327 | #endif 328 | 329 | -------------------------------------------------------------------------------- /Phoenix/THex_PS2_SSC32/Hex_Cfg.h: -------------------------------------------------------------------------------- 1 | 2 | //==================================================================== 3 | //Project Lynxmotion Phoenix 4 | //Description: 5 | // This is the hardware configuration file for the Hex Robot. 6 | // This Header file is specific for T-Hex with 3 DOF 7 | // 8 | // This version of the Configuration file is set up to run on the 9 | // Lynxmotion BotboardDuino board, which is similar to the Arduino Duemilanove 10 | // 11 | // This version of configuration file assumes that the servos will be controlled 12 | // by a Lynxmotion Servo controller SSC-32 and the user is using a Lynxmotion 13 | // PS2 to control the robot. 14 | // 15 | //Date: March 18, 2012 16 | //Programmer: Kurt (aka KurtE) 17 | // 18 | // 19 | //NEW IN V1.0 20 | // - First Release 21 | // 22 | //==================================================================== 23 | #ifndef HEX_CFG_THEX3_H 24 | #define HEX_CFG_THEX3_H 25 | //[CONDITIONAL COMPILING] - COMMENT IF NOT WANTED 26 | // Define other optional compnents to be included or not... 27 | #define OPT_TERMINAL_MONITOR 28 | 29 | #ifdef OPT_TERMINAL_MONITOR // turning off terminal monitor will turn these off as well... 30 | #define OPT_SSC_FORWARDER // only useful if terminal monitor is enabled 31 | //#define OPT_FIND_SERVO_OFFSETS // Only useful if terminal monitor is enabled 32 | #endif 33 | 34 | #define OPT_GPPLAYER 35 | 36 | // Which type of control(s) do you want to compile in 37 | #define DBGSerial Serial 38 | //#define DEBUG_IOPINS 39 | 40 | #if defined(UBRR1H) 41 | #define SSCSerial Serial1 42 | #else 43 | #endif 44 | 45 | #define USEPS2 46 | 47 | //================================================================================================================================== 48 | //================================================================================================================================== 49 | //================================================================================================================================== 50 | // THex-3 51 | //================================================================================================================================== 52 | #define USE_SSC32 53 | //#define cSSC_BINARYMODE 1 // Define if your SSC-32 card supports binary mode. 54 | 55 | //[SERIAL CONNECTIONS] 56 | 57 | 58 | // Warning I will undefine some components as the non-megas don't have enough memory... 59 | //#undef OPT_FIND_SERVO_OFFSETS 60 | 61 | #define cSSC_BAUD 38400 //SSC32 BAUD rate 62 | 63 | //-------------------------------------------------------------------- 64 | //[Botboarduino Pin Numbers] 65 | #define SOUND_PIN 5 // Botboarduino JR pin number 66 | #define PS2_DAT 6 67 | #define PS2_CMD 7 68 | #define PS2_SEL 8 69 | #define PS2_CLK 9 70 | // If we are using a SSC-32 then: 71 | // If were are running on an Arduino Mega we will use one of the hardware serial port, default to Serial1 above. 72 | // If on Non mega, if the IO pins are set to 0, we will overload the hardware Serial port 73 | // Else we will user SoftwareSerial to talk to the SSC-32 74 | #define cSSC_OUT 12 //Output pin for (SSC32 RX) on BotBoard (Yellow) 75 | #define cSSC_IN 13 //Input pin for (SSC32 TX) on BotBoard (Blue) 76 | 77 | //==================================================================== 78 | //[SSC PIN NUMBERS] 79 | #define cRFCoxaPin 0 //Front Right leg Hip Horizontal 80 | #define cRFFemurPin 1 //Front Right leg Hip Vertical 81 | #define cRFTibiaPin 2 //Front Right leg Knee 82 | #define cRFTarsPin 3 // Tar 83 | 84 | #define cRMCoxaPin 4 //Middle Right leg Hip Horizontal 85 | #define cRMFemurPin 5 //Middle Right leg Hip Vertical 86 | #define cRMTibiaPin 6 //Middle Right leg Knee 87 | #define cRMTarsPin 7 // Tar 88 | 89 | #define cRRCoxaPin 8 //Rear Right leg Hip Horizontal 90 | #define cRRFemurPin 9 //Rear Right leg Hip Vertical 91 | #define cRRTibiaPin 10 //Rear Right leg Knee 92 | #define cRRTarsPin 11 // Tar 93 | 94 | #define cLFCoxaPin 16 //Front Left leg Hip Horizontal 95 | #define cLFFemurPin 17 //Front Left leg Hip Vertical 96 | #define cLFTibiaPin 18 //Front Left leg Knee 97 | #define cLFTarsPin 19 // Tar 98 | 99 | #define cLMCoxaPin 20 //Middle Left leg Hip Horizontal 100 | #define cLMFemurPin 21 //Middle Left leg Hip Vertical 101 | #define cLMTibiaPin 22 //Middle Left leg Knee 102 | #define cLMTarsPin 23 // Tar 103 | 104 | #define cLRCoxaPin 24 //Rear Left leg Hip Horizontal 105 | #define cLRFemurPin 25 //Rear Left leg Hip Vertical 106 | #define cLRTibiaPin 26 //Rear Left leg Knee 107 | #define cLRTarsPin 27 // Tar 108 | 109 | 110 | //-------------------------------------------------------------------- 111 | //[MIN/MAX ANGLES] 112 | #define cRRCoxaMin1 -550 //Mechanical limits of the Right Rear Leg 113 | #define cRRCoxaMax1 550 114 | #define cRRFemurMin1 -900 115 | #define cRRFemurMax1 550 116 | #define cRRTibiaMin1 -400 117 | #define cRRTibiaMax1 750 118 | #define cRRTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 119 | #define cRRTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 120 | 121 | #define cRMCoxaMin1 -550 //Mechanical limits of the Right Middle Leg 122 | #define cRMCoxaMax1 550 123 | #define cRMFemurMin1 -900 124 | #define cRMFemurMax1 550 125 | #define cRMTibiaMin1 -400 126 | #define cRMTibiaMax1 750 127 | #define cRMTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 128 | #define cRMTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 129 | 130 | #define cRFCoxaMin1 -550 //Mechanical limits of the Right Front Leg 131 | #define cRFCoxaMax1 550 132 | #define cRFFemurMin1 -900 133 | #define cRFFemurMax1 550 134 | #define cRFTibiaMin1 -400 135 | #define cRFTibiaMax1 750 136 | #define cRFTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 137 | #define cRFTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 138 | 139 | #define cLRCoxaMin1 -550 //Mechanical limits of the Left Rear Leg 140 | #define cLRCoxaMax1 550 141 | #define cLRFemurMin1 -900 142 | #define cLRFemurMax1 550 143 | #define cLRTibiaMin1 -400 144 | #define cLRTibiaMax1 750 145 | #define cLRTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 146 | #define cLRTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 147 | 148 | #define cLMCoxaMin1 -550 //Mechanical limits of the Left Middle Leg 149 | #define cLMCoxaMax1 550 150 | #define cLMFemurMin1 -900 151 | #define cLMFemurMax1 550 152 | #define cLMTibiaMin1 -400 153 | #define cLMTibiaMax1 750 154 | #define cLMTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 155 | #define cLMTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 156 | 157 | #define cLFCoxaMin1 -550 //Mechanical limits of the Left Front Leg 158 | #define cLFCoxaMax1 550 159 | #define cLFFemurMin1 -900 160 | #define cLFFemurMax1 550 161 | #define cLFTibiaMin1 -400 162 | #define cLFTibiaMax1 750 163 | #define cLFTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 164 | #define cLFTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 165 | 166 | //-------------------------------------------------------------------- 167 | //[LEG DIMENSIONS] 168 | //Universal dimensions for each leg in mm 169 | #define cXXCoxaLength 29 // This is for TH3-R legs 170 | #define cXXFemurLength 76 171 | #define cXXTibiaLength 104 172 | #define cXXTarsLength 85 // 4DOF only... 173 | 174 | #define cRRCoxaLength cXXCoxaLength //Right Rear leg 175 | #define cRRFemurLength cXXFemurLength 176 | #define cRRTibiaLength cXXTibiaLength 177 | #define cRRTarsLength cXXTarsLength //4DOF ONLY 178 | 179 | #define cRMCoxaLength cXXCoxaLength //Right middle leg 180 | #define cRMFemurLength cXXFemurLength 181 | #define cRMTibiaLength cXXTibiaLength 182 | #define cRMTarsLength cXXTarsLength //4DOF ONLY 183 | 184 | #define cRFCoxaLength cXXCoxaLength //Rigth front leg 185 | #define cRFFemurLength cXXFemurLength 186 | #define cRFTibiaLength cXXTibiaLength 187 | #define cRFTarsLength cXXTarsLength //4DOF ONLY 188 | 189 | #define cLRCoxaLength cXXCoxaLength //Left Rear leg 190 | #define cLRFemurLength cXXFemurLength 191 | #define cLRTibiaLength cXXTibiaLength 192 | #define cLRTarsLength cXXTarsLength //4DOF ONLY 193 | 194 | #define cLMCoxaLength cXXCoxaLength //Left middle leg 195 | #define cLMFemurLength cXXFemurLength 196 | #define cLMTibiaLength cXXTibiaLength 197 | #define cLMTarsLength cXXTarsLength //4DOF ONLY 198 | 199 | #define cLFCoxaLength cXXCoxaLength //Left front leg 200 | #define cLFFemurLength cXXFemurLength 201 | #define cLFTibiaLength cXXTibiaLength 202 | #define cLFTarsLength cXXTarsLength //4DOF ONLY 203 | 204 | 205 | //-------------------------------------------------------------------- 206 | //[BODY DIMENSIONS] 207 | #define cRRCoxaAngle1 -450 //Default Coxa setup angle, decimals = 1 208 | #define cRMCoxaAngle1 0 //Default Coxa setup angle, decimals = 1 209 | #define cRFCoxaAngle1 450 //Default Coxa setup angle, decimals = 1 210 | #define cLRCoxaAngle1 -450 //Default Coxa setup angle, decimals = 1 211 | #define cLMCoxaAngle1 0 //Default Coxa setup angle, decimals = 1 212 | #define cLFCoxaAngle1 450 //Default Coxa setup angle, decimals = 1 213 | 214 | #define cRROffsetX -53 //Distance X from center of the body to the Right Rear coxa 215 | #define cRROffsetZ 102 //Distance Z from center of the body to the Right Rear coxa 216 | #define cRMOffsetX -72 //Distance X from center of the body to the Right Middle coxa 217 | #define cRMOffsetZ 0 //Distance Z from center of the body to the Right Middle coxa 218 | #define cRFOffsetX -60 //Distance X from center of the body to the Right Front coxa 219 | #define cRFOffsetZ -102 //Distance Z from center of the body to the Right Front coxa 220 | 221 | #define cLROffsetX 53 //Distance X from center of the body to the Left Rear coxa 222 | #define cLROffsetZ 102 //Distance Z from center of the body to the Left Rear coxa 223 | #define cLMOffsetX 72 //Distance X from center of the body to the Left Middle coxa 224 | #define cLMOffsetZ 0 //Distance Z from center of the body to the Left Middle coxa 225 | #define cLFOffsetX 60 //Distance X from center of the body to the Left Front coxa 226 | #define cLFOffsetZ -102 //Distance Z from center of the body to the Left Front coxa 227 | 228 | //-------------------------------------------------------------------- 229 | //[START POSITIONS FEET] 230 | #define cHexInitXZ 105 231 | #define CHexInitXZCos45 74 // COS(45) = .7071 232 | #define CHexInitXZSin45 74 // sin(45) = .7071 233 | #define CHexInitY 26 234 | 235 | // Lets try some multi leg positions depending on height settings. 236 | #define CNT_HEX_INITS 3 237 | #define MAX_BODY_Y 90 238 | #ifdef DEFINE_HEX_GLOBALS 239 | const byte g_abHexIntXZ[] PROGMEM = { 240 | cHexInitXZ, 99, 86}; 241 | const byte g_abHexMaxBodyY[] PROGMEM = { 242 | 20, 50, MAX_BODY_Y}; 243 | #else 244 | extern const byte g_abHexIntXZ[] PROGMEM; 245 | extern const byte g_abHexMaxBodyY[] PROGMEM; 246 | #endif 247 | 248 | #define cRRInitPosX CHexInitXZCos45 //Start positions of the Right Rear leg 249 | #define cRRInitPosY CHexInitY 250 | #define cRRInitPosZ CHexInitXZSin45 251 | 252 | #define cRMInitPosX cHexInitXZ //Start positions of the Right Middle leg 253 | #define cRMInitPosY CHexInitY 254 | #define cRMInitPosZ 0 255 | 256 | #define cRFInitPosX CHexInitXZCos45 //Start positions of the Right Front leg 257 | #define cRFInitPosY CHexInitY 258 | #define cRFInitPosZ -CHexInitXZSin45 259 | 260 | #define cLRInitPosX CHexInitXZCos45 //Start positions of the Left Rear leg 261 | #define cLRInitPosY CHexInitY 262 | #define cLRInitPosZ CHexInitXZSin45 263 | 264 | #define cLMInitPosX cHexInitXZ //Start positions of the Left Middle leg 265 | #define cLMInitPosY CHexInitY 266 | #define cLMInitPosZ 0 267 | 268 | #define cLFInitPosX CHexInitXZCos45 //Start positions of the Left Front leg 269 | #define cLFInitPosY CHexInitY 270 | #define cLFInitPosZ -CHexInitXZSin45 271 | //-------------------------------------------------------------------- 272 | //[Tars factors used in formula to calc Tarsus angle relative to the ground] 273 | #define cTarsConst 720 //4DOF ONLY 274 | #define cTarsMulti 2 //4DOF ONLY 275 | #define cTarsFactorA 70 //4DOF ONLY 276 | #define cTarsFactorB 60 //4DOF ONLY 277 | #define cTarsFactorC 50 //4DOF ONLY 278 | 279 | #endif CFG_HEX_H 280 | 281 | 282 | 283 | -------------------------------------------------------------------------------- /Phoenix/THex_Serial_SSC32/Hex_Cfg.h: -------------------------------------------------------------------------------- 1 | 2 | //==================================================================== 3 | //Project Lynxmotion Phoenix 4 | //Description: 5 | // This is the hardware configuration file for the Hex Robot. 6 | // This Header file is specific for T-Hex with 3 DOF 7 | // 8 | // This version of the Configuration file is set up to run on the 9 | // Lynxmotion BotboardDuino board, which is similar to the Arduino Duemilanove 10 | // 11 | // This version of configuration file assumes that the servos will be controlled 12 | // by a Lynxmotion Servo controller SSC-32 and the user is using a Lynxmotion 13 | // PS2 to control the robot. 14 | // 15 | //Date: March 18, 2012 16 | //Programmer: Kurt (aka KurtE) 17 | // 18 | // 19 | //NEW IN V1.0 20 | // - First Release 21 | // 22 | //==================================================================== 23 | #ifndef HEX_CFG_THEX3_H 24 | #define HEX_CFG_THEX3_H 25 | //[CONDITIONAL COMPILING] - COMMENT IF NOT WANTED 26 | // Define other optional compnents to be included or not... 27 | #define OPT_TERMINAL_MONITOR 28 | 29 | #ifdef OPT_TERMINAL_MONITOR // turning off terminal monitor will turn these off as well... 30 | #define OPT_SSC_FORWARDER // only useful if terminal monitor is enabled 31 | //#define OPT_FIND_SERVO_OFFSETS // Only useful if terminal monitor is enabled 32 | #endif 33 | 34 | #define OPT_GPPLAYER 35 | 36 | // Which type of control(s) do you want to compile in 37 | #define DBGSerial Serial 38 | //#define DEBUG_IOPINS 39 | 40 | #if defined(UBRR1H) 41 | #define SSCSerial Serial1 42 | #else 43 | #endif 44 | 45 | #define USESERIAL 46 | 47 | //================================================================================================================================== 48 | //================================================================================================================================== 49 | //================================================================================================================================== 50 | // THex-3 51 | //================================================================================================================================== 52 | #define USE_SSC32 53 | //#define cSSC_BINARYMODE 1 // Define if your SSC-32 card supports binary mode. 54 | 55 | //[SERIAL CONNECTIONS] 56 | 57 | 58 | // Warning I will undefine some components as the non-megas don't have enough memory... 59 | //#undef OPT_FIND_SERVO_OFFSETS 60 | 61 | #define cSSC_BAUD 38400 //SSC32 BAUD rate 62 | 63 | //-------------------------------------------------------------------- 64 | //[Botboarduino Pin Numbers] 65 | #define SOUND_PIN 5 // Botboarduino JR pin number 66 | #define PS2_DAT 6 67 | #define PS2_CMD 7 68 | #define PS2_SEL 8 69 | #define PS2_CLK 9 70 | // If we are using a SSC-32 then: 71 | // If were are running on an Arduino Mega we will use one of the hardware serial port, default to Serial1 above. 72 | // If on Non mega, if the IO pins are set to 0, we will overload the hardware Serial port 73 | // Else we will user SoftwareSerial to talk to the SSC-32 74 | #define cSSC_OUT 12 //Output pin for (SSC32 RX) on BotBoard (Yellow) 75 | #define cSSC_IN 13 //Input pin for (SSC32 TX) on BotBoard (Blue) 76 | 77 | //==================================================================== 78 | //[SSC PIN NUMBERS] 79 | #define cRFCoxaPin 0 //Front Right leg Hip Horizontal 80 | #define cRFFemurPin 1 //Front Right leg Hip Vertical 81 | #define cRFTibiaPin 2 //Front Right leg Knee 82 | #define cRFTarsPin 3 // Tar 83 | 84 | #define cRMCoxaPin 4 //Middle Right leg Hip Horizontal 85 | #define cRMFemurPin 5 //Middle Right leg Hip Vertical 86 | #define cRMTibiaPin 6 //Middle Right leg Knee 87 | #define cRMTarsPin 7 // Tar 88 | 89 | #define cRRCoxaPin 8 //Rear Right leg Hip Horizontal 90 | #define cRRFemurPin 9 //Rear Right leg Hip Vertical 91 | #define cRRTibiaPin 10 //Rear Right leg Knee 92 | #define cRRTarsPin 11 // Tar 93 | 94 | #define cLFCoxaPin 16 //Front Left leg Hip Horizontal 95 | #define cLFFemurPin 17 //Front Left leg Hip Vertical 96 | #define cLFTibiaPin 18 //Front Left leg Knee 97 | #define cLFTarsPin 19 // Tar 98 | 99 | #define cLMCoxaPin 20 //Middle Left leg Hip Horizontal 100 | #define cLMFemurPin 21 //Middle Left leg Hip Vertical 101 | #define cLMTibiaPin 22 //Middle Left leg Knee 102 | #define cLMTarsPin 23 // Tar 103 | 104 | #define cLRCoxaPin 24 //Rear Left leg Hip Horizontal 105 | #define cLRFemurPin 25 //Rear Left leg Hip Vertical 106 | #define cLRTibiaPin 26 //Rear Left leg Knee 107 | #define cLRTarsPin 27 // Tar 108 | 109 | 110 | //-------------------------------------------------------------------- 111 | //[MIN/MAX ANGLES] 112 | #define cRRCoxaMin1 -550 //Mechanical limits of the Right Rear Leg 113 | #define cRRCoxaMax1 550 114 | #define cRRFemurMin1 -900 115 | #define cRRFemurMax1 550 116 | #define cRRTibiaMin1 -400 117 | #define cRRTibiaMax1 750 118 | #define cRRTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 119 | #define cRRTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 120 | 121 | #define cRMCoxaMin1 -550 //Mechanical limits of the Right Middle Leg 122 | #define cRMCoxaMax1 550 123 | #define cRMFemurMin1 -900 124 | #define cRMFemurMax1 550 125 | #define cRMTibiaMin1 -400 126 | #define cRMTibiaMax1 750 127 | #define cRMTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 128 | #define cRMTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 129 | 130 | #define cRFCoxaMin1 -550 //Mechanical limits of the Right Front Leg 131 | #define cRFCoxaMax1 550 132 | #define cRFFemurMin1 -900 133 | #define cRFFemurMax1 550 134 | #define cRFTibiaMin1 -400 135 | #define cRFTibiaMax1 750 136 | #define cRFTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 137 | #define cRFTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 138 | 139 | #define cLRCoxaMin1 -550 //Mechanical limits of the Left Rear Leg 140 | #define cLRCoxaMax1 550 141 | #define cLRFemurMin1 -900 142 | #define cLRFemurMax1 550 143 | #define cLRTibiaMin1 -400 144 | #define cLRTibiaMax1 750 145 | #define cLRTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 146 | #define cLRTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 147 | 148 | #define cLMCoxaMin1 -550 //Mechanical limits of the Left Middle Leg 149 | #define cLMCoxaMax1 550 150 | #define cLMFemurMin1 -900 151 | #define cLMFemurMax1 550 152 | #define cLMTibiaMin1 -400 153 | #define cLMTibiaMax1 750 154 | #define cLMTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 155 | #define cLMTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 156 | 157 | #define cLFCoxaMin1 -550 //Mechanical limits of the Left Front Leg 158 | #define cLFCoxaMax1 550 159 | #define cLFFemurMin1 -900 160 | #define cLFFemurMax1 550 161 | #define cLFTibiaMin1 -400 162 | #define cLFTibiaMax1 750 163 | #define cLFTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 164 | #define cLFTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 165 | 166 | //-------------------------------------------------------------------- 167 | //[LEG DIMENSIONS] 168 | //Universal dimensions for each leg in mm 169 | #define cXXCoxaLength 29 // This is for TH3-R legs 170 | #define cXXFemurLength 76 171 | #define cXXTibiaLength 104 172 | #define cXXTarsLength 85 // 4DOF only... 173 | 174 | #define cRRCoxaLength cXXCoxaLength //Right Rear leg 175 | #define cRRFemurLength cXXFemurLength 176 | #define cRRTibiaLength cXXTibiaLength 177 | #define cRRTarsLength cXXTarsLength //4DOF ONLY 178 | 179 | #define cRMCoxaLength cXXCoxaLength //Right middle leg 180 | #define cRMFemurLength cXXFemurLength 181 | #define cRMTibiaLength cXXTibiaLength 182 | #define cRMTarsLength cXXTarsLength //4DOF ONLY 183 | 184 | #define cRFCoxaLength cXXCoxaLength //Rigth front leg 185 | #define cRFFemurLength cXXFemurLength 186 | #define cRFTibiaLength cXXTibiaLength 187 | #define cRFTarsLength cXXTarsLength //4DOF ONLY 188 | 189 | #define cLRCoxaLength cXXCoxaLength //Left Rear leg 190 | #define cLRFemurLength cXXFemurLength 191 | #define cLRTibiaLength cXXTibiaLength 192 | #define cLRTarsLength cXXTarsLength //4DOF ONLY 193 | 194 | #define cLMCoxaLength cXXCoxaLength //Left middle leg 195 | #define cLMFemurLength cXXFemurLength 196 | #define cLMTibiaLength cXXTibiaLength 197 | #define cLMTarsLength cXXTarsLength //4DOF ONLY 198 | 199 | #define cLFCoxaLength cXXCoxaLength //Left front leg 200 | #define cLFFemurLength cXXFemurLength 201 | #define cLFTibiaLength cXXTibiaLength 202 | #define cLFTarsLength cXXTarsLength //4DOF ONLY 203 | 204 | 205 | //-------------------------------------------------------------------- 206 | //[BODY DIMENSIONS] 207 | #define cRRCoxaAngle1 -450 //Default Coxa setup angle, decimals = 1 208 | #define cRMCoxaAngle1 0 //Default Coxa setup angle, decimals = 1 209 | #define cRFCoxaAngle1 450 //Default Coxa setup angle, decimals = 1 210 | #define cLRCoxaAngle1 -450 //Default Coxa setup angle, decimals = 1 211 | #define cLMCoxaAngle1 0 //Default Coxa setup angle, decimals = 1 212 | #define cLFCoxaAngle1 450 //Default Coxa setup angle, decimals = 1 213 | 214 | #define cRROffsetX -53 //Distance X from center of the body to the Right Rear coxa 215 | #define cRROffsetZ 102 //Distance Z from center of the body to the Right Rear coxa 216 | #define cRMOffsetX -72 //Distance X from center of the body to the Right Middle coxa 217 | #define cRMOffsetZ 0 //Distance Z from center of the body to the Right Middle coxa 218 | #define cRFOffsetX -60 //Distance X from center of the body to the Right Front coxa 219 | #define cRFOffsetZ -102 //Distance Z from center of the body to the Right Front coxa 220 | 221 | #define cLROffsetX 53 //Distance X from center of the body to the Left Rear coxa 222 | #define cLROffsetZ 102 //Distance Z from center of the body to the Left Rear coxa 223 | #define cLMOffsetX 72 //Distance X from center of the body to the Left Middle coxa 224 | #define cLMOffsetZ 0 //Distance Z from center of the body to the Left Middle coxa 225 | #define cLFOffsetX 60 //Distance X from center of the body to the Left Front coxa 226 | #define cLFOffsetZ -102 //Distance Z from center of the body to the Left Front coxa 227 | 228 | //-------------------------------------------------------------------- 229 | //[START POSITIONS FEET] 230 | #define cHexInitXZ 105 231 | #define CHexInitXZCos45 74 // COS(45) = .7071 232 | #define CHexInitXZSin45 74 // sin(45) = .7071 233 | #define CHexInitY 26 234 | 235 | // Lets try some multi leg positions depending on height settings. 236 | #define CNT_HEX_INITS 3 237 | #define MAX_BODY_Y 90 238 | #ifdef DEFINE_HEX_GLOBALS 239 | const byte g_abHexIntXZ[] PROGMEM = { 240 | cHexInitXZ, 99, 86}; 241 | const byte g_abHexMaxBodyY[] PROGMEM = { 242 | 20, 50, MAX_BODY_Y}; 243 | #else 244 | extern const byte g_abHexIntXZ[] PROGMEM; 245 | extern const byte g_abHexMaxBodyY[] PROGMEM; 246 | #endif 247 | 248 | #define cRRInitPosX CHexInitXZCos45 //Start positions of the Right Rear leg 249 | #define cRRInitPosY CHexInitY 250 | #define cRRInitPosZ CHexInitXZSin45 251 | 252 | #define cRMInitPosX cHexInitXZ //Start positions of the Right Middle leg 253 | #define cRMInitPosY CHexInitY 254 | #define cRMInitPosZ 0 255 | 256 | #define cRFInitPosX CHexInitXZCos45 //Start positions of the Right Front leg 257 | #define cRFInitPosY CHexInitY 258 | #define cRFInitPosZ -CHexInitXZSin45 259 | 260 | #define cLRInitPosX CHexInitXZCos45 //Start positions of the Left Rear leg 261 | #define cLRInitPosY CHexInitY 262 | #define cLRInitPosZ CHexInitXZSin45 263 | 264 | #define cLMInitPosX cHexInitXZ //Start positions of the Left Middle leg 265 | #define cLMInitPosY CHexInitY 266 | #define cLMInitPosZ 0 267 | 268 | #define cLFInitPosX CHexInitXZCos45 //Start positions of the Left Front leg 269 | #define cLFInitPosY CHexInitY 270 | #define cLFInitPosZ -CHexInitXZSin45 271 | //-------------------------------------------------------------------- 272 | //[Tars factors used in formula to calc Tarsus angle relative to the ground] 273 | #define cTarsConst 720 //4DOF ONLY 274 | #define cTarsMulti 2 //4DOF ONLY 275 | #define cTarsFactorA 70 //4DOF ONLY 276 | #define cTarsFactorB 60 //4DOF ONLY 277 | #define cTarsFactorC 50 //4DOF ONLY 278 | 279 | #endif CFG_HEX_H 280 | 281 | 282 | 283 | -------------------------------------------------------------------------------- /Phoenix/PhXQuadV2_Commander_AX12_Stock/Quad_Cfg.h: -------------------------------------------------------------------------------- 1 | //==================================================================== 2 | //Project Lynxmotion Phoenix 3 | //Description: 4 | // This is the hardware configuration file for the 5 | // Version 2 PhantomX Quad robot. 6 | // Will first define to use their commander unit. 7 | // 8 | //Date: June 29, 2013 9 | // 10 | //==================================================================== 11 | #ifndef QUAD_CFG_H 12 | #define QUAD_CFG_H 13 | 14 | #define QUADMODE // We are building for quad support... 15 | #define ADJUSTABLE_LEG_ANGLES 16 | //================================================================================================================================== 17 | // Define which input classes we will use. If we wish to use more than one we need to define USEMULTI - This will define a forwarder 18 | // type implementation, that the Inputcontroller will need to call. There will be some negotion for which one is in contol. 19 | // 20 | // If this is not defined, The included Controller should simply implement the InputController Class... 21 | //================================================================================================================================== 22 | #define USECOMMANDER 23 | 24 | // Global defines to control which configuration we are using. Note: Only define one of these... 25 | // 26 | // Which type of control(s) do you want to compile in 27 | #if defined(__MK20DX256__) 28 | #define DBGSerial Serial 29 | #else 30 | #if defined(UBRR2H) 31 | #define DBGSerial Serial 32 | #endif 33 | #endif 34 | 35 | // Define other optional compnents to be included or not... 36 | //#define PHANTOMX_V2 // Some code may depend on it being a V2 PhantomX 37 | #define cFemurHornOffset1 -35 // -70 38 | #define cTibiaHornOffset1 463 //380 39 | #define cRRTibiaInv 0 40 | #define cRMTibiaInv 0 41 | #define cRFTibiaInv 0 42 | #define cLRTibiaInv 1 43 | #define cLMTibiaInv 1 44 | #define cLFTibiaInv 1 45 | 46 | #define BALANCE_DELAY 25 // don't add as much as the default here. 47 | 48 | //=================================================================== 49 | // Debug Options 50 | #ifdef DBGSerial 51 | #define OPT_TERMINAL_MONITOR 52 | #endif 53 | 54 | //#define DEBUG_IOPINS 55 | #ifdef DEBUG_IOPINS 56 | #define DebugToggle(pin) {digitalWrite(pin, !digitalRead(pin));} 57 | #define DebugWrite(pin, state) {digitalWrite(pin, state);} 58 | #else 59 | #define DebugToggle(pin) {;} 60 | #define DebugWrite(pin, state) {;} 61 | #endif 62 | 63 | 64 | // Also define that we are using the AX12 driver 65 | #define USE_AX12_DRIVER 66 | #define OPT_BACKGROUND_PROCESS // The AX12 has a background process 67 | //#define OPT_GPPLAYER 68 | //#define OPT_SINGLELEG 69 | #define OPT_DYNAMIC_ADJUST_LEGS 70 | //#define ADJUSTABLE_LEG_ANGLES 71 | 72 | 73 | //================================================================================================================================== 74 | //================================================================================================================================== 75 | //================================================================================================================================== 76 | // PhantomX 77 | //================================================================================================================================== 78 | //[SERIAL CONNECTIONS] 79 | 80 | //==================================================================== 81 | // XBEE on non mega??? 82 | #if defined(__MK20DX256__) 83 | #define XBeeSerial Serial2 84 | #else 85 | #if defined(UBRR2H) 86 | #define XBeeSerial Serial2 87 | #endif 88 | #define XBeeSerial Serial 89 | #endif 90 | #define XBEE_BAUD 38400 91 | #define DISP_VOLTAGE // User wants the Battery voltage to be displayed... 92 | #define DISP_VOLTAGE_TIME 1000 // how often to check and report in millis 93 | //-------------------------------------------------------------------- 94 | //[Arbotix Pin Numbers] 95 | #if defined(__MK20DX256__) 96 | #define SOUND_PIN 6 97 | #else 98 | #define USER 0 // defaults to 13 but Arbotix on 0... 99 | #define SOUND_PIN 1 //0xff // Tell system we have no IO pin... 100 | #endif 101 | #define PS2_DAT A0 102 | #define PS2_CMD A1 103 | #define PS2_SEL A2 104 | #define PS2_CLK A3 105 | 106 | // Define Analog pin and minimum voltage that we will allow the servos to run 107 | #if defined(__MK20DX256__) 108 | // Our Teensy board 109 | #define cVoltagePin 0 110 | 111 | #define CVADR1 402 // VD Resistor 1 - reduced as only need ratio... 40.2K and 10K 112 | #define CVADR2 100 // VD Resistor 2 113 | #define CVREF 330 // 3.3v 114 | #endif 115 | //#define cVoltagePin 7 // Use our Analog pin jumper here... 116 | //#define CVADR1 1000 // VD Resistor 1 - reduced as only need ratio... 20K and 4.66K 117 | //#define CVADR2 233 // VD Resistor 2 118 | #define cTurnOffVol 1000 // 10v 119 | #define cTurnOnVol 1100 // 11V - optional part to say if voltage goes back up, turn it back on... 120 | 121 | //==================================================================== 122 | #define DEFAULT_GAIT_SPEED 35 // Default gait speed - Will depend on what Servos you are using... 123 | #define DEFAULT_SLOW_GAIT 50 // Had a couple different speeds... 124 | 125 | //==================================================================== 126 | // Defines for Optional XBee Init and configuration code. 127 | //==================================================================== 128 | #define CHECK_AND_CONFIG_XBEE 129 | #define DEFAULT_MY 0x101 // Swap My/DL on 2nd unit 130 | #define DEFAULT_DL 0x102 131 | #define DEFAULT_ID 0x3332 132 | 133 | 134 | //-------------------------------------------------------------------- 135 | // Define which pins(sevo IDS go with which joint 136 | 137 | #define cRRCoxaPin 8 //Rear Right leg Hip Horizontal 138 | #define cRRFemurPin 10 //Rear Right leg Hip Vertical 139 | #define cRRTibiaPin 12 //Rear Right leg Knee 140 | 141 | #define cRFCoxaPin 2 //Front Right leg Hip Horizontal 142 | #define cRFFemurPin 4 //Front Right leg Hip Vertical 143 | #define cRFTibiaPin 6 //Front Right leg Knee 144 | 145 | #define cLRCoxaPin 7 //Rear Left leg Hip Horizontal 146 | #define cLRFemurPin 9 //Rear Left leg Hip Vertical 147 | #define cLRTibiaPin 11 //Rear Left leg Knee 148 | 149 | #define cLFCoxaPin 1 //Front Left leg Hip Horizontal 150 | #define cLFFemurPin 3 //Front Left leg Hip Vertical 151 | #define cLFTibiaPin 5 //Front Left leg Knee 152 | 153 | 154 | //-------------------------------------------------------------------- 155 | //[MIN/MAX ANGLES] - Warning - remember that some servos direction is 156 | // inverted in code after we do the conversions. So the Right legs need 157 | // to have their Min/Max values negated from what is seen on the actual robot 158 | // servo positions... 159 | //1:224(-843) 797(834) 160 | //3:159(-1034) 862(1025) 161 | //5:277(-688) 864(1031) 162 | //7:223(-846) 798(837) 163 | //9:160(-1031) 858(1013) 164 | //11:283(-670) 863(1028) 165 | //2:220(-855) 797(834) 166 | //4:163(-1022) 863(1028) 167 | //6:158(-1037) 747(688) 168 | //8:220(-855) 801(846) 169 | //10:255(-752) 861(1022) 170 | //12:125(-1133) 746(685) 171 | #define cRRCoxaMin1 -750 172 | #define cRRCoxaMax1 750 173 | #define cRRFemurMin1 -1000 174 | #define cRRFemurMax1 1000 175 | #define cRRTibiaMin1 -1020 176 | #define cRRTibiaMax1 680 177 | 178 | #define cRFCoxaMin1 -750 //Mechanical limits of the Right Front Leg, decimals = 1 179 | #define cRFCoxaMax1 750 180 | #define cRFFemurMin1 -1000 181 | #define cRFFemurMax1 1000 182 | #define cRFTibiaMin1 -1020 183 | #define cRFTibiaMax1 680 184 | 185 | #define cLRCoxaMin1 -750 //Mechanical limits of the Left Rear Leg, decimals = 1 186 | #define cLRCoxaMax1 750 187 | #define cLRFemurMin1 -1000 188 | #define cLRFemurMax1 1000 189 | #define cLRTibiaMin1 -1020 190 | #define cLRTibiaMax1 680 191 | 192 | #define cLFCoxaMin1 -750 //Mechanical limits of the Left Front Leg, decimals = 1 193 | #define cLFCoxaMax1 750 194 | #define cLFFemurMin1 -1000 195 | #define cLFFemurMax1 1000 196 | #define cLFTibiaMin1 -1020 197 | #define cLFTibiaMax1 680 198 | 199 | //-------------------------------------------------------------------- 200 | //[Joint offsets] 201 | // This allows us to calibrate servos to some fixed position, and then adjust them by moving theim 202 | // one or more servo horn clicks. This requires us to adjust the value for those servos by 15 degrees 203 | // per click. This is used with the T-Hex 4DOF legs 204 | //First calibrate the servos in the 0 deg position using the SSC-32 reg offsets, then: 205 | //-------------------------------------------------------------------- 206 | //[LEG DIMENSIONS] 207 | //Universal dimensions for each leg in mm 208 | #define cXXCoxaLength 52 // PhantomX leg dimensions. 209 | #define cXXFemurLength 65 210 | #define cXXTibiaLength 133 211 | 212 | #define cRRCoxaLength cXXCoxaLength //Right Rear leg 213 | #define cRRFemurLength cXXFemurLength 214 | #define cRRTibiaLength cXXTibiaLength 215 | 216 | #define cRFCoxaLength cXXCoxaLength //Rigth front leg 217 | #define cRFFemurLength cXXFemurLength 218 | #define cRFTibiaLength cXXTibiaLength 219 | 220 | #define cLRCoxaLength cXXCoxaLength //Left Rear leg 221 | #define cLRFemurLength cXXFemurLength 222 | #define cLRTibiaLength cXXTibiaLength 223 | 224 | #define cLFCoxaLength cXXCoxaLength //Left front leg 225 | #define cLFFemurLength cXXFemurLength 226 | #define cLFTibiaLength cXXTibiaLength 227 | 228 | //-------------------------------------------------------------------- 229 | //[BODY DIMENSIONS] 230 | #define cRRCoxaAngle1 -450 //Default Coxa setup angle, decimals = 1 231 | #define cRFCoxaAngle1 450 //Default Coxa setup angle, decimals = 1 232 | #define cLRCoxaAngle1 -450 //Default Coxa setup angle, decimals = 1 233 | #define cLFCoxaAngle1 450 //Default Coxa setup angle, decimals = 1 234 | 235 | #define X_COXA 65 // MM between front and back legs /2 236 | #define Y_COXA 65 // MM between front/back legs /2 237 | 238 | #define cRROffsetX -X_COXA //Distance X from center of the body to the Right Rear coxa 239 | #define cRROffsetZ Y_COXA //Distance Z from center of the body to the Right Rear coxa 240 | 241 | #define cRFOffsetX -X_COXA //Distance X from center of the body to the Right Front coxa 242 | #define cRFOffsetZ -Y_COXA //Distance Z from center of the body to the Right Front coxa 243 | 244 | #define cLROffsetX X_COXA //Distance X from center of the body to the Left Rear coxa 245 | #define cLROffsetZ Y_COXA //Distance Z from center of the body to the Left Rear coxa 246 | 247 | #define cLFOffsetX X_COXA //Distance X from center of the body to the Left Front coxa 248 | #define cLFOffsetZ -Y_COXA //Distance Z from center of the body to the Left Front coxa 249 | 250 | //-------------------------------------------------------------------- 251 | //[START POSITIONS FEET] 252 | #define cHexInitXZ 150 253 | #define CHexInitXZCos60 130 //92 // COS(60) = .866 254 | #define CHexInitXZSin60 75 // 92 // sin(60) = .5 255 | #define CHexInitY 25 //30 256 | 257 | // Lets try some multi leg positions depending on height settings. 258 | #define DYNAMIC_INIT_XZ 259 | #define CNT_HEX_INITS 3 260 | #define MAX_BODY_Y 150 261 | 262 | // For Inits we may want to tell system actual angles we are initiing servos to... 263 | // In some cases like some quads may not want legs straight out... 264 | #define cRRInitCoxaAngle1 -300 //Default Coxa setup angle, decimals = 1 265 | #define cRFInitCoxaAngle1 300 //Default Coxa setup angle, decimals = 1 266 | #define cLRInitCoxaAngle1 -300 //Default Coxa setup angle, decimals = 1 267 | #define cLFInitCoxaAngle1 300 //Default Coxa setup angle, decimals = 1 268 | 269 | 270 | #ifdef DEFINE_HEX_GLOBALS 271 | const byte g_abHexIntXZ[] PROGMEM = {cHexInitXZ, 130, 110}; 272 | const byte g_abHexMaxBodyY[] PROGMEM = { 30, 60, MAX_BODY_Y}; 273 | #else 274 | extern const byte g_abHexIntXZ[] PROGMEM; 275 | extern const byte g_abHexMaxBodyY[] PROGMEM; 276 | #endif 277 | 278 | #define cRRInitPosX CHexInitXZCos60 //Start positions of the Right Rear leg 279 | #define cRRInitPosY CHexInitY 280 | #define cRRInitPosZ CHexInitXZSin60 281 | 282 | #define cRFInitPosX CHexInitXZCos60 //Start positions of the Right Front leg 283 | #define cRFInitPosY CHexInitY 284 | #define cRFInitPosZ -CHexInitXZSin60 285 | 286 | #define cLRInitPosX CHexInitXZCos60 //Start positions of the Left Rear leg 287 | #define cLRInitPosY CHexInitY 288 | #define cLRInitPosZ CHexInitXZSin60 289 | 290 | #define cLFInitPosX CHexInitXZCos60 //Start positions of the Left Front leg 291 | #define cLFInitPosY CHexInitY 292 | #define cLFInitPosZ -CHexInitXZSin60 293 | //-------------------------------------------------------------------- 294 | #endif // HEX_CFG_H 295 | -------------------------------------------------------------------------------- /Phoenix/THex4_PS2_SSC32/Hex_Cfg.h: -------------------------------------------------------------------------------- 1 | 2 | //==================================================================== 3 | //Project Lynxmotion Phoenix 4 | //Description: 5 | // This is the hardware configuration file for the Hex Robot. 6 | // This Header file is specific for T-Hex with 3 DOF 7 | // 8 | // This version of the Configuration file is set up to run on the 9 | // Lynxmotion BotboardDuino board, which is similar to the Arduino Duemilanove 10 | // 11 | // This version of configuration file assumes that the servos will be controlled 12 | // by a Lynxmotion Servo controller SSC-32 and the user is using a Lynxmotion 13 | // PS2 to control the robot. 14 | // 15 | //Date: March 18, 2012 16 | //Programmer: Kurt (aka KurtE) 17 | // 18 | // 19 | //NEW IN V1.0 20 | // - First Release 21 | // 22 | //==================================================================== 23 | #ifndef HEX_CFG_THEX3_H 24 | #define HEX_CFG_THEX3_H 25 | //[CONDITIONAL COMPILING] - COMMENT IF NOT WANTED 26 | // Define other optional compnents to be included or not... 27 | #define OPT_TERMINAL_MONITOR 28 | 29 | #ifdef OPT_TERMINAL_MONITOR // turning off terminal monitor will turn these off as well... 30 | #define OPT_SSC_FORWARDER // only useful if terminal monitor is enabled 31 | //#define OPT_FIND_SERVO_OFFSETS // Only useful if terminal monitor is enabled 32 | #endif 33 | 34 | #define OPT_GPPLAYER 35 | 36 | // Which type of control(s) do you want to compile in 37 | #define DBGSerial Serial 38 | //#define DEBUG_IOPINS 39 | 40 | #if defined(UBRR1H) 41 | #define SSCSerial Serial1 42 | #else 43 | #endif 44 | 45 | #define USEPS2 46 | 47 | //================================================================================================================================== 48 | //================================================================================================================================== 49 | //================================================================================================================================== 50 | // THex-3 51 | //================================================================================================================================== 52 | #define USE_SSC32 53 | //#define cSSC_BINARYMODE 1 // Define if your SSC-32 card supports binary mode. 54 | #define c4DOF 55 | 56 | //[SERIAL CONNECTIONS] 57 | 58 | 59 | // Warning I will undefine some components as the non-megas don't have enough memory... 60 | //#undef OPT_FIND_SERVO_OFFSETS 61 | 62 | #define cSSC_BAUD 38400 //SSC32 BAUD rate 63 | 64 | //-------------------------------------------------------------------- 65 | //[Botboarduino Pin Numbers] 66 | #define SOUND_PIN 5 // Botboarduino JR pin number 67 | #define PS2_DAT 6 68 | #define PS2_CMD 7 69 | #define PS2_SEL 8 70 | #define PS2_CLK 9 71 | // If we are using a SSC-32 then: 72 | // If were are running on an Arduino Mega we will use one of the hardware serial port, default to Serial1 above. 73 | // If on Non mega, if the IO pins are set to 0, we will overload the hardware Serial port 74 | // Else we will user SoftwareSerial to talk to the SSC-32 75 | #define cSSC_OUT 12 //Output pin for (SSC32 RX) on BotBoard (Yellow) 76 | #define cSSC_IN 13 //Input pin for (SSC32 TX) on BotBoard (Blue) 77 | 78 | //==================================================================== 79 | //[SSC PIN NUMBERS] 80 | #define cRFCoxaPin 0 //Front Right leg Hip Horizontal 81 | #define cRFFemurPin 1 //Front Right leg Hip Vertical 82 | #define cRFTibiaPin 2 //Front Right leg Knee 83 | #define cRFTarsPin 3 // Tar 84 | 85 | #define cRMCoxaPin 4 //Middle Right leg Hip Horizontal 86 | #define cRMFemurPin 5 //Middle Right leg Hip Vertical 87 | #define cRMTibiaPin 6 //Middle Right leg Knee 88 | #define cRMTarsPin 7 // Tar 89 | 90 | #define cRRCoxaPin 8 //Rear Right leg Hip Horizontal 91 | #define cRRFemurPin 9 //Rear Right leg Hip Vertical 92 | #define cRRTibiaPin 10 //Rear Right leg Knee 93 | #define cRRTarsPin 11 // Tar 94 | 95 | #define cLFCoxaPin 16 //Front Left leg Hip Horizontal 96 | #define cLFFemurPin 17 //Front Left leg Hip Vertical 97 | #define cLFTibiaPin 18 //Front Left leg Knee 98 | #define cLFTarsPin 19 // Tar 99 | 100 | #define cLMCoxaPin 20 //Middle Left leg Hip Horizontal 101 | #define cLMFemurPin 21 //Middle Left leg Hip Vertical 102 | #define cLMTibiaPin 22 //Middle Left leg Knee 103 | #define cLMTarsPin 23 // Tar 104 | 105 | #define cLRCoxaPin 24 //Rear Left leg Hip Horizontal 106 | #define cLRFemurPin 25 //Rear Left leg Hip Vertical 107 | #define cLRTibiaPin 26 //Rear Left leg Knee 108 | #define cLRTarsPin 27 // Tar 109 | 110 | 111 | //-------------------------------------------------------------------- 112 | //[MIN/MAX ANGLES] 113 | #define cRRCoxaMin1 -650 //Mechanical limits of the Right Rear Leg 114 | #define cRRCoxaMax1 650 115 | #define cRRFemurMin1 -1050 116 | #define cRRFemurMax1 750 117 | #define cRRTibiaMin1 -530 118 | #define cRRTibiaMax1 900 119 | #define cRRTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 120 | #define cRRTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 121 | 122 | #define cRMCoxaMin1 -530 //Mechanical limits of the Right Middle Leg 123 | #define cRMCoxaMax1 530 124 | #define cRMFemurMin1 -1050 125 | #define cRMFemurMax1 750 126 | #define cRMTibiaMin1 -530 127 | #define cRMTibiaMax1 900 128 | #define cRMTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 129 | #define cRMTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 130 | 131 | #define cRFCoxaMin1 -550 //Mechanical limits of the Right Front Leg 132 | #define cRFCoxaMax1 650 133 | #define cRFFemurMin1 -1050 134 | #define cRFFemurMax1 750 135 | #define cRFTibiaMin1 -530 136 | #define cRFTibiaMax1 900 137 | #define cRFTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 138 | #define cRFTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 139 | 140 | #define cLRCoxaMin1 -650 //Mechanical limits of the Left Rear Leg 141 | #define cLRCoxaMax1 650 142 | #define cLRFemurMin1 -1050 143 | #define cLRFemurMax1 750 144 | #define cLRTibiaMin1 -530 145 | #define cLRTibiaMax1 900 146 | #define cLRTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 147 | #define cLRTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 148 | 149 | #define cLMCoxaMin1 -530 //Mechanical limits of the Left Middle Leg 150 | #define cLMCoxaMax1 530 151 | #define cLMFemurMin1 -1050 152 | #define cLMFemurMax1 750 153 | #define cLMTibiaMin1 -530 154 | #define cLMTibiaMax1 900 155 | #define cLMTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 156 | #define cLMTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 157 | 158 | #define cLFCoxaMin1 -550 //Mechanical limits of the Left Front Leg 159 | #define cLFCoxaMax1 650 160 | #define cLFFemurMin1 -1050 161 | #define cLFFemurMax1 750 162 | #define cLFTibiaMin1 -530 163 | #define cLFTibiaMax1 900 164 | #define cLFTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 165 | #define cLFTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 166 | 167 | //-------------------------------------------------------------------- 168 | //[Joint offsets] 169 | // This allows us to calibrate servos to some fixed position, and then adjust them by moving theim 170 | // one or more servo horn clicks. This requires us to adjust the value for those servos by 15 degrees 171 | // per click. This is used with the T-Hex 4DOF legs 172 | //First calibrate the servos in the 0 deg position using the SSC-32 reg offsets, then: 173 | #define cFemurHornOffset1 150 174 | #define cTarsHornOffset1 150 175 | 176 | //-------------------------------------------------------------------- 177 | //[LEG DIMENSIONS] 178 | //Universal dimensions for each leg in mm 179 | #define cXXCoxaLength 29 // This is for TH3-R legs 180 | #define cXXFemurLength 75 181 | #define cXXTibiaLength 71 182 | #define cXXTarsLength 85 // 4DOF only... 183 | 184 | #define cRRCoxaLength cXXCoxaLength //Right Rear leg 185 | #define cRRFemurLength cXXFemurLength 186 | #define cRRTibiaLength cXXTibiaLength 187 | #define cRRTarsLength cXXTarsLength //4DOF ONLY 188 | 189 | #define cRMCoxaLength cXXCoxaLength //Right middle leg 190 | #define cRMFemurLength cXXFemurLength 191 | #define cRMTibiaLength cXXTibiaLength 192 | #define cRMTarsLength cXXTarsLength //4DOF ONLY 193 | 194 | #define cRFCoxaLength cXXCoxaLength //Rigth front leg 195 | #define cRFFemurLength cXXFemurLength 196 | #define cRFTibiaLength cXXTibiaLength 197 | #define cRFTarsLength cXXTarsLength //4DOF ONLY 198 | 199 | #define cLRCoxaLength cXXCoxaLength //Left Rear leg 200 | #define cLRFemurLength cXXFemurLength 201 | #define cLRTibiaLength cXXTibiaLength 202 | #define cLRTarsLength cXXTarsLength //4DOF ONLY 203 | 204 | #define cLMCoxaLength cXXCoxaLength //Left middle leg 205 | #define cLMFemurLength cXXFemurLength 206 | #define cLMTibiaLength cXXTibiaLength 207 | #define cLMTarsLength cXXTarsLength //4DOF ONLY 208 | 209 | #define cLFCoxaLength cXXCoxaLength //Left front leg 210 | #define cLFFemurLength cXXFemurLength 211 | #define cLFTibiaLength cXXTibiaLength 212 | #define cLFTarsLength cXXTarsLength //4DOF ONLY 213 | 214 | 215 | //-------------------------------------------------------------------- 216 | //[BODY DIMENSIONS] 217 | #define cRRCoxaAngle1 -450 //Default Coxa setup angle, decimals = 1 218 | #define cRMCoxaAngle1 0 //Default Coxa setup angle, decimals = 1 219 | #define cRFCoxaAngle1 450 //Default Coxa setup angle, decimals = 1 220 | #define cLRCoxaAngle1 -450 //Default Coxa setup angle, decimals = 1 221 | #define cLMCoxaAngle1 0 //Default Coxa setup angle, decimals = 1 222 | #define cLFCoxaAngle1 450 //Default Coxa setup angle, decimals = 1 223 | 224 | #define cRROffsetX -52 //Distance X from center of the body to the Right Rear coxa 225 | #define cRROffsetZ 102 //Distance Z from center of the body to the Right Rear coxa 226 | #define cRMOffsetX -68 //Distance X from center of the body to the Right Middle coxa 227 | #define cRMOffsetZ 0 //Distance Z from center of the body to the Right Middle coxa 228 | #define cRFOffsetX -60 //Distance X from center of the body to the Right Front coxa 229 | #define cRFOffsetZ -102 //Distance Z from center of the body to the Right Front coxa 230 | 231 | #define cLROffsetX 52 //Distance X from center of the body to the Left Rear coxa 232 | #define cLROffsetZ 102 //Distance Z from center of the body to the Left Rear coxa 233 | #define cLMOffsetX 68 //Distance X from center of the body to the Left Middle coxa 234 | #define cLMOffsetZ 0 //Distance Z from center of the body to the Left Middle coxa 235 | #define cLFOffsetX 60 //Distance X from center of the body to the Left Front coxa 236 | #define cLFOffsetZ -102 //Distance Z from center of the body to the Left Front coxa 237 | 238 | //-------------------------------------------------------------------- 239 | //[START POSITIONS FEET] 240 | #define cHexInitXZ 105 241 | #define CHexInitXZCos45 74 // COS(45) = .7071 242 | #define CHexInitXZSin45 74 // sin(45) = .7071 243 | #define CHexInitY 26 244 | 245 | // Lets try some multi leg positions depending on height settings. 246 | #define CNT_HEX_INITS 3 247 | #define MAX_BODY_Y 90 248 | #ifdef DEFINE_HEX_GLOBALS 249 | const byte g_abHexIntXZ[] PROGMEM = { 250 | cHexInitXZ, 99, 86}; 251 | const byte g_abHexMaxBodyY[] PROGMEM = { 252 | 20, 50, MAX_BODY_Y}; 253 | #else 254 | extern const byte g_abHexIntXZ[] PROGMEM; 255 | extern const byte g_abHexMaxBodyY[] PROGMEM; 256 | #endif 257 | 258 | #define cRRInitPosX CHexInitXZCos45 //Start positions of the Right Rear leg 259 | #define cRRInitPosY CHexInitY 260 | #define cRRInitPosZ CHexInitXZSin45 261 | 262 | #define cRMInitPosX cHexInitXZ //Start positions of the Right Middle leg 263 | #define cRMInitPosY CHexInitY 264 | #define cRMInitPosZ 0 265 | 266 | #define cRFInitPosX CHexInitXZCos45 //Start positions of the Right Front leg 267 | #define cRFInitPosY CHexInitY 268 | #define cRFInitPosZ -CHexInitXZSin45 269 | 270 | #define cLRInitPosX CHexInitXZCos45 //Start positions of the Left Rear leg 271 | #define cLRInitPosY CHexInitY 272 | #define cLRInitPosZ CHexInitXZSin45 273 | 274 | #define cLMInitPosX cHexInitXZ //Start positions of the Left Middle leg 275 | #define cLMInitPosY CHexInitY 276 | #define cLMInitPosZ 0 277 | 278 | #define cLFInitPosX CHexInitXZCos45 //Start positions of the Left Front leg 279 | #define cLFInitPosY CHexInitY 280 | #define cLFInitPosZ -CHexInitXZSin45 281 | //-------------------------------------------------------------------- 282 | //[Tars factors used in formula to calc Tarsus angle relative to the ground] 283 | #define cTarsConst 720 //4DOF ONLY 284 | #define cTarsMulti 2 //4DOF ONLY 285 | #define cTarsFactorA 70 //4DOF ONLY 286 | #define cTarsFactorB 60 //4DOF ONLY 287 | #define cTarsFactorC 50 //4DOF ONLY 288 | 289 | #endif CFG_HEX_H 290 | 291 | 292 | 293 | -------------------------------------------------------------------------------- /Phoenix/Chr3_PS2_Orion/Hex_Cfg.h: -------------------------------------------------------------------------------- 1 | //==================================================================== 2 | //Project Lynxmotion Phoenix 3 | //Description: 4 | // This is the hardware configuration file for the Hex Robot. 5 | // 6 | // This version of the Configuration file is set up to run on the 7 | // Basic Micro DaVinci board with the Basic Micro Orion shield. 8 | // 9 | // This version of configuration file assumes that the servos will be controlled 10 | // by the Orion. 11 | // 12 | //Date: March 18, 2012 13 | //Programmer: Kurt (aka KurtE) 14 | // 15 | // 16 | //NEW IN V1.0 17 | // - First Release 18 | // 19 | //==================================================================== 20 | #ifndef HEX_CFG_CHR3_H 21 | #define HEX_CFG_CHR3_H 22 | 23 | 24 | // Which type of control(s) do you want to compile in 25 | 26 | #define DEBUG 27 | 28 | 29 | 30 | #ifdef __AVR__ 31 | #if defined(UBRR1H) 32 | #define SSCSerial Serial1 33 | #define XBeeSerial Serial3 //Serial2 34 | #else 35 | #define XBeeSerial Serial 36 | #define DontAllowDebug 37 | #endif 38 | #else // For My Pic32 Mega shield... 39 | #define SSCSerial Serial1 40 | #define XBeeSerial Serial3 41 | #endif 42 | 43 | //================================================================================================================================== 44 | // Define which input classes we will use. If we wish to use more than one we need to define USEMULTI - This will define a forwarder 45 | // type implementation, that the Inputcontroller will need to call. There will be some negotion for which one is in contol. 46 | // 47 | // If this is not defined, The included Controller should simply implement the InputController Class... 48 | //================================================================================================================================== 49 | //#define USEMULTI 50 | //#define USEXBEE // only allow to be defined on Megas... 51 | #define USEPS2 52 | //#define USECOMMANDER 53 | //#define USESERIAL 54 | 55 | // Do we want Debug Serial Output? 56 | #define DBGSerial Serial 57 | 58 | // Some configurations will not allow this so if one of them undefine it 59 | #if (defined USEXBEE) || (defined USECOMMANDER) 60 | #ifdef DontAllowDebug 61 | #undef DBGSerial 62 | #endif 63 | #endif 64 | 65 | #ifdef USESERIAL 66 | #undef DBGSerial 67 | #endif 68 | 69 | #ifdef DBGSerial 70 | #define OPT_TERMINAL_MONITOR // Only allow this to be defined if we have a debug serial port 71 | #endif 72 | 73 | #ifdef OPT_TERMINAL_MONITOR 74 | //#define OPT_SSC_FORWARDER // only useful if terminal monitor is enabled 75 | #define OPT_FIND_SERVO_OFFSETS // Only useful if terminal monitor is enabled 76 | #endif 77 | 78 | //#define OPT_GPPLAYER 79 | 80 | // Debug options 81 | //#define DEBUG_IOPINS // used to control if we are going to use IO pins for debug support 82 | 83 | //================================================================================================================================== 84 | //================================================================================================================================== 85 | //================================================================================================================================== 86 | // CHR-3 87 | //================================================================================================================================== 88 | 89 | //[We assume that this has to be a Mega to run the servos dirctly... 90 | // Set up for Basic Micro board 91 | #define SOUND_PIN 3 // 92 | #define PS2_DAT 6 93 | #define PS2_CMD 7 94 | #define PS2_SEL 8 95 | #define PS2_CLK 9 96 | 97 | // XBee was defined to use a hardware Serial port 98 | #define XBEE_BAUD 38400 99 | #define SERIAL_BAUD 38400 100 | 101 | // Define Analog pin and minimum voltage that we will allow the servos to run 102 | #define cVoltagePin A2 // Use our Analog pin jumper here... 103 | #define cTurnOffVol 470 // 4.7v 104 | #define cTurnOnVol 550 // 5.5V - optional part to say if voltage goes back up, turn it back on... 105 | 106 | //==================================================================== 107 | //[IO Pins On Orion Shield 108 | // Kurts new Mega Shield for Mega pin numbers. 109 | #define cRRCoxaPin 12 //Rear Right leg Hip Horizontal 110 | #define cRRFemurPin 13 //Rear Right leg Hip Vertical 111 | #define cRRTibiaPin 14 //Rear Right leg Knee 112 | #define cRRTarsPin 15 // Tar 113 | 114 | #define cRMCoxaPin 20 //Middle Right leg Hip Horizontal 115 | #define cRMFemurPin 21 //Middle Right leg Hip Vertical 116 | #define cRMTibiaPin 22 //Middle Right leg Knee 117 | #define cRMTarsPin 23 // Tar 118 | 119 | #define cRFCoxaPin 16 //Front Right leg Hip Horizontal 120 | #define cRFFemurPin 17 //Front Right leg Hip Vertical 121 | #define cRFTibiaPin 18 //Front Right leg Knee 122 | #define cRFTarsPin 19 // Tar 123 | 124 | #define cLRCoxaPin 8 //Rear Left leg Hip Horizontal 125 | #define cLRFemurPin 9 //Rear Left leg Hip Vertical 126 | #define cLRTibiaPin 10 //Rear Left leg Knee 127 | #define cLRTarsPin 11 // Tar 128 | 129 | #define cLMCoxaPin 4 //Middle Left leg Hip Horizontal 130 | #define cLMFemurPin 5 //Middle Left leg Hip Vertical 131 | #define cLMTibiaPin 6 //Middle Left leg Knee 132 | #define cLMTarsPin 7 // Tar = Not working... 133 | 134 | #define cLFCoxaPin 0 //Front Left leg Hip Horizontal 135 | #define cLFFemurPin 1 //Front Left leg Hip Vertical 136 | #define cLFTibiaPin 2 //Front Left leg Knee 137 | #define cLFTarsPin 3 // Tar 138 | 139 | //-------------------------------------------------------------------- 140 | //[MIN/MAX ANGLES] 141 | #define cRRCoxaMin1 -650 //Mechanical limits of the Right Rear Leg 142 | #define cRRCoxaMax1 650 143 | #define cRRFemurMin1 -1050 144 | #define cRRFemurMax1 750 145 | #define cRRTibiaMin1 -530 146 | #define cRRTibiaMax1 900 147 | #define cRRTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 148 | #define cRRTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 149 | 150 | #define cRMCoxaMin1 -650 //Mechanical limits of the Right Middle Leg 151 | #define cRMCoxaMax1 650 152 | #define cRMFemurMin1 -1050 153 | #define cRMFemurMax1 750 154 | #define cRMTibiaMin1 -530 155 | #define cRMTibiaMax1 900 156 | #define cRMTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 157 | #define cRMTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 158 | 159 | #define cRFCoxaMin1 -650 //Mechanical limits of the Right Front Leg 160 | #define cRFCoxaMax1 650 161 | #define cRFFemurMin1 -1050 162 | #define cRFFemurMax1 750 163 | #define cRFTibiaMin1 -530 164 | #define cRFTibiaMax1 900 165 | #define cRFTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 166 | #define cRFTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 167 | 168 | #define cLRCoxaMin1 -650 //Mechanical limits of the Left Rear Leg 169 | #define cLRCoxaMax1 650 170 | #define cLRFemurMin1 -1050 171 | #define cLRFemurMax1 750 172 | #define cLRTibiaMin1 -530 173 | #define cLRTibiaMax1 900 174 | #define cLRTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 175 | #define cLRTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 176 | 177 | #define cLMCoxaMin1 -650 //Mechanical limits of the Left Middle Leg 178 | #define cLMCoxaMax1 650 179 | #define cLMFemurMin1 -1050 180 | #define cLMFemurMax1 750 181 | #define cLMTibiaMin1 -530 182 | #define cLMTibiaMax1 900 183 | #define cLMTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 184 | #define cLMTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 185 | 186 | #define cLFCoxaMin1 -650 //Mechanical limits of the Left Front Leg 187 | #define cLFCoxaMax1 650 188 | #define cLFFemurMin1 -1050 189 | #define cLFFemurMax1 750 190 | #define cLFTibiaMin1 -530 191 | #define cLFTibiaMax1 900 192 | #define cLFTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 193 | #define cLFTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 194 | 195 | //-------------------------------------------------------------------- 196 | //[LEG DIMENSIONS] 197 | //Universal dimensions for each leg in mm 198 | #define cXXCoxaLength 29 // This is for CH3-R with Type 3 legs 199 | #define cXXFemurLength 57 200 | #define cXXTibiaLength 141 201 | #define cXXTarsLength 85 // 4DOF only... 202 | 203 | #define cRRCoxaLength cXXCoxaLength //Right Rear leg 204 | #define cRRFemurLength cXXFemurLength 205 | #define cRRTibiaLength cXXTibiaLength 206 | #define cRRTarsLength cXXTarsLength //4DOF ONLY 207 | 208 | #define cRMCoxaLength cXXCoxaLength //Right middle leg 209 | #define cRMFemurLength cXXFemurLength 210 | #define cRMTibiaLength cXXTibiaLength 211 | #define cRMTarsLength cXXTarsLength //4DOF ONLY 212 | 213 | #define cRFCoxaLength cXXCoxaLength //Rigth front leg 214 | #define cRFFemurLength cXXFemurLength 215 | #define cRFTibiaLength cXXTibiaLength 216 | #define cRFTarsLength cXXTarsLength //4DOF ONLY 217 | 218 | #define cLRCoxaLength cXXCoxaLength //Left Rear leg 219 | #define cLRFemurLength cXXFemurLength 220 | #define cLRTibiaLength cXXTibiaLength 221 | #define cLRTarsLength cXXTarsLength //4DOF ONLY 222 | 223 | #define cLMCoxaLength cXXCoxaLength //Left middle leg 224 | #define cLMFemurLength cXXFemurLength 225 | #define cLMTibiaLength cXXTibiaLength 226 | #define cLMTarsLength cXXTarsLength //4DOF ONLY 227 | 228 | #define cLFCoxaLength cXXCoxaLength //Left front leg 229 | #define cLFFemurLength cXXFemurLength 230 | #define cLFTibiaLength cXXTibiaLength 231 | #define cLFTarsLength cXXTarsLength //4DOF ONLY 232 | 233 | 234 | //-------------------------------------------------------------------- 235 | //[BODY DIMENSIONS] 236 | #define cRRCoxaAngle1 -600 //Default Coxa setup angle, decimals = 1 237 | #define cRMCoxaAngle1 0 //Default Coxa setup angle, decimals = 1 238 | #define cRFCoxaAngle1 600 //Default Coxa setup angle, decimals = 1 239 | #define cLRCoxaAngle1 -600 //Default Coxa setup angle, decimals = 1 240 | #define cLMCoxaAngle1 0 //Default Coxa setup angle, decimals = 1 241 | #define cLFCoxaAngle1 600 //Default Coxa setup angle, decimals = 1 242 | 243 | #define cRROffsetX -69 //Distance X from center of the body to the Right Rear coxa 244 | #define cRROffsetZ 119 //Distance Z from center of the body to the Right Rear coxa 245 | #define cRMOffsetX -138 //Distance X from center of the body to the Right Middle coxa 246 | #define cRMOffsetZ 0 //Distance Z from center of the body to the Right Middle coxa 247 | #define cRFOffsetX -69 //Distance X from center of the body to the Right Front coxa 248 | #define cRFOffsetZ -119 //Distance Z from center of the body to the Right Front coxa 249 | 250 | #define cLROffsetX 69 //Distance X from center of the body to the Left Rear coxa 251 | #define cLROffsetZ 119 //Distance Z from center of the body to the Left Rear coxa 252 | #define cLMOffsetX 138 //Distance X from center of the body to the Left Middle coxa 253 | #define cLMOffsetZ 0 //Distance Z from center of the body to the Left Middle coxa 254 | #define cLFOffsetX 69 //Distance X from center of the body to the Left Front coxa 255 | #define cLFOffsetZ -119 //Distance Z from center of the body to the Left Front coxa 256 | 257 | //-------------------------------------------------------------------- 258 | //[START POSITIONS FEET] 259 | #define cHexInitXZ 111 260 | #define CHexInitXZCos60 56 // COS(60) = .5 261 | #define CHexInitXZSin60 96 // sin(60) = .866 262 | #define CHexInitY 65 //30 263 | 264 | // Lets try some multi leg positions depending on height settings. 265 | #define CNT_HEX_INITS 3 266 | #define MAX_BODY_Y 90 267 | #ifdef DEFINE_HEX_GLOBALS 268 | const byte g_abHexIntXZ[] PROGMEM = {cHexInitXZ, 99, 86}; 269 | const byte g_abHexMaxBodyY[] PROGMEM = { 20, 50, MAX_BODY_Y}; 270 | #else 271 | extern const byte g_abHexIntXZ[] PROGMEM; 272 | extern const byte g_abHexMaxBodyY[] PROGMEM; 273 | #endif 274 | 275 | #define cRRInitPosX CHexInitXZCos60 //Start positions of the Right Rear leg 276 | #define cRRInitPosY CHexInitY 277 | #define cRRInitPosZ CHexInitXZSin60 278 | 279 | #define cRMInitPosX cHexInitXZ //Start positions of the Right Middle leg 280 | #define cRMInitPosY CHexInitY 281 | #define cRMInitPosZ 0 282 | 283 | #define cRFInitPosX CHexInitXZCos60 //Start positions of the Right Front leg 284 | #define cRFInitPosY CHexInitY 285 | #define cRFInitPosZ -CHexInitXZSin60 286 | 287 | #define cLRInitPosX CHexInitXZCos60 //Start positions of the Left Rear leg 288 | #define cLRInitPosY CHexInitY 289 | #define cLRInitPosZ CHexInitXZSin60 290 | 291 | #define cLMInitPosX cHexInitXZ //Start positions of the Left Middle leg 292 | #define cLMInitPosY CHexInitY 293 | #define cLMInitPosZ 0 294 | 295 | #define cLFInitPosX CHexInitXZCos60 //Start positions of the Left Front leg 296 | #define cLFInitPosY CHexInitY 297 | #define cLFInitPosZ -CHexInitXZSin60 298 | //-------------------------------------------------------------------- 299 | //[Tars factors used in formula to calc Tarsus angle relative to the ground] 300 | #define cTarsConst 720 //4DOF ONLY 301 | #define cTarsMulti 2 //4DOF ONLY 302 | #define cTarsFactorA 70 //4DOF ONLY 303 | #define cTarsFactorB 60 //4DOF ONLY 304 | #define cTarsFactorC 50 //4DOF ONLY 305 | 306 | #endif CFG_HEX_H 307 | 308 | -------------------------------------------------------------------------------- /Phoenix/Chr3_RC_SSC32/Hex_Cfg.h: -------------------------------------------------------------------------------- 1 | //==================================================================== 2 | //Project Lynxmotion Phoenix 3 | //Description: 4 | // This is the hardware configuration file for the Hex Robot. 5 | // 6 | // This version of the Configuration file is set up to run on the 7 | // Lynxmotion BotboardDuino board, which is similar to the Arduino Duemilanove 8 | // 9 | // This version of configuration file assumes that the servos will be controlled 10 | // by a Lynxmotion Servo controller SSC-32 and the user is using a Lynxmotion 11 | // PS2 to control the robot. 12 | // 13 | //Date: March 18, 2012 14 | //Programmer: Kurt (aka KurtE) 15 | // 16 | // 17 | //NEW IN V1.0 18 | // - First Release 19 | // 20 | //==================================================================== 21 | #ifndef HEX_CFG_CHR3_H 22 | #define HEX_CFG_CHR3_H 23 | 24 | 25 | // Which type of control(s) do you want to compile in 26 | 27 | 28 | // For this RC Test will put SSCSerial on the main hardware serial port as I am using pin change interrupts which use the 29 | // same interrupt vectors as SoftwareSerial also blindly uses... 30 | #define SSCSerial Serial 31 | 32 | //================================================================================================================================== 33 | // Define which input classes we will use. If we wish to use more than one we need to define USEMULTI - This will define a forwarder 34 | // type implementation, that the Inputcontroller will need to call. There will be some negotion for which one is in contol. 35 | // 36 | // If this is not defined, The included Controller should simply implement the InputController Class... 37 | //================================================================================================================================== 38 | 39 | // Do we want Debug Serial Output? So don't allow Debug output 40 | #define DBGSerial Serial 41 | #define DontAllowDebug 42 | 43 | 44 | // NOW split up the two global configurations... 45 | #ifdef DBGSerial 46 | #define OPT_TERMINAL_MONITOR // Only allow this to be defined if we have a debug serial port 47 | #endif 48 | 49 | #ifdef OPT_TERMINAL_MONITOR 50 | //#define OPT_SSC_FORWARDER // only useful if terminal monitor is enabled 51 | #define OPT_FIND_SERVO_OFFSETS // Only useful if terminal monitor is enabled 52 | #endif 53 | 54 | #define OPT_GPPLAYER 55 | 56 | //================================================================================================================================== 57 | //================================================================================================================================== 58 | //================================================================================================================================== 59 | // CHR-3 60 | //================================================================================================================================== 61 | #define USE_SSC32 62 | #define cSSC_BINARYMODE 1 // Define if your SSC-32 card supports binary mode. 63 | 64 | //[SERIAL CONNECTIONS] 65 | 66 | 67 | // Warning I will undefine some components as the non-megas don't have enough memory... 68 | //#undef OPT_FIND_SERVO_OFFSETS 69 | 70 | #define cSSC_BAUD 38400 //SSC32 BAUD rate 71 | 72 | //-------------------------------------------------------------------- 73 | //[Botboarduino Pin Numbers] 74 | #define SOUND_PIN 5 // Botboarduino JR pin number 75 | 76 | // RC Informatin 77 | #define RC_VALID_MIN 950 // Should be enough slop.... 78 | #define RC_VALID_MAX 2000 79 | #define RC_VALID_PIN_MASK 0x3f // Should generate this... But I have 6 pins 80 | 81 | // Define the Pins that are used by the RC Receiver 82 | const byte caRCPins[] PROGMEM = {6, 7, 8, 9, 10, 11}; 83 | #define RCPIN_COUNT (sizeof(caRCPins)/sizeof(caRCPins[0])) 84 | 85 | 86 | // Define Baud rate for Serial input. 87 | #define SERIAL_BAUD 38400 88 | 89 | 90 | // If we are using a SSC-32 then: 91 | // If were are running on an Arduino Mega we will use one of the hardware serial port, default to Serial1 above. 92 | // If on Non mega, if the IO pins are set to 0, we will overload the hardware Serial port 93 | // Else we will user SoftwareSerial to talk to the SSC-32 94 | #define cSSC_OUT 0 //Output pin for (SSC32 RX) on BotBoard (Yellow) 95 | #define cSSC_IN 0 //Input pin for (SSC32 TX) on BotBoard (Blue) 96 | 97 | //==================================================================== 98 | //[SSC PIN NUMBERS] 99 | #define cRRCoxaPin 0 //Rear Right leg Hip Horizontal 100 | #define cRRFemurPin 1 //Rear Right leg Hip Vertical 101 | #define cRRTibiaPin 2 //Rear Right leg Knee 102 | #define cRRTarsPin 3 // Tar 103 | 104 | #define cRMCoxaPin 4 //Middle Right leg Hip Horizontal 105 | #define cRMFemurPin 5 //Middle Right leg Hip Vertical 106 | #define cRMTibiaPin 6 //Middle Right leg Knee 107 | #define cRMTarsPin 7 // Tar 108 | 109 | #define cRFCoxaPin 8 //Front Right leg Hip Horizontal 110 | #define cRFFemurPin 9 //Front Right leg Hip Vertical 111 | #define cRFTibiaPin 10 //Front Right leg Knee 112 | #define cRFTarsPin 11 // Tar 113 | 114 | #define cLRCoxaPin 16 //Rear Left leg Hip Horizontal 115 | #define cLRFemurPin 17 //Rear Left leg Hip Vertical 116 | #define cLRTibiaPin 18 //Rear Left leg Knee 117 | #define cLRTarsPin 19 // Tar 118 | 119 | #define cLMCoxaPin 20 //Middle Left leg Hip Horizontal 120 | #define cLMFemurPin 21 //Middle Left leg Hip Vertical 121 | #define cLMTibiaPin 22 //Middle Left leg Knee 122 | #define cLMTarsPin 23 // Tar 123 | 124 | #define cLFCoxaPin 24 //Front Left leg Hip Horizontal 125 | #define cLFFemurPin 25 //Front Left leg Hip Vertical 126 | #define cLFTibiaPin 26 //Front Left leg Knee 127 | #define cLFTarsPin 27 // Tar 128 | 129 | 130 | //-------------------------------------------------------------------- 131 | //[MIN/MAX ANGLES] 132 | #define cRRCoxaMin1 -650 //Mechanical limits of the Right Rear Leg 133 | #define cRRCoxaMax1 650 134 | #define cRRFemurMin1 -1050 135 | #define cRRFemurMax1 750 136 | #define cRRTibiaMin1 -530 137 | #define cRRTibiaMax1 900 138 | #define cRRTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 139 | #define cRRTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 140 | 141 | #define cRMCoxaMin1 -650 //Mechanical limits of the Right Middle Leg 142 | #define cRMCoxaMax1 650 143 | #define cRMFemurMin1 -1050 144 | #define cRMFemurMax1 750 145 | #define cRMTibiaMin1 -530 146 | #define cRMTibiaMax1 900 147 | #define cRMTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 148 | #define cRMTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 149 | 150 | #define cRFCoxaMin1 -650 //Mechanical limits of the Right Front Leg 151 | #define cRFCoxaMax1 650 152 | #define cRFFemurMin1 -1050 153 | #define cRFFemurMax1 750 154 | #define cRFTibiaMin1 -530 155 | #define cRFTibiaMax1 900 156 | #define cRFTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 157 | #define cRFTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 158 | 159 | #define cLRCoxaMin1 -650 //Mechanical limits of the Left Rear Leg 160 | #define cLRCoxaMax1 650 161 | #define cLRFemurMin1 -1050 162 | #define cLRFemurMax1 750 163 | #define cLRTibiaMin1 -530 164 | #define cLRTibiaMax1 900 165 | #define cLRTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 166 | #define cLRTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 167 | 168 | #define cLMCoxaMin1 -650 //Mechanical limits of the Left Middle Leg 169 | #define cLMCoxaMax1 650 170 | #define cLMFemurMin1 -1050 171 | #define cLMFemurMax1 750 172 | #define cLMTibiaMin1 -530 173 | #define cLMTibiaMax1 900 174 | #define cLMTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 175 | #define cLMTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 176 | 177 | #define cLFCoxaMin1 -650 //Mechanical limits of the Left Front Leg 178 | #define cLFCoxaMax1 650 179 | #define cLFFemurMin1 -1050 180 | #define cLFFemurMax1 750 181 | #define cLFTibiaMin1 -530 182 | #define cLFTibiaMax1 900 183 | #define cLFTarsMin1 -1300 //4DOF ONLY - In theory the kinematics can reach about -160 deg 184 | #define cLFTarsMax1 500 //4DOF ONLY - The kinematics will never exceed 23 deg though.. 185 | 186 | //-------------------------------------------------------------------- 187 | //[LEG DIMENSIONS] 188 | //Universal dimensions for each leg in mm 189 | #define cXXCoxaLength 29 // This is for CH3-R with Type 3 legs 190 | #define cXXFemurLength 57 191 | #define cXXTibiaLength 141 192 | #define cXXTarsLength 85 // 4DOF only... 193 | 194 | #define cRRCoxaLength cXXCoxaLength //Right Rear leg 195 | #define cRRFemurLength cXXFemurLength 196 | #define cRRTibiaLength cXXTibiaLength 197 | #define cRRTarsLength cXXTarsLength //4DOF ONLY 198 | 199 | #define cRMCoxaLength cXXCoxaLength //Right middle leg 200 | #define cRMFemurLength cXXFemurLength 201 | #define cRMTibiaLength cXXTibiaLength 202 | #define cRMTarsLength cXXTarsLength //4DOF ONLY 203 | 204 | #define cRFCoxaLength cXXCoxaLength //Rigth front leg 205 | #define cRFFemurLength cXXFemurLength 206 | #define cRFTibiaLength cXXTibiaLength 207 | #define cRFTarsLength cXXTarsLength //4DOF ONLY 208 | 209 | #define cLRCoxaLength cXXCoxaLength //Left Rear leg 210 | #define cLRFemurLength cXXFemurLength 211 | #define cLRTibiaLength cXXTibiaLength 212 | #define cLRTarsLength cXXTarsLength //4DOF ONLY 213 | 214 | #define cLMCoxaLength cXXCoxaLength //Left middle leg 215 | #define cLMFemurLength cXXFemurLength 216 | #define cLMTibiaLength cXXTibiaLength 217 | #define cLMTarsLength cXXTarsLength //4DOF ONLY 218 | 219 | #define cLFCoxaLength cXXCoxaLength //Left front leg 220 | #define cLFFemurLength cXXFemurLength 221 | #define cLFTibiaLength cXXTibiaLength 222 | #define cLFTarsLength cXXTarsLength //4DOF ONLY 223 | 224 | 225 | //-------------------------------------------------------------------- 226 | //[BODY DIMENSIONS] 227 | #define cRRCoxaAngle1 -600 //Default Coxa setup angle, decimals = 1 228 | #define cRMCoxaAngle1 0 //Default Coxa setup angle, decimals = 1 229 | #define cRFCoxaAngle1 600 //Default Coxa setup angle, decimals = 1 230 | #define cLRCoxaAngle1 -600 //Default Coxa setup angle, decimals = 1 231 | #define cLMCoxaAngle1 0 //Default Coxa setup angle, decimals = 1 232 | #define cLFCoxaAngle1 600 //Default Coxa setup angle, decimals = 1 233 | 234 | #define cRROffsetX -69 //Distance X from center of the body to the Right Rear coxa 235 | #define cRROffsetZ 119 //Distance Z from center of the body to the Right Rear coxa 236 | #define cRMOffsetX -138 //Distance X from center of the body to the Right Middle coxa 237 | #define cRMOffsetZ 0 //Distance Z from center of the body to the Right Middle coxa 238 | #define cRFOffsetX -69 //Distance X from center of the body to the Right Front coxa 239 | #define cRFOffsetZ -119 //Distance Z from center of the body to the Right Front coxa 240 | 241 | #define cLROffsetX 69 //Distance X from center of the body to the Left Rear coxa 242 | #define cLROffsetZ 119 //Distance Z from center of the body to the Left Rear coxa 243 | #define cLMOffsetX 138 //Distance X from center of the body to the Left Middle coxa 244 | #define cLMOffsetZ 0 //Distance Z from center of the body to the Left Middle coxa 245 | #define cLFOffsetX 69 //Distance X from center of the body to the Left Front coxa 246 | #define cLFOffsetZ -119 //Distance Z from center of the body to the Left Front coxa 247 | 248 | //-------------------------------------------------------------------- 249 | //[START POSITIONS FEET] 250 | #define cHexInitXZ 111 251 | #define CHexInitXZCos60 56 // COS(60) = .5 252 | #define CHexInitXZSin60 96 // sin(60) = .866 253 | #define CHexInitY 65 //30 254 | 255 | // Lets try some multi leg positions depending on height settings. 256 | #define CNT_HEX_INITS 3 257 | #define MAX_BODY_Y 90 258 | #ifdef DEFINE_HEX_GLOBALS 259 | const byte g_abHexIntXZ[] PROGMEM = {cHexInitXZ, 99, 86}; 260 | const byte g_abHexMaxBodyY[] PROGMEM = { 20, 50, MAX_BODY_Y}; 261 | #else 262 | extern const byte g_abHexIntXZ[] PROGMEM; 263 | extern const byte g_abHexMaxBodyY[] PROGMEM; 264 | #endif 265 | 266 | #define cRRInitPosX CHexInitXZCos60 //Start positions of the Right Rear leg 267 | #define cRRInitPosY CHexInitY 268 | #define cRRInitPosZ CHexInitXZSin60 269 | 270 | #define cRMInitPosX cHexInitXZ //Start positions of the Right Middle leg 271 | #define cRMInitPosY CHexInitY 272 | #define cRMInitPosZ 0 273 | 274 | #define cRFInitPosX CHexInitXZCos60 //Start positions of the Right Front leg 275 | #define cRFInitPosY CHexInitY 276 | #define cRFInitPosZ -CHexInitXZSin60 277 | 278 | #define cLRInitPosX CHexInitXZCos60 //Start positions of the Left Rear leg 279 | #define cLRInitPosY CHexInitY 280 | #define cLRInitPosZ CHexInitXZSin60 281 | 282 | #define cLMInitPosX cHexInitXZ //Start positions of the Left Middle leg 283 | #define cLMInitPosY CHexInitY 284 | #define cLMInitPosZ 0 285 | 286 | #define cLFInitPosX CHexInitXZCos60 //Start positions of the Left Front leg 287 | #define cLFInitPosY CHexInitY 288 | #define cLFInitPosZ -CHexInitXZSin60 289 | //-------------------------------------------------------------------- 290 | //[Tars factors used in formula to calc Tarsus angle relative to the ground] 291 | #define cTarsConst 720 //4DOF ONLY 292 | #define cTarsMulti 2 //4DOF ONLY 293 | #define cTarsFactorA 70 //4DOF ONLY 294 | #define cTarsFactorB 60 //4DOF ONLY 295 | #define cTarsFactorC 50 //4DOF ONLY 296 | 297 | #endif //CFG_HEX_H 298 | 299 | --------------------------------------------------------------------------------