New version of quadcopter software written to OO principles
Dependencies: mbed MODSERIAL filter mbed-rtos ConfigFile PID PPM FreeIMU_external_magnetometer TinyGPS
BaseStation/BaseStation.cpp@2:969dfa4f2436, 2015-04-01 (annotated)
- Committer:
- joe4465
- Date:
- Wed Apr 01 11:19:21 2015 +0000
- Revision:
- 2:969dfa4f2436
- Parent:
- 0:c6a85bb2a827
- Child:
- 3:4823d6750629
Altitude hold with 2 PID's working. Exported to offline compiler
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joe4465 | 2:969dfa4f2436 | 1 | #include "BaseStation.h" |
joe4465 | 2:969dfa4f2436 | 2 | |
joe4465 | 2:969dfa4f2436 | 3 | BaseStation::BaseStation(Status& status, Rc& rc, Sensors& sensors, NavigationController& navigationController, FlightController& flightController, ConfigFileWrapper& configFileWrapper, PinName wirelessPinTx, PinName wirelessPinRx) : _status(status), _rc(rc), _sensors(sensors), _navigationController(navigationController), _flightController(flightController), _configFileWrapper(configFileWrapper) |
joe4465 | 2:969dfa4f2436 | 4 | { |
joe4465 | 2:969dfa4f2436 | 5 | _wireless = new MODSERIAL(wirelessPinTx, wirelessPinRx); |
joe4465 | 2:969dfa4f2436 | 6 | _wireless->baud(57600); |
joe4465 | 2:969dfa4f2436 | 7 | _wirelessSerialRxPos = 0; |
joe4465 | 2:969dfa4f2436 | 8 | |
joe4465 | 2:969dfa4f2436 | 9 | _thread = new Thread(&BaseStation::threadStarter, this, osPriorityNormal); |
joe4465 | 2:969dfa4f2436 | 10 | DEBUG("Base Station initialised\r\n"); |
joe4465 | 2:969dfa4f2436 | 11 | } |
joe4465 | 2:969dfa4f2436 | 12 | |
joe4465 | 2:969dfa4f2436 | 13 | BaseStation::~BaseStation(){} |
joe4465 | 2:969dfa4f2436 | 14 | |
joe4465 | 2:969dfa4f2436 | 15 | void BaseStation::threadStarter(void const *p) |
joe4465 | 2:969dfa4f2436 | 16 | { |
joe4465 | 2:969dfa4f2436 | 17 | BaseStation *instance = (BaseStation*)p; |
joe4465 | 2:969dfa4f2436 | 18 | instance->threadWorker(); |
joe4465 | 2:969dfa4f2436 | 19 | } |
joe4465 | 2:969dfa4f2436 | 20 | |
joe4465 | 2:969dfa4f2436 | 21 | void BaseStation::threadWorker() |
joe4465 | 2:969dfa4f2436 | 22 | { |
joe4465 | 2:969dfa4f2436 | 23 | while(true) |
joe4465 | 2:969dfa4f2436 | 24 | { |
joe4465 | 2:969dfa4f2436 | 25 | //Check comms mode and print correct data back to PC application |
joe4465 | 2:969dfa4f2436 | 26 | Status::BaseStationMode mode = _status.getBaseStationMode(); |
joe4465 | 2:969dfa4f2436 | 27 | |
joe4465 | 2:969dfa4f2436 | 28 | if(mode == Status::MOTOR_POWER) |
joe4465 | 2:969dfa4f2436 | 29 | { |
joe4465 | 2:969dfa4f2436 | 30 | MotorMixer::MotorPower motorPower = _flightController.getMotorPower(); |
joe4465 | 2:969dfa4f2436 | 31 | |
joe4465 | 2:969dfa4f2436 | 32 | _wireless->printf("<M1=%1.2f:M2=%1.2f:M3=%1.2f:M4=%1.2f>", |
joe4465 | 2:969dfa4f2436 | 33 | motorPower.motor1, motorPower.motor2, motorPower.motor3, motorPower.motor4); |
joe4465 | 2:969dfa4f2436 | 34 | } |
joe4465 | 2:969dfa4f2436 | 35 | else if (mode == Status::PID_OUTPUTS) |
joe4465 | 2:969dfa4f2436 | 36 | { |
joe4465 | 2:969dfa4f2436 | 37 | PidWrapper::PidOutput pidOutputs = _flightController.getPidOutputs(); |
joe4465 | 2:969dfa4f2436 | 38 | |
joe4465 | 2:969dfa4f2436 | 39 | _wireless->printf("<YPID=%1.2f:PPID=%1.2f:RPID=%1.2f>", |
joe4465 | 2:969dfa4f2436 | 40 | pidOutputs.yaw, pidOutputs.pitch, pidOutputs.roll); |
joe4465 | 2:969dfa4f2436 | 41 | } |
joe4465 | 2:969dfa4f2436 | 42 | else if (mode == Status::IMU_OUTPUTS) |
joe4465 | 2:969dfa4f2436 | 43 | { |
joe4465 | 2:969dfa4f2436 | 44 | Imu::Rate rate = _sensors.getRate(); |
joe4465 | 2:969dfa4f2436 | 45 | Imu::Angle angle = _sensors.getAngle(); |
joe4465 | 2:969dfa4f2436 | 46 | |
joe4465 | 2:969dfa4f2436 | 47 | _wireless->printf("<SY=%1.2f:SP=%1.2f:SR=%1.2f:RY=%1.2f:RP=%1.2f:RR=%1.2f>", |
joe4465 | 2:969dfa4f2436 | 48 | angle.yaw, angle.pitch, angle.roll, rate.yaw, rate.pitch, rate.roll); |
joe4465 | 2:969dfa4f2436 | 49 | } |
joe4465 | 2:969dfa4f2436 | 50 | else if (mode == Status::STATUS) |
joe4465 | 2:969dfa4f2436 | 51 | { |
joe4465 | 2:969dfa4f2436 | 52 | _wireless->printf("<Batt=%f:Armed=%d:Init=%d:FlightMode=%d:State=%d:NavMode=%d>", |
joe4465 | 2:969dfa4f2436 | 53 | _status.getBatteryLevel(), _status.getArmed(), _status.getInitialised(), _status.getFlightMode(), _status.getState(), _status.getNavigationMode()); |
joe4465 | 2:969dfa4f2436 | 54 | } |
joe4465 | 2:969dfa4f2436 | 55 | else if (mode == Status::RC) |
joe4465 | 2:969dfa4f2436 | 56 | { |
joe4465 | 2:969dfa4f2436 | 57 | Rc::MappedRc mappedRc = _rc.getMappedRc(); |
joe4465 | 2:969dfa4f2436 | 58 | Rc::RawRc rawRc = _rc.getRawRc(); |
joe4465 | 2:969dfa4f2436 | 59 | |
joe4465 | 2:969dfa4f2436 | 60 | _wireless->printf("<MRCY=%1.2f:MRCP=%1.2f:MRCR=%1.2f:MRCT=%1.2f:RRC1=%1.2f:RRC2=%1.2f:RRC3=%1.2f:RRC4=%1.2f:RRC5=%1.2f:RRC6=%1.2f:RRC7=%1.2f:RRC8=%1.2f>", |
joe4465 | 2:969dfa4f2436 | 61 | mappedRc.yaw, mappedRc.pitch, mappedRc.roll, mappedRc.throttle, rawRc.channel0, rawRc.channel1, rawRc.channel2, rawRc.channel3, rawRc.channel4, rawRc.channel5, rawRc.channel6, rawRc.channel7); |
joe4465 | 2:969dfa4f2436 | 62 | } |
joe4465 | 2:969dfa4f2436 | 63 | else if (mode == Status::PID_TUNING) |
joe4465 | 2:969dfa4f2436 | 64 | { |
joe4465 | 2:969dfa4f2436 | 65 | PidWrapper::FlightControllerPidParameters flightControllerPidParameters = _flightController.getPidParameters(); |
joe4465 | 2:969dfa4f2436 | 66 | PidWrapper::NavigationControllerPidParameters navigationControllerPidParameters = _navigationController.getPidParameters(); |
joe4465 | 2:969dfa4f2436 | 67 | _wireless->printf("<RYPIDP=%1.8f:RYPIDI=%1.8f:RYPIDD=%1.8f:RPPIDP=%1.8f:RPPIDI=%1.8f:RPPIDD=%1.8f:RRPIDP=%1.8f:RRPIDI=%1.8f:RRPIDD=%1.8f:SYPIDP=%1.8f:SYPIDI=%1.8f:SYPIDD=%1.8f:SPPIDP=%1.8f:SPPIDI=%1.8f:SPPIDD=%1.8f:SRPIDP=%1.8f:SRPIDI=%1.8f:SRPIDD=%1.8f:ARPIDP=%1.8f:ARPIDI=%1.8f:ARPIDD=%1.8f:ASPIDP=%1.8f:ASPIDI=%1.8f:ASPIDD=%1.8f>", |
joe4465 | 2:969dfa4f2436 | 68 | flightControllerPidParameters.yawRate.p, flightControllerPidParameters.yawRate.i, flightControllerPidParameters.yawRate.d, |
joe4465 | 2:969dfa4f2436 | 69 | flightControllerPidParameters.pitchRate.p, flightControllerPidParameters.pitchRate.i, flightControllerPidParameters.pitchRate.d, |
joe4465 | 2:969dfa4f2436 | 70 | flightControllerPidParameters.rollRate.p, flightControllerPidParameters.rollRate.i, flightControllerPidParameters.rollRate.d, |
joe4465 | 2:969dfa4f2436 | 71 | flightControllerPidParameters.yawStab.p, flightControllerPidParameters.yawStab.i, flightControllerPidParameters.yawStab.d, |
joe4465 | 2:969dfa4f2436 | 72 | flightControllerPidParameters.pitchStab.p, flightControllerPidParameters.pitchStab.i, flightControllerPidParameters.pitchStab.d, |
joe4465 | 2:969dfa4f2436 | 73 | flightControllerPidParameters.rollStab.p, flightControllerPidParameters.rollStab.i, flightControllerPidParameters.rollStab.d, |
joe4465 | 2:969dfa4f2436 | 74 | navigationControllerPidParameters.altitudeRate.p, navigationControllerPidParameters.altitudeRate.i, navigationControllerPidParameters.altitudeRate.d, |
joe4465 | 2:969dfa4f2436 | 75 | navigationControllerPidParameters.altitudeStab.p, navigationControllerPidParameters.altitudeStab.i, navigationControllerPidParameters.altitudeStab.d); |
joe4465 | 2:969dfa4f2436 | 76 | } |
joe4465 | 2:969dfa4f2436 | 77 | else if (mode == Status::GPS) |
joe4465 | 2:969dfa4f2436 | 78 | { |
joe4465 | 2:969dfa4f2436 | 79 | Gps::Value gpsValues = _sensors.getGpsValues(); |
joe4465 | 2:969dfa4f2436 | 80 | |
joe4465 | 2:969dfa4f2436 | 81 | _wireless->printf("<GLat=%1.6f:GLon=%1.6f:GAlt=%1.2f:GInit=%d>", |
joe4465 | 2:969dfa4f2436 | 82 | gpsValues.latitude, gpsValues.longitude, gpsValues.altitude, gpsValues.fix); |
joe4465 | 2:969dfa4f2436 | 83 | }/* |
joe4465 | 2:969dfa4f2436 | 84 | else if (mode == Status::ZERO) |
joe4465 | 2:969dfa4f2436 | 85 | { |
joe4465 | 2:969dfa4f2436 | 86 | _wirelessSerial.printf("<ZY=%1.6f:ZP=%1.6f:ZR=%1.6f>", |
joe4465 | 2:969dfa4f2436 | 87 | _zeroValues[0], _zeroValues[1], _zeroValues[2]); |
joe4465 | 2:969dfa4f2436 | 88 | break; |
joe4465 | 2:969dfa4f2436 | 89 | |
joe4465 | 2:969dfa4f2436 | 90 | }*/ |
joe4465 | 2:969dfa4f2436 | 91 | else if (mode == Status::RATE_TUNING) |
joe4465 | 2:969dfa4f2436 | 92 | { |
joe4465 | 2:969dfa4f2436 | 93 | if(_status.getFlightMode() == Status::RATE) |
joe4465 | 2:969dfa4f2436 | 94 | { |
joe4465 | 2:969dfa4f2436 | 95 | PidWrapper::RatePidState ratePidState = _flightController.getRatePidState(); |
joe4465 | 2:969dfa4f2436 | 96 | |
joe4465 | 2:969dfa4f2436 | 97 | //Yaw set point, Yaw actual, Yaw PID output |
joe4465 | 2:969dfa4f2436 | 98 | //Pitch set point, Pitch actual, Pitch PID output |
joe4465 | 2:969dfa4f2436 | 99 | //Roll set point, Roll actual, Roll PID output |
joe4465 | 2:969dfa4f2436 | 100 | _wireless->printf("<RYPIDS=%1.2f:RYPIDP=%1.2f:RYPIDO=%1.2f:RPPIDS=%1.2f:RPPIDP=%1.2f:RPPIDO=%1.2f:RRPIDS=%1.2f:RRPIDP=%1.2f:RRPIDO=%1.2f>", |
joe4465 | 2:969dfa4f2436 | 101 | ratePidState.yawRate.setPoint, ratePidState.yawRate.processValue, ratePidState.yawRate.output, ratePidState.pitchRate.setPoint, ratePidState.pitchRate.processValue, ratePidState.pitchRate.output, ratePidState.rollRate.setPoint, ratePidState.rollRate.processValue, ratePidState.rollRate.output); |
joe4465 | 2:969dfa4f2436 | 102 | } |
joe4465 | 2:969dfa4f2436 | 103 | else if (_status.getFlightMode() == Status::STAB) |
joe4465 | 2:969dfa4f2436 | 104 | { |
joe4465 | 2:969dfa4f2436 | 105 | PidWrapper::StabPidState stabPidState = _flightController.getStabPidState(); |
joe4465 | 2:969dfa4f2436 | 106 | |
joe4465 | 2:969dfa4f2436 | 107 | //Yaw set point, Yaw actual, Yaw PID output |
joe4465 | 2:969dfa4f2436 | 108 | //Pitch set point, Pitch actual, Pitch PID output |
joe4465 | 2:969dfa4f2436 | 109 | //Roll set point, Roll actual, Roll PID output |
joe4465 | 2:969dfa4f2436 | 110 | _wireless->printf("<RYPIDS=%1.2f:RYPIDP=%1.2f:RYPIDO=%1.2f:RPPIDS=%1.2f:RPPIDP=%1.2f:RPPIDO=%1.2f:RRPIDS=%1.2f:RRPIDP=%1.2f:RRPIDO=%1.2f>", |
joe4465 | 2:969dfa4f2436 | 111 | stabPidState.yawRate.setPoint, stabPidState.yawRate.processValue, stabPidState.yawRate.output, stabPidState.pitchRate.setPoint, stabPidState.pitchRate.processValue, stabPidState.pitchRate.output, stabPidState.rollRate.setPoint, stabPidState.rollRate.processValue, stabPidState.rollRate.output); |
joe4465 | 2:969dfa4f2436 | 112 | } |
joe4465 | 2:969dfa4f2436 | 113 | } |
joe4465 | 2:969dfa4f2436 | 114 | else if (mode == Status::STAB_TUNING) |
joe4465 | 2:969dfa4f2436 | 115 | { |
joe4465 | 2:969dfa4f2436 | 116 | if(_status.getFlightMode() == Status::RATE) |
joe4465 | 2:969dfa4f2436 | 117 | { |
joe4465 | 2:969dfa4f2436 | 118 | //Yaw set point, Yaw actual, Yaw PID output |
joe4465 | 2:969dfa4f2436 | 119 | //Pitch set point, Pitch actual, Pitch PID output |
joe4465 | 2:969dfa4f2436 | 120 | //Roll set point, Roll actual, Roll PID output |
joe4465 | 2:969dfa4f2436 | 121 | _wireless->printf("<SYPIDS=0:SYPIDP=0:SYPIDO=0:SPPIDS=0:SPPIDP=0:SPPIDO=0:SRPIDS=0:SRPIDP=0:SRPIDO=0>"); |
joe4465 | 2:969dfa4f2436 | 122 | } |
joe4465 | 2:969dfa4f2436 | 123 | else if (_status.getFlightMode() == Status::STAB) |
joe4465 | 2:969dfa4f2436 | 124 | { |
joe4465 | 2:969dfa4f2436 | 125 | PidWrapper::StabPidState stabPidState = _flightController.getStabPidState(); |
joe4465 | 2:969dfa4f2436 | 126 | |
joe4465 | 2:969dfa4f2436 | 127 | //Yaw set point, Yaw actual, Yaw PID output |
joe4465 | 2:969dfa4f2436 | 128 | //Pitch set point, Pitch actual, Pitch PID output |
joe4465 | 2:969dfa4f2436 | 129 | //Roll set point, Roll actual, Roll PID output |
joe4465 | 2:969dfa4f2436 | 130 | _wireless->printf("<SYPIDS=%1.2f:SYPIDP=%1.2f:SYPIDO=%1.2f:SPPIDS=%1.2f:SPPIDP=%1.2f:SPPIDO=%1.2f:SRPIDS=%1.2f:SRPIDP=%1.2f:SRPIDO=%1.2f>", |
joe4465 | 2:969dfa4f2436 | 131 | stabPidState.yawStab.setPoint, stabPidState.yawStab.processValue, stabPidState.yawStab.output, stabPidState.pitchStab.setPoint, stabPidState.pitchStab.processValue, stabPidState.pitchStab.output, stabPidState.rollStab.setPoint, stabPidState.rollStab.processValue, stabPidState.rollStab.output); |
joe4465 | 2:969dfa4f2436 | 132 | } |
joe4465 | 2:969dfa4f2436 | 133 | } |
joe4465 | 2:969dfa4f2436 | 134 | else if (mode == Status::ALTITUDE) |
joe4465 | 2:969dfa4f2436 | 135 | { |
joe4465 | 2:969dfa4f2436 | 136 | Sensors::Altitude altitude = _sensors.getAltitude(); |
joe4465 | 2:969dfa4f2436 | 137 | _wireless->printf("<GAlt=%1.2f:CAlt=%1.2f:BAlt=%1.2f:LAlt=%1.2f>", |
joe4465 | 2:969dfa4f2436 | 138 | altitude.gps, altitude.computed, altitude.barometer, altitude.lidar); |
joe4465 | 2:969dfa4f2436 | 139 | } |
joe4465 | 2:969dfa4f2436 | 140 | else if (mode == Status::VELOCITY) |
joe4465 | 2:969dfa4f2436 | 141 | { |
joe4465 | 2:969dfa4f2436 | 142 | //Sensors::Velocity velocity = _sensors.getVelocity(); |
joe4465 | 2:969dfa4f2436 | 143 | //_wireless->printf("<AVelX=%1.2f:AVelY=%1.2f:AVelZ=%1.2f:LVel=%1.2f:CVelX=%1.2f:CVelY=%1.2f:CVelZ=%1.2f>", |
joe4465 | 2:969dfa4f2436 | 144 | //velocity.accelX, velocity.accelY, velocity.accelZ, velocity.lidar, velocity.computedX, velocity.computedY, velocity.computedZ); |
joe4465 | 2:969dfa4f2436 | 145 | } |
joe4465 | 2:969dfa4f2436 | 146 | else if (mode == Status::ALTITUDE_STATUS) |
joe4465 | 2:969dfa4f2436 | 147 | { |
joe4465 | 2:969dfa4f2436 | 148 | NavigationController::SetPoint setPoints = _navigationController.getSetPoint(); |
joe4465 | 2:969dfa4f2436 | 149 | Sensors::Altitude altitude = _sensors.getAltitude(); |
joe4465 | 2:969dfa4f2436 | 150 | _wireless->printf("<ACR=%1.2f:AT=%1.2f:ATHR=%1.2f:LAlt=%1.2f>", |
joe4465 | 2:969dfa4f2436 | 151 | setPoints.climbRate, setPoints.targetAltitude, (setPoints.throttle * 100), altitude.computed); |
joe4465 | 2:969dfa4f2436 | 152 | } |
joe4465 | 2:969dfa4f2436 | 153 | |
joe4465 | 2:969dfa4f2436 | 154 | //Check for wireless serial command |
joe4465 | 2:969dfa4f2436 | 155 | while (_wireless->readable() > 0) |
joe4465 | 2:969dfa4f2436 | 156 | { |
joe4465 | 2:969dfa4f2436 | 157 | int c = _wireless->getc(); |
joe4465 | 2:969dfa4f2436 | 158 | |
joe4465 | 2:969dfa4f2436 | 159 | switch (c) |
joe4465 | 2:969dfa4f2436 | 160 | { |
joe4465 | 2:969dfa4f2436 | 161 | case 60: // |
joe4465 | 2:969dfa4f2436 | 162 | _wirelessSerialRxPos = 0; |
joe4465 | 2:969dfa4f2436 | 163 | break; |
joe4465 | 2:969dfa4f2436 | 164 | |
joe4465 | 2:969dfa4f2436 | 165 | case 10: // LF |
joe4465 | 2:969dfa4f2436 | 166 | case 13: // CR |
joe4465 | 2:969dfa4f2436 | 167 | case 62: // > |
joe4465 | 2:969dfa4f2436 | 168 | checkCommand(); |
joe4465 | 2:969dfa4f2436 | 169 | break; |
joe4465 | 2:969dfa4f2436 | 170 | |
joe4465 | 2:969dfa4f2436 | 171 | default: |
joe4465 | 2:969dfa4f2436 | 172 | _wirelessSerialBuffer[_wirelessSerialRxPos++] = c; |
joe4465 | 2:969dfa4f2436 | 173 | if (_wirelessSerialRxPos > 200) |
joe4465 | 2:969dfa4f2436 | 174 | { |
joe4465 | 2:969dfa4f2436 | 175 | _wirelessSerialRxPos = 0; |
joe4465 | 2:969dfa4f2436 | 176 | } |
joe4465 | 2:969dfa4f2436 | 177 | break; |
joe4465 | 2:969dfa4f2436 | 178 | } |
joe4465 | 2:969dfa4f2436 | 179 | } |
joe4465 | 2:969dfa4f2436 | 180 | |
joe4465 | 2:969dfa4f2436 | 181 | Thread::wait(200); |
joe4465 | 2:969dfa4f2436 | 182 | } |
joe4465 | 2:969dfa4f2436 | 183 | } |
joe4465 | 2:969dfa4f2436 | 184 | |
joe4465 | 2:969dfa4f2436 | 185 | void BaseStation::checkCommand() |
joe4465 | 2:969dfa4f2436 | 186 | { |
joe4465 | 2:969dfa4f2436 | 187 | int length = _wirelessSerialRxPos; |
joe4465 | 2:969dfa4f2436 | 188 | _wirelessSerialBuffer[_wirelessSerialRxPos] = 0; |
joe4465 | 2:969dfa4f2436 | 189 | _wirelessSerialRxPos = 0; |
joe4465 | 2:969dfa4f2436 | 190 | |
joe4465 | 2:969dfa4f2436 | 191 | if (length < 1) |
joe4465 | 2:969dfa4f2436 | 192 | { |
joe4465 | 2:969dfa4f2436 | 193 | return; |
joe4465 | 2:969dfa4f2436 | 194 | } |
joe4465 | 2:969dfa4f2436 | 195 | |
joe4465 | 2:969dfa4f2436 | 196 | char command = _wirelessSerialBuffer[0]; |
joe4465 | 2:969dfa4f2436 | 197 | double value = 0; |
joe4465 | 2:969dfa4f2436 | 198 | if(length > 1) |
joe4465 | 2:969dfa4f2436 | 199 | { |
joe4465 | 2:969dfa4f2436 | 200 | value = atof((char*)&_wirelessSerialBuffer[2]); |
joe4465 | 2:969dfa4f2436 | 201 | } |
joe4465 | 2:969dfa4f2436 | 202 | |
joe4465 | 2:969dfa4f2436 | 203 | PidWrapper::FlightControllerPidParameters flightControllerPidParameters = _flightController.getPidParameters(); |
joe4465 | 2:969dfa4f2436 | 204 | PidWrapper::NavigationControllerPidParameters navigationControllerPidParameters = _navigationController.getPidParameters(); |
joe4465 | 2:969dfa4f2436 | 205 | |
joe4465 | 2:969dfa4f2436 | 206 | switch (command) |
joe4465 | 2:969dfa4f2436 | 207 | { |
joe4465 | 2:969dfa4f2436 | 208 | case 'a': |
joe4465 | 2:969dfa4f2436 | 209 | navigationControllerPidParameters.altitudeRate.p = value; |
joe4465 | 2:969dfa4f2436 | 210 | _navigationController.setAltitudeRatePidParameters(navigationControllerPidParameters.altitudeRate); |
joe4465 | 2:969dfa4f2436 | 211 | break; |
joe4465 | 2:969dfa4f2436 | 212 | |
joe4465 | 2:969dfa4f2436 | 213 | case 'b': |
joe4465 | 2:969dfa4f2436 | 214 | navigationControllerPidParameters.altitudeRate.i = value; |
joe4465 | 2:969dfa4f2436 | 215 | _navigationController.setAltitudeRatePidParameters(navigationControllerPidParameters.altitudeRate); |
joe4465 | 2:969dfa4f2436 | 216 | break; |
joe4465 | 2:969dfa4f2436 | 217 | |
joe4465 | 2:969dfa4f2436 | 218 | case 'c': |
joe4465 | 2:969dfa4f2436 | 219 | navigationControllerPidParameters.altitudeRate.d = value; |
joe4465 | 2:969dfa4f2436 | 220 | _navigationController.setAltitudeRatePidParameters(navigationControllerPidParameters.altitudeRate); |
joe4465 | 2:969dfa4f2436 | 221 | break; |
joe4465 | 2:969dfa4f2436 | 222 | |
joe4465 | 2:969dfa4f2436 | 223 | case 'd': |
joe4465 | 2:969dfa4f2436 | 224 | navigationControllerPidParameters.altitudeStab.p = value; |
joe4465 | 2:969dfa4f2436 | 225 | _navigationController.setAltitudeStabPidParameters(navigationControllerPidParameters.altitudeStab); |
joe4465 | 2:969dfa4f2436 | 226 | break; |
joe4465 | 2:969dfa4f2436 | 227 | |
joe4465 | 2:969dfa4f2436 | 228 | case 'e': |
joe4465 | 2:969dfa4f2436 | 229 | navigationControllerPidParameters.altitudeStab.i = value; |
joe4465 | 2:969dfa4f2436 | 230 | _navigationController.setAltitudeStabPidParameters(navigationControllerPidParameters.altitudeStab); |
joe4465 | 2:969dfa4f2436 | 231 | break; |
joe4465 | 2:969dfa4f2436 | 232 | |
joe4465 | 2:969dfa4f2436 | 233 | case 'f': |
joe4465 | 2:969dfa4f2436 | 234 | navigationControllerPidParameters.altitudeStab.d = value; |
joe4465 | 2:969dfa4f2436 | 235 | _navigationController.setAltitudeStabPidParameters(navigationControllerPidParameters.altitudeStab); |
joe4465 | 2:969dfa4f2436 | 236 | break; |
joe4465 | 2:969dfa4f2436 | 237 | |
joe4465 | 2:969dfa4f2436 | 238 | case 'g': |
joe4465 | 2:969dfa4f2436 | 239 | _sensors.zeroAccel(); |
joe4465 | 2:969dfa4f2436 | 240 | break; |
joe4465 | 2:969dfa4f2436 | 241 | |
joe4465 | 2:969dfa4f2436 | 242 | //Set PID values |
joe4465 | 2:969dfa4f2436 | 243 | case 'h': |
joe4465 | 2:969dfa4f2436 | 244 | flightControllerPidParameters.yawRate.p = value; |
joe4465 | 2:969dfa4f2436 | 245 | _flightController.setYawRatePidParameters(flightControllerPidParameters.yawRate); |
joe4465 | 2:969dfa4f2436 | 246 | break; |
joe4465 | 2:969dfa4f2436 | 247 | |
joe4465 | 2:969dfa4f2436 | 248 | case 'i': |
joe4465 | 2:969dfa4f2436 | 249 | flightControllerPidParameters.yawRate.i = value; |
joe4465 | 2:969dfa4f2436 | 250 | _flightController.setYawRatePidParameters(flightControllerPidParameters.yawRate); |
joe4465 | 2:969dfa4f2436 | 251 | break; |
joe4465 | 2:969dfa4f2436 | 252 | |
joe4465 | 2:969dfa4f2436 | 253 | case 'j': |
joe4465 | 2:969dfa4f2436 | 254 | flightControllerPidParameters.yawRate.d = value; |
joe4465 | 2:969dfa4f2436 | 255 | _flightController.setYawRatePidParameters(flightControllerPidParameters.yawRate); |
joe4465 | 2:969dfa4f2436 | 256 | break; |
joe4465 | 2:969dfa4f2436 | 257 | |
joe4465 | 2:969dfa4f2436 | 258 | case 'k': |
joe4465 | 2:969dfa4f2436 | 259 | flightControllerPidParameters.pitchRate.p = value; |
joe4465 | 2:969dfa4f2436 | 260 | _flightController.setPitchRatePidParameters(flightControllerPidParameters.pitchRate); |
joe4465 | 2:969dfa4f2436 | 261 | break; |
joe4465 | 2:969dfa4f2436 | 262 | |
joe4465 | 2:969dfa4f2436 | 263 | case 'l': |
joe4465 | 2:969dfa4f2436 | 264 | flightControllerPidParameters.pitchRate.i = value; |
joe4465 | 2:969dfa4f2436 | 265 | _flightController.setPitchRatePidParameters(flightControllerPidParameters.pitchRate); |
joe4465 | 2:969dfa4f2436 | 266 | break; |
joe4465 | 2:969dfa4f2436 | 267 | |
joe4465 | 2:969dfa4f2436 | 268 | case 'm': |
joe4465 | 2:969dfa4f2436 | 269 | flightControllerPidParameters.pitchRate.d = value; |
joe4465 | 2:969dfa4f2436 | 270 | _flightController.setPitchRatePidParameters(flightControllerPidParameters.pitchRate); |
joe4465 | 2:969dfa4f2436 | 271 | break; |
joe4465 | 2:969dfa4f2436 | 272 | |
joe4465 | 2:969dfa4f2436 | 273 | case 'n': |
joe4465 | 2:969dfa4f2436 | 274 | flightControllerPidParameters.rollRate.p = value; |
joe4465 | 2:969dfa4f2436 | 275 | _flightController.setRollRatePidParameters(flightControllerPidParameters.rollRate); |
joe4465 | 2:969dfa4f2436 | 276 | break; |
joe4465 | 2:969dfa4f2436 | 277 | |
joe4465 | 2:969dfa4f2436 | 278 | case 'o': |
joe4465 | 2:969dfa4f2436 | 279 | flightControllerPidParameters.rollRate.i = value; |
joe4465 | 2:969dfa4f2436 | 280 | _flightController.setRollRatePidParameters(flightControllerPidParameters.rollRate); |
joe4465 | 2:969dfa4f2436 | 281 | break; |
joe4465 | 2:969dfa4f2436 | 282 | |
joe4465 | 2:969dfa4f2436 | 283 | case 'p': |
joe4465 | 2:969dfa4f2436 | 284 | flightControllerPidParameters.rollRate.d = value; |
joe4465 | 2:969dfa4f2436 | 285 | _flightController.setRollRatePidParameters(flightControllerPidParameters.rollRate); |
joe4465 | 2:969dfa4f2436 | 286 | break; |
joe4465 | 2:969dfa4f2436 | 287 | |
joe4465 | 2:969dfa4f2436 | 288 | case 'q': |
joe4465 | 2:969dfa4f2436 | 289 | flightControllerPidParameters.yawStab.p = value; |
joe4465 | 2:969dfa4f2436 | 290 | _flightController.setYawStabPidParameters(flightControllerPidParameters.yawStab); |
joe4465 | 2:969dfa4f2436 | 291 | break; |
joe4465 | 2:969dfa4f2436 | 292 | |
joe4465 | 2:969dfa4f2436 | 293 | case 'r': |
joe4465 | 2:969dfa4f2436 | 294 | flightControllerPidParameters.yawStab.i = value; |
joe4465 | 2:969dfa4f2436 | 295 | _flightController.setYawStabPidParameters(flightControllerPidParameters.yawStab); |
joe4465 | 2:969dfa4f2436 | 296 | break; |
joe4465 | 2:969dfa4f2436 | 297 | |
joe4465 | 2:969dfa4f2436 | 298 | case 's': |
joe4465 | 2:969dfa4f2436 | 299 | flightControllerPidParameters.yawStab.d = value; |
joe4465 | 2:969dfa4f2436 | 300 | _flightController.setYawStabPidParameters(flightControllerPidParameters.yawStab); |
joe4465 | 2:969dfa4f2436 | 301 | break; |
joe4465 | 2:969dfa4f2436 | 302 | |
joe4465 | 2:969dfa4f2436 | 303 | case 't': |
joe4465 | 2:969dfa4f2436 | 304 | flightControllerPidParameters.pitchStab.p = value; |
joe4465 | 2:969dfa4f2436 | 305 | _flightController.setPitchStabPidParameters(flightControllerPidParameters.pitchStab); |
joe4465 | 2:969dfa4f2436 | 306 | break; |
joe4465 | 2:969dfa4f2436 | 307 | |
joe4465 | 2:969dfa4f2436 | 308 | case 'u': |
joe4465 | 2:969dfa4f2436 | 309 | flightControllerPidParameters.pitchStab.i = value; |
joe4465 | 2:969dfa4f2436 | 310 | _flightController.setPitchStabPidParameters(flightControllerPidParameters.pitchStab); |
joe4465 | 2:969dfa4f2436 | 311 | break; |
joe4465 | 2:969dfa4f2436 | 312 | |
joe4465 | 2:969dfa4f2436 | 313 | case 'v': |
joe4465 | 2:969dfa4f2436 | 314 | flightControllerPidParameters.pitchStab.d = value; |
joe4465 | 2:969dfa4f2436 | 315 | _flightController.setPitchStabPidParameters(flightControllerPidParameters.pitchStab); |
joe4465 | 2:969dfa4f2436 | 316 | break; |
joe4465 | 2:969dfa4f2436 | 317 | |
joe4465 | 2:969dfa4f2436 | 318 | case 'w': |
joe4465 | 2:969dfa4f2436 | 319 | flightControllerPidParameters.rollStab.p = value; |
joe4465 | 2:969dfa4f2436 | 320 | _flightController.setRollStabPidParameters(flightControllerPidParameters.rollStab); |
joe4465 | 2:969dfa4f2436 | 321 | break; |
joe4465 | 2:969dfa4f2436 | 322 | |
joe4465 | 2:969dfa4f2436 | 323 | case 'x': |
joe4465 | 2:969dfa4f2436 | 324 | flightControllerPidParameters.rollStab.i = value; |
joe4465 | 2:969dfa4f2436 | 325 | _flightController.setRollStabPidParameters(flightControllerPidParameters.rollStab); |
joe4465 | 2:969dfa4f2436 | 326 | break; |
joe4465 | 2:969dfa4f2436 | 327 | |
joe4465 | 2:969dfa4f2436 | 328 | case 'y': |
joe4465 | 2:969dfa4f2436 | 329 | flightControllerPidParameters.rollStab.d = value; |
joe4465 | 2:969dfa4f2436 | 330 | _flightController.setRollStabPidParameters(flightControllerPidParameters.rollStab); |
joe4465 | 2:969dfa4f2436 | 331 | break; |
joe4465 | 2:969dfa4f2436 | 332 | |
joe4465 | 2:969dfa4f2436 | 333 | case 'z': |
joe4465 | 2:969dfa4f2436 | 334 | _status.setBaseStationMode(static_cast<Status::BaseStationMode>(value)); |
joe4465 | 2:969dfa4f2436 | 335 | break; |
joe4465 | 2:969dfa4f2436 | 336 | |
joe4465 | 2:969dfa4f2436 | 337 | default: |
joe4465 | 2:969dfa4f2436 | 338 | break; |
joe4465 | 2:969dfa4f2436 | 339 | } |
joe4465 | 2:969dfa4f2436 | 340 | |
joe4465 | 2:969dfa4f2436 | 341 | return; |
joe4465 | 2:969dfa4f2436 | 342 | } |