forward

Dependencies:   VNH5019

Fork of AigamozuControlPackets by aigamozu

Committer:
s1200058
Date:
Fri May 15 08:18:38 2015 +0000
Revision:
25:119fd6c9ae80
Parent:
20:fec2d6dec897
Child:
26:195c054a0148
2015/05/15

Who changed what in which revision?

UserRevisionLine numberNew 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
kityann 17:a6fa8cc96d94 10 #define RECEIVE_STATUS_COMMNAD_LENGTH 64
m5171135 0:2b8b56ac7a82 11
m5171135 7:200ce5c1f486 12 #define vertex2D vector2D
m5171135 7:200ce5c1f486 13
kityann 19:13b24b50800e 14 #define BASENUMBER 10
kityann 19:13b24b50800e 15
kityann 13:a5bc425540a7 16 enum COMMAND_TYPE {MANUAL = 'M', STATUS_REQUEST = 'S', CHANGE_MODE = 'C', RECEIVE_STATUS = 'R',RECEIVE_KALMAN = 'K'};
m5171135 4:04dadf67ecb6 17 enum MODE {STANDBY_MODE = 0, MANUAL_MODE = 1,AUTO_MODE = 2,AUTO_GPS_MODE = 3};
m5171135 6:f164a716be46 18 enum STATUS {GPS_AVAIL = 0, GPS_UNAVAIL = 1,GPS_OUT_AREA = 2};
m5171135 0:2b8b56ac7a82 19
m5171135 0:2b8b56ac7a82 20 union TEST_T{
m5171135 0:2b8b56ac7a82 21 long a;
m5171135 0:2b8b56ac7a82 22 uint8_t b[4];
m5171135 0:2b8b56ac7a82 23 };
m5171135 7:200ce5c1f486 24
kityann 17:a6fa8cc96d94 25 union UNION_double_char{
kityann 17:a6fa8cc96d94 26 double double_value;
kityann 17:a6fa8cc96d94 27 uint8_t char_value[8];
kityann 17:a6fa8cc96d94 28 };
kityann 17:a6fa8cc96d94 29
m5171135 7:200ce5c1f486 30 struct vector2D{
m5171135 7:200ce5c1f486 31 double x;
m5171135 7:200ce5c1f486 32 double y;
m5171135 7:200ce5c1f486 33 };
m5171135 7:200ce5c1f486 34
m5171135 0:2b8b56ac7a82 35 class AigamozuControlPackets{
m5171135 0:2b8b56ac7a82 36
m5171135 6:f164a716be46 37 //--------PUBLIC-----------//
m5171135 0:2b8b56ac7a82 38 public:
m5171135 5:3f51eeb5aedc 39 AigamozuControlPackets(VNH5019 agzSheild);
m5171135 5:3f51eeb5aedc 40
m5171135 6:f164a716be46 41 Ticker eachModeInt;
m5171135 0:2b8b56ac7a82 42
m5171135 2:3f2d4f53ceed 43 uint8_t* packetData;
m5171135 2:3f2d4f53ceed 44 //Create Packet: Controller/Base -> Robot
m5171135 2:3f2d4f53ceed 45 void createManualCommad(uint8_t fromID,uint8_t toID,uint8_t directionL,uint8_t pwmL,uint8_t directionR, uint8_t pwmR);
s1200058 9:4f675487f06b 46 void createRequestCommand(uint8_t fromID,uint8_t toID);
m5171135 2:3f2d4f53ceed 47 void createChangeModeCommand(uint8_t fromID,uint8_t toID,uint8_t,MODE mode);
m5171135 0:2b8b56ac7a82 48
m5171135 2:3f2d4f53ceed 49 //Create Packet: Robot -> Controller/Base
kityann 17:a6fa8cc96d94 50 void createReceiveStatusCommand(uint8_t fromID,uint8_t toID,double latitude,double longitude,double latitudeKalman,double longitudeKalman,
kityann 17:a6fa8cc96d94 51 double covarLati,double covarLongi);
m5171135 2:3f2d4f53ceed 52 //uint8_t* createAckPacket(uint8_t fromID,uint8_t toID);
m5171135 0:2b8b56ac7a82 53
m5171135 2:3f2d4f53ceed 54 //using create packet
m5171135 2:3f2d4f53ceed 55 uint8_t* getPacketData();
m5171135 2:3f2d4f53ceed 56 int getPacketLength();
m5171135 2:3f2d4f53ceed 57
m5171135 2:3f2d4f53ceed 58 //Change Mode:
m5171135 2:3f2d4f53ceed 59 bool changeMode(uint8_t *buf);
m5171135 5:3f51eeb5aedc 60
m5171135 5:3f51eeb5aedc 61 //Check Command Type using xbee buffer;
m5171135 0:2b8b56ac7a82 62 uint8_t checkCommnadType(uint8_t* buf);
m5171135 0:2b8b56ac7a82 63
s1200058 9:4f675487f06b 64 //Change Speed
m5171135 5:3f51eeb5aedc 65 void changeSpeed(uint8_t* buf);
m5171135 5:3f51eeb5aedc 66
m5171135 0:2b8b56ac7a82 67 MODE nowMode;
m5171135 0:2b8b56ac7a82 68 STATUS nowStatus;
m5171135 4:04dadf67ecb6 69 int packetLength;
m5171135 4:04dadf67ecb6 70
m5171135 4:04dadf67ecb6 71
kityann 13:a5bc425540a7 72 void reNewRobotPointKalman(long latitudeH,long latitudeL,long longitudeH,long longitudeL);
kityann 19:13b24b50800e 73 void reNewBasePointKalman(int id, uint8_t *latitude,uint8_t *longitude);
kityann 11:4d71c9cc3b4a 74 void reNewRobotPoint(long latitudeH,long latitudeL,long longitudeH,long longitudeL);
kityann 19:13b24b50800e 75 void reNewBasePoint(int id, uint8_t *latitude,uint8_t *longitude);
kityann 17:a6fa8cc96d94 76
kityann 17:a6fa8cc96d94 77 double get_agzPoint_lati();
kityann 17:a6fa8cc96d94 78 double get_agzPoint_longi();
kityann 17:a6fa8cc96d94 79 double get_agzPointKalman_lati();
kityann 17:a6fa8cc96d94 80 double get_agzPointKalman_longi();
kityann 17:a6fa8cc96d94 81 double get_agzCov_lati();
kityann 17:a6fa8cc96d94 82 double get_agzCov_longi();
kityann 19:13b24b50800e 83 double get_basePoint_lati(int);
kityann 19:13b24b50800e 84 double get_basePoint_longi(int);
kityann 19:13b24b50800e 85 double get_basePointKalman_lati(int);
kityann 19:13b24b50800e 86 double get_basePointKalman_longi(int);
s1200058 25:119fd6c9ae80 87 char get_base_status(int);
kityann 19:13b24b50800e 88
s1200058 20:fec2d6dec897 89 void set_agzAutoGPS();
s1200058 20:fec2d6dec897 90 void set_agzKalmanGPS();
s1200058 20:fec2d6dec897 91
kityann 17:a6fa8cc96d94 92 void set_agzCov(double cov_lati,double cov_longi);
s1200058 25:119fd6c9ae80 93 void set_base_status(int, uint8_t *);
s1200058 20:fec2d6dec897 94
s1200058 20:fec2d6dec897 95 //Auto Type 2 -> GPS
s1200058 20:fec2d6dec897 96 bool gpsAuto();
m5171135 6:f164a716be46 97 //--------PRIVATE-----------//
m5171135 0:2b8b56ac7a82 98 private:
m5171135 5:3f51eeb5aedc 99 //
m5171135 5:3f51eeb5aedc 100 VNH5019 _agzSheild;
m5171135 5:3f51eeb5aedc 101
m5171135 5:3f51eeb5aedc 102 void manualMode();
m5171135 5:3f51eeb5aedc 103 int manualCount;
m5171135 5:3f51eeb5aedc 104
m5171135 5:3f51eeb5aedc 105 //Auto Type 1 -> Random
m5171135 5:3f51eeb5aedc 106 void randomAuto();
s1200058 20:fec2d6dec897 107 int randomCount;
m5171135 7:200ce5c1f486 108
kityann 17:a6fa8cc96d94 109 vector2D agzPoint;//自分自身の位置の情報(double型)
kityann 13:a5bc425540a7 110 vector2D agzPointKalman;
kityann 17:a6fa8cc96d94 111 vector2D agzCov;//カルマンフィルタの共分散
m5171135 7:200ce5c1f486 112 vector2D sub_vector( const vector2D& a, const vector2D& b );
m5171135 7:200ce5c1f486 113 bool checkGpsHit( vertex2D A, vertex2D B, vertex2D C, vertex2D P);
m5171135 7:200ce5c1f486 114
kityann 19:13b24b50800e 115 vector2D basePoint[BASENUMBER];//ベースの位置の情報(double型)
kityann 19:13b24b50800e 116 vector2D basePointKalman[BASENUMBER];
m5171135 7:200ce5c1f486 117
s1200058 25:119fd6c9ae80 118 char base_status[12];
s1200058 25:119fd6c9ae80 119
m5171135 0:2b8b56ac7a82 120 };
m5171135 0:2b8b56ac7a82 121
m5171135 0:2b8b56ac7a82 122 #endif