QC Control software

Dependencies:   mbed

Fork of dgps by Colin Stearns

Committer:
krobertson
Date:
Sat Apr 26 23:01:45 2014 +0000
Revision:
60:bf851bafc807
Parent:
58:ea73523cf04b
Child:
61:aa32e17f6801
gps working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dylanembed123 24:e65416d6de22 1 #include "mbed.h"
dylanembed123 24:e65416d6de22 2 #include "mavcontrol.h"
dylanembed123 24:e65416d6de22 3 #include "adapt/usb.h"
dylanembed123 24:e65416d6de22 4 #include <algorithm>
dylanembed123 54:fc7c8b5d4d41 5 #include"handle/dataLocation.h"
dylanembed123 24:e65416d6de22 6 typedef struct MAV_REQUEST_LIST_S{
dylanembed123 24:e65416d6de22 7 char targSys;
dylanembed123 24:e65416d6de22 8 char targComp;
dylanembed123 24:e65416d6de22 9 }MAV_REQUEST_LIST;
dylanembed123 24:e65416d6de22 10
dylanembed123 24:e65416d6de22 11 typedef struct MAV_COUNT_S{
dylanembed123 24:e65416d6de22 12 uint16_t count;
dylanembed123 24:e65416d6de22 13 char targSys;
dylanembed123 24:e65416d6de22 14 char targComp;
dylanembed123 24:e65416d6de22 15 }MAV_COUNT;
dylanembed123 24:e65416d6de22 16
dylanembed123 24:e65416d6de22 17 typedef struct MAV_REQ_S{
dylanembed123 24:e65416d6de22 18 char targSys;
dylanembed123 24:e65416d6de22 19 char targComp;
dylanembed123 24:e65416d6de22 20 char other;
dylanembed123 24:e65416d6de22 21 char count;
dylanembed123 24:e65416d6de22 22 }MAV_REQ;
dylanembed123 24:e65416d6de22 23
dylanembed123 24:e65416d6de22 24 typedef struct MAV_APM_S{
dylanembed123 24:e65416d6de22 25 float parm1;
dylanembed123 24:e65416d6de22 26 float parm2;
dylanembed123 24:e65416d6de22 27 float parm3;
dylanembed123 24:e65416d6de22 28 float parm4;
dylanembed123 24:e65416d6de22 29 float parm5;
dylanembed123 24:e65416d6de22 30 float parm6;
dylanembed123 24:e65416d6de22 31 float parm7;
dylanembed123 24:e65416d6de22 32 uint16_t cmd;
dylanembed123 24:e65416d6de22 33 uint8_t targSys;
dylanembed123 24:e65416d6de22 34 uint8_t targComp;
dylanembed123 24:e65416d6de22 35 uint8_t confirm;
dylanembed123 24:e65416d6de22 36 } MAV_APM;
dylanembed123 24:e65416d6de22 37
dylanembed123 24:e65416d6de22 38 typedef struct MAV_MISSION_ITEM_S{
dylanembed123 24:e65416d6de22 39 float parm1;
dylanembed123 24:e65416d6de22 40 float parm2;
dylanembed123 24:e65416d6de22 41 float parm3;
dylanembed123 24:e65416d6de22 42 float parm4;
dylanembed123 24:e65416d6de22 43 float lat;
dylanembed123 24:e65416d6de22 44 float lon;
dylanembed123 24:e65416d6de22 45 float alt;
dylanembed123 24:e65416d6de22 46 uint16_t seq;
dylanembed123 24:e65416d6de22 47 uint16_t cmd;
dylanembed123 24:e65416d6de22 48 uint8_t targSys;
dylanembed123 24:e65416d6de22 49 uint8_t targComp;
dylanembed123 24:e65416d6de22 50 uint8_t frame;
dylanembed123 24:e65416d6de22 51 uint8_t current; // set to true/1 to make current
dylanembed123 24:e65416d6de22 52 uint8_t autoContinue;// set to true/1 to auto continue
dylanembed123 24:e65416d6de22 53 uint8_t confirm;
dylanembed123 24:e65416d6de22 54 } MAV_MISSION_ITEM;
dylanembed123 24:e65416d6de22 55
dylanembed123 39:1acea80563cf 56 typedef struct MAV_DATA_STREAM_S{
dylanembed123 52:b4dddb28dffa 57 uint16_t rate; // Hz
dylanembed123 39:1acea80563cf 58 uint8_t targSys;
dylanembed123 39:1acea80563cf 59 uint8_t targComp;
dylanembed123 39:1acea80563cf 60 uint8_t streamID;
dylanembed123 39:1acea80563cf 61 uint8_t start; // Set to 1 to start and 0 to stop
dylanembed123 39:1acea80563cf 62 } MAV_DATA_STREAM;
dylanembed123 39:1acea80563cf 63
dylanembed123 52:b4dddb28dffa 64 typedef struct MAV_LOCDATA_S{
krobertson 60:bf851bafc807 65 int32_t timestamp;
krobertson 60:bf851bafc807 66 int32_t lat;
krobertson 60:bf851bafc807 67 int32_t lon;
krobertson 60:bf851bafc807 68 int32_t alt;
dylanembed123 52:b4dddb28dffa 69 uint16_t x;
dylanembed123 52:b4dddb28dffa 70 uint16_t y;
dylanembed123 52:b4dddb28dffa 71 uint16_t z;
dylanembed123 52:b4dddb28dffa 72 }MAV_LOCDATA;
dylanembed123 52:b4dddb28dffa 73
dylanembed123 24:e65416d6de22 74 class MavCmd{
dylanembed123 24:e65416d6de22 75 private:
dylanembed123 24:e65416d6de22 76 MAV_REQUEST_LIST req;
dylanembed123 24:e65416d6de22 77 MAV_APM issueArm;
dylanembed123 24:e65416d6de22 78 MAV_APM issueDisArm;
dylanembed123 24:e65416d6de22 79 MAV_COUNT issueCount;
dylanembed123 24:e65416d6de22 80 MAV_MISSION_ITEM issueItem;
dylanembed123 33:ad63e7013801 81 MAV_MISSION_ITEM issueStart;
dylanembed123 24:e65416d6de22 82 MAV_MISSION_ITEM issueTakeOff;
dylanembed123 52:b4dddb28dffa 83 MAV_DATA_STREAM issueStreamReq;
dylanembed123 24:e65416d6de22 84
dylanembed123 24:e65416d6de22 85 // Local variables
dylanembed123 24:e65416d6de22 86 bool startSetup; // Set to true to initiate startup sequence
dylanembed123 24:e65416d6de22 87 int readState; // Read State
dylanembed123 24:e65416d6de22 88 int realLen; // How many more bytes need to be read
dylanembed123 24:e65416d6de22 89 char nextCmd[512+1]; // Temperary storage of next command
dylanembed123 24:e65416d6de22 90 int readIndex; // Current index in next cmd (also the size)
dylanembed123 24:e65416d6de22 91 static MavCmd* mavcmd;
dylanembed123 24:e65416d6de22 92 bool initialized;
dylanembed123 54:fc7c8b5d4d41 93 double cLat,cLon,cAlt;
dylanembed123 54:fc7c8b5d4d41 94 bool hasMoved();
dylanembed123 54:fc7c8b5d4d41 95 bool moveValid;
dylanembed123 24:e65416d6de22 96 public:
dylanembed123 24:e65416d6de22 97 MavCmd():initialized(false){}
dylanembed123 24:e65416d6de22 98 char* getNextCmd();
dylanembed123 24:e65416d6de22 99 void handleNextCmd();
dylanembed123 24:e65416d6de22 100 void setupCmds();
dylanembed123 24:e65416d6de22 101 void setup(){if(!initialized){setupCmds();initialized=true;}}
krobertson 58:ea73523cf04b 102 void run(){
krobertson 58:ea73523cf04b 103 setup();
krobertson 60:bf851bafc807 104 for(int i=0;i<100;i++){readState=0;handleNextCmd();wait_ms(1);}
krobertson 58:ea73523cf04b 105 }
dylanembed123 24:e65416d6de22 106 static MavCmd& get(){if(mavcmd==NULL){mavcmd=new MavCmd();}return *mavcmd;}
dylanembed123 24:e65416d6de22 107 };