QC Control software

Dependencies:   mbed

Fork of dgps by Colin Stearns

Committer:
dylanembed123
Date:
Sat Apr 26 16:26:18 2014 +0000
Revision:
54:fc7c8b5d4d41
Parent:
52:b4dddb28dffa
Child:
58:ea73523cf04b
Update mutliple send attempts of path.

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{
dylanembed123 54:fc7c8b5d4d41 65 uint32_t alt;
dylanembed123 52:b4dddb28dffa 66 uint32_t lat;
dylanembed123 52:b4dddb28dffa 67 uint32_t lon;
dylanembed123 52:b4dddb28dffa 68 uint16_t x;
dylanembed123 52:b4dddb28dffa 69 uint16_t y;
dylanembed123 52:b4dddb28dffa 70 uint16_t z;
dylanembed123 52:b4dddb28dffa 71 }MAV_LOCDATA;
dylanembed123 52:b4dddb28dffa 72
dylanembed123 24:e65416d6de22 73 class MavCmd{
dylanembed123 24:e65416d6de22 74 private:
dylanembed123 24:e65416d6de22 75 MAV_REQUEST_LIST req;
dylanembed123 24:e65416d6de22 76 MAV_APM issueArm;
dylanembed123 24:e65416d6de22 77 MAV_APM issueDisArm;
dylanembed123 24:e65416d6de22 78 MAV_COUNT issueCount;
dylanembed123 24:e65416d6de22 79 MAV_MISSION_ITEM issueItem;
dylanembed123 33:ad63e7013801 80 MAV_MISSION_ITEM issueStart;
dylanembed123 24:e65416d6de22 81 MAV_MISSION_ITEM issueTakeOff;
dylanembed123 52:b4dddb28dffa 82 MAV_DATA_STREAM issueStreamReq;
dylanembed123 24:e65416d6de22 83
dylanembed123 24:e65416d6de22 84 // Local variables
dylanembed123 24:e65416d6de22 85 bool startSetup; // Set to true to initiate startup sequence
dylanembed123 24:e65416d6de22 86 int readState; // Read State
dylanembed123 24:e65416d6de22 87 int realLen; // How many more bytes need to be read
dylanembed123 24:e65416d6de22 88 char nextCmd[512+1]; // Temperary storage of next command
dylanembed123 24:e65416d6de22 89 int readIndex; // Current index in next cmd (also the size)
dylanembed123 24:e65416d6de22 90 static MavCmd* mavcmd;
dylanembed123 24:e65416d6de22 91 bool initialized;
dylanembed123 54:fc7c8b5d4d41 92 double cLat,cLon,cAlt;
dylanembed123 54:fc7c8b5d4d41 93 bool hasMoved();
dylanembed123 54:fc7c8b5d4d41 94 bool moveValid;
dylanembed123 24:e65416d6de22 95 public:
dylanembed123 24:e65416d6de22 96 MavCmd():initialized(false){}
dylanembed123 24:e65416d6de22 97 char* getNextCmd();
dylanembed123 24:e65416d6de22 98 void handleNextCmd();
dylanembed123 24:e65416d6de22 99 void setupCmds();
dylanembed123 24:e65416d6de22 100 void setup(){if(!initialized){setupCmds();initialized=true;}}
dylanembed123 25:b7f861fc8ddd 101 void run(){setup();handleNextCmd();}
dylanembed123 24:e65416d6de22 102 static MavCmd& get(){if(mavcmd==NULL){mavcmd=new MavCmd();}return *mavcmd;}
dylanembed123 24:e65416d6de22 103 };