forward
Dependencies: VNH5019
Fork of AigamozuControlPackets by
AigamozuControlPackets.h@9:4f675487f06b, 2015-04-10 (annotated)
- Committer:
- s1200058
- Date:
- Fri Apr 10 12:58:42 2015 +0000
- Revision:
- 9:4f675487f06b
- Parent:
- 8:aff2d67d31c8
- Child:
- 11:4d71c9cc3b4a
yokokawa;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
m5171135 | 0:2b8b56ac7a82 | 1 | #include "mbed.h" |
m5171135 | 0:2b8b56ac7a82 | 2 | #include "VNH5019.h" |
m5171135 | 0:2b8b56ac7a82 | 3 | |
m5171135 | 0:2b8b56ac7a82 | 4 | #ifndef AIGAMOZU_CONTROL_PACKETS |
m5171135 | 0:2b8b56ac7a82 | 5 | #define AIGAMOZU_CONTROL_PACKETS |
m5171135 | 0:2b8b56ac7a82 | 6 | |
m5171135 | 2:3f2d4f53ceed | 7 | #define MANUAL_COMMAND_LENGTH 17 |
m5171135 | 2:3f2d4f53ceed | 8 | #define REQUEST_COMMNAD_LENGTH 11 |
m5171135 | 2:3f2d4f53ceed | 9 | #define CHANGE_MODE_COMMAND_LENGTH 12 |
m5171135 | 2:3f2d4f53ceed | 10 | #define RECEIVE_STATUS_COMMNAD_LENGTH 32 |
m5171135 | 0:2b8b56ac7a82 | 11 | |
m5171135 | 7:200ce5c1f486 | 12 | #define vertex2D vector2D |
m5171135 | 7:200ce5c1f486 | 13 | |
s1200058 | 9:4f675487f06b | 14 | enum COMMAND_TYPE {MANUAL = 'M', STATUS_REQUEST = 'S', CHANGE_MODE = 'C', RECEIVE_STATUS = 'R'}; |
m5171135 | 4:04dadf67ecb6 | 15 | enum MODE {STANDBY_MODE = 0, MANUAL_MODE = 1,AUTO_MODE = 2,AUTO_GPS_MODE = 3}; |
m5171135 | 6:f164a716be46 | 16 | enum STATUS {GPS_AVAIL = 0, GPS_UNAVAIL = 1,GPS_OUT_AREA = 2}; |
m5171135 | 0:2b8b56ac7a82 | 17 | |
m5171135 | 0:2b8b56ac7a82 | 18 | union TEST_T{ |
m5171135 | 0:2b8b56ac7a82 | 19 | long a; |
m5171135 | 0:2b8b56ac7a82 | 20 | uint8_t b[4]; |
m5171135 | 0:2b8b56ac7a82 | 21 | }; |
m5171135 | 7:200ce5c1f486 | 22 | |
m5171135 | 7:200ce5c1f486 | 23 | struct vector2D{ |
m5171135 | 7:200ce5c1f486 | 24 | double x; |
m5171135 | 7:200ce5c1f486 | 25 | double y; |
m5171135 | 7:200ce5c1f486 | 26 | }; |
m5171135 | 7:200ce5c1f486 | 27 | |
m5171135 | 0:2b8b56ac7a82 | 28 | class AigamozuControlPackets{ |
m5171135 | 0:2b8b56ac7a82 | 29 | |
m5171135 | 6:f164a716be46 | 30 | //--------PUBLIC-----------// |
m5171135 | 0:2b8b56ac7a82 | 31 | public: |
m5171135 | 5:3f51eeb5aedc | 32 | AigamozuControlPackets(VNH5019 agzSheild); |
m5171135 | 5:3f51eeb5aedc | 33 | |
m5171135 | 6:f164a716be46 | 34 | Ticker eachModeInt; |
m5171135 | 0:2b8b56ac7a82 | 35 | |
m5171135 | 2:3f2d4f53ceed | 36 | uint8_t* packetData; |
m5171135 | 2:3f2d4f53ceed | 37 | //Create Packet: Controller/Base -> Robot |
m5171135 | 2:3f2d4f53ceed | 38 | void createManualCommad(uint8_t fromID,uint8_t toID,uint8_t directionL,uint8_t pwmL,uint8_t directionR, uint8_t pwmR); |
s1200058 | 9:4f675487f06b | 39 | void createRequestCommand(uint8_t fromID,uint8_t toID); |
m5171135 | 2:3f2d4f53ceed | 40 | void createChangeModeCommand(uint8_t fromID,uint8_t toID,uint8_t,MODE mode); |
m5171135 | 0:2b8b56ac7a82 | 41 | |
m5171135 | 2:3f2d4f53ceed | 42 | //Create Packet: Robot -> Controller/Base |
m5171135 | 2:3f2d4f53ceed | 43 | void createReceiveStatusCommand(uint8_t fromID,uint8_t toID,long latitudeH,long latitudeL,long longitudeH,long longitudeL); |
m5171135 | 2:3f2d4f53ceed | 44 | //uint8_t* createAckPacket(uint8_t fromID,uint8_t toID); |
m5171135 | 0:2b8b56ac7a82 | 45 | |
m5171135 | 2:3f2d4f53ceed | 46 | //using create packet |
m5171135 | 2:3f2d4f53ceed | 47 | uint8_t* getPacketData(); |
m5171135 | 2:3f2d4f53ceed | 48 | int getPacketLength(); |
m5171135 | 2:3f2d4f53ceed | 49 | |
m5171135 | 2:3f2d4f53ceed | 50 | //Change Mode: |
m5171135 | 2:3f2d4f53ceed | 51 | bool changeMode(uint8_t *buf); |
m5171135 | 5:3f51eeb5aedc | 52 | |
m5171135 | 5:3f51eeb5aedc | 53 | //Check Command Type using xbee buffer; |
m5171135 | 0:2b8b56ac7a82 | 54 | uint8_t checkCommnadType(uint8_t* buf); |
m5171135 | 0:2b8b56ac7a82 | 55 | |
s1200058 | 9:4f675487f06b | 56 | //Change Speed |
m5171135 | 5:3f51eeb5aedc | 57 | void changeSpeed(uint8_t* buf); |
m5171135 | 5:3f51eeb5aedc | 58 | |
m5171135 | 0:2b8b56ac7a82 | 59 | MODE nowMode; |
m5171135 | 0:2b8b56ac7a82 | 60 | STATUS nowStatus; |
m5171135 | 4:04dadf67ecb6 | 61 | int packetLength; |
m5171135 | 4:04dadf67ecb6 | 62 | |
m5171135 | 4:04dadf67ecb6 | 63 | |
m5171135 | 7:200ce5c1f486 | 64 | void reNewPoint(long latitudeH,long latitudeL,long longitudeH,long longitudeL); |
m5171135 | 7:200ce5c1f486 | 65 | |
m5171135 | 6:f164a716be46 | 66 | //--------PRIVATE-----------// |
m5171135 | 0:2b8b56ac7a82 | 67 | private: |
m5171135 | 5:3f51eeb5aedc | 68 | // |
m5171135 | 5:3f51eeb5aedc | 69 | VNH5019 _agzSheild; |
m5171135 | 5:3f51eeb5aedc | 70 | |
m5171135 | 5:3f51eeb5aedc | 71 | void manualMode(); |
m5171135 | 5:3f51eeb5aedc | 72 | int manualCount; |
m5171135 | 5:3f51eeb5aedc | 73 | |
m5171135 | 5:3f51eeb5aedc | 74 | //Auto Type 1 -> Random |
m5171135 | 5:3f51eeb5aedc | 75 | void randomAuto(); |
m5171135 | 5:3f51eeb5aedc | 76 | int randomCount; |
m5171135 | 5:3f51eeb5aedc | 77 | |
m5171135 | 5:3f51eeb5aedc | 78 | //Auto Type 2 -> GPS |
m5171135 | 5:3f51eeb5aedc | 79 | void gpsAuto(); |
m5171135 | 7:200ce5c1f486 | 80 | |
m5171135 | 7:200ce5c1f486 | 81 | vector2D agzPoint; |
m5171135 | 7:200ce5c1f486 | 82 | vector2D sub_vector( const vector2D& a, const vector2D& b ); |
m5171135 | 7:200ce5c1f486 | 83 | bool checkGpsHit( vertex2D A, vertex2D B, vertex2D C, vertex2D P); |
m5171135 | 7:200ce5c1f486 | 84 | |
m5171135 | 7:200ce5c1f486 | 85 | vector2D basePoint[4]; |
m5171135 | 7:200ce5c1f486 | 86 | |
m5171135 | 0:2b8b56ac7a82 | 87 | }; |
m5171135 | 0:2b8b56ac7a82 | 88 | |
m5171135 | 0:2b8b56ac7a82 | 89 | #endif |