forward
Dependencies: VNH5019
Fork of AigamozuControlPackets by
AigamozuControlPackets.h@13:a5bc425540a7, 2015-04-20 (annotated)
- Committer:
- kityann
- Date:
- Mon Apr 20 10:36:16 2015 +0000
- Revision:
- 13:a5bc425540a7
- Parent:
- 11:4d71c9cc3b4a
- Child:
- 17:a6fa8cc96d94
improve the Kalman system
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 | |
kityann | 13:a5bc425540a7 | 14 | enum COMMAND_TYPE {MANUAL = 'M', STATUS_REQUEST = 'S', CHANGE_MODE = 'C', RECEIVE_STATUS = 'R',RECEIVE_KALMAN = 'K'}; |
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); |
kityann | 13:a5bc425540a7 | 44 | void createReceiveStatusCommandwithKalman(uint8_t fromID,uint8_t toID,long latitudeH,long latitudeL,long longitudeH,long longitudeL); |
m5171135 | 2:3f2d4f53ceed | 45 | //uint8_t* createAckPacket(uint8_t fromID,uint8_t toID); |
m5171135 | 0:2b8b56ac7a82 | 46 | |
m5171135 | 2:3f2d4f53ceed | 47 | //using create packet |
m5171135 | 2:3f2d4f53ceed | 48 | uint8_t* getPacketData(); |
m5171135 | 2:3f2d4f53ceed | 49 | int getPacketLength(); |
m5171135 | 2:3f2d4f53ceed | 50 | |
m5171135 | 2:3f2d4f53ceed | 51 | //Change Mode: |
m5171135 | 2:3f2d4f53ceed | 52 | bool changeMode(uint8_t *buf); |
m5171135 | 5:3f51eeb5aedc | 53 | |
m5171135 | 5:3f51eeb5aedc | 54 | //Check Command Type using xbee buffer; |
m5171135 | 0:2b8b56ac7a82 | 55 | uint8_t checkCommnadType(uint8_t* buf); |
m5171135 | 0:2b8b56ac7a82 | 56 | |
s1200058 | 9:4f675487f06b | 57 | //Change Speed |
m5171135 | 5:3f51eeb5aedc | 58 | void changeSpeed(uint8_t* buf); |
m5171135 | 5:3f51eeb5aedc | 59 | |
m5171135 | 0:2b8b56ac7a82 | 60 | MODE nowMode; |
m5171135 | 0:2b8b56ac7a82 | 61 | STATUS nowStatus; |
m5171135 | 4:04dadf67ecb6 | 62 | int packetLength; |
m5171135 | 4:04dadf67ecb6 | 63 | |
m5171135 | 4:04dadf67ecb6 | 64 | |
kityann | 13:a5bc425540a7 | 65 | void reNewRobotPointKalman(long latitudeH,long latitudeL,long longitudeH,long longitudeL); |
kityann | 13:a5bc425540a7 | 66 | void reNewBasePointKalman(int id, long latitudeH,long latitudeL,long longitudeH,long longitudeL); |
kityann | 11:4d71c9cc3b4a | 67 | void reNewRobotPoint(long latitudeH,long latitudeL,long longitudeH,long longitudeL); |
kityann | 11:4d71c9cc3b4a | 68 | void reNewBasePoint(int id, long latitudeH,long latitudeL,long longitudeH,long longitudeL); |
kityann | 13:a5bc425540a7 | 69 | |
m5171135 | 6:f164a716be46 | 70 | //--------PRIVATE-----------// |
m5171135 | 0:2b8b56ac7a82 | 71 | private: |
m5171135 | 5:3f51eeb5aedc | 72 | // |
m5171135 | 5:3f51eeb5aedc | 73 | VNH5019 _agzSheild; |
m5171135 | 5:3f51eeb5aedc | 74 | |
m5171135 | 5:3f51eeb5aedc | 75 | void manualMode(); |
m5171135 | 5:3f51eeb5aedc | 76 | int manualCount; |
m5171135 | 5:3f51eeb5aedc | 77 | |
m5171135 | 5:3f51eeb5aedc | 78 | //Auto Type 1 -> Random |
m5171135 | 5:3f51eeb5aedc | 79 | void randomAuto(); |
m5171135 | 5:3f51eeb5aedc | 80 | int randomCount; |
m5171135 | 5:3f51eeb5aedc | 81 | |
m5171135 | 5:3f51eeb5aedc | 82 | //Auto Type 2 -> GPS |
m5171135 | 5:3f51eeb5aedc | 83 | void gpsAuto(); |
m5171135 | 7:200ce5c1f486 | 84 | |
m5171135 | 7:200ce5c1f486 | 85 | vector2D agzPoint; |
kityann | 13:a5bc425540a7 | 86 | vector2D agzPointKalman; |
m5171135 | 7:200ce5c1f486 | 87 | vector2D sub_vector( const vector2D& a, const vector2D& b ); |
m5171135 | 7:200ce5c1f486 | 88 | bool checkGpsHit( vertex2D A, vertex2D B, vertex2D C, vertex2D P); |
m5171135 | 7:200ce5c1f486 | 89 | |
m5171135 | 7:200ce5c1f486 | 90 | vector2D basePoint[4]; |
kityann | 13:a5bc425540a7 | 91 | vector2D basePointKalman[4]; |
m5171135 | 7:200ce5c1f486 | 92 | |
m5171135 | 0:2b8b56ac7a82 | 93 | }; |
m5171135 | 0:2b8b56ac7a82 | 94 | |
m5171135 | 0:2b8b56ac7a82 | 95 | #endif |