Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MODSERIAL filter mbed-rtos ConfigFile PID PPM FreeIMU_external_magnetometer TinyGPS
FlightController/RateController/RateController.cpp
- Committer:
- joe4465
- Date:
- 2015-03-04
- Revision:
- 0:c6a85bb2a827
- Child:
- 2:969dfa4f2436
File content as of revision 0:c6a85bb2a827:
#include "RateController.h"
RateController::RateController(){}
RateController::~RateController(){}
bool RateController::initialise(Sensors& sensors, NavigationController& navigationController)
{
_sensors = sensors;
_navigationController = navigationController;
ConfigFileWrapper configFileWrapper = new ConfigFileWrapper();
configFileWrapper.initialise();
_yawRatePidController.initialise(configFileWrapper.getYawRateParameters, IMU_YAW_RATE_MIN, IMU_YAW_RATE_MAX, RATE_PID_CONTROLLER_OUTPUT_MIN, RATE_PID_CONTROLLER_OUTPUT_MAX);
_pitchRatePidController.initialise(configFileWrapper.getPitchRateParameters, IMU_PITCH_RATE_MIN, IMU_PITCH_RATE_MAX, RATE_PID_CONTROLLER_OUTPUT_MIN, RATE_PID_CONTROLLER_OUTPUT_MAX);
_rollRatePidController.initialise(configFileWrapper.getRollRateParameters, IMU_ROLL_RATE_MIN, IMU_ROLL_RATE_MAX, RATE_PID_CONTROLLER_OUTPUT_MIN, RATE_PID_CONTROLLER_OUTPUT_MAX);
DEBUG("Rate controller initialised");
return true;
}
PidWrapper::PidOutputs RateController::compute()
{
//Update rate PID process value with gyro rate
_yawRatePIDController->setProcessValue(_gyroRate[0]);
_pitchRatePIDController->setProcessValue(_gyroRate[1]);
_rollRatePIDController->setProcessValue(_gyroRate[2]);
//Update rate PID set point with desired rate from RC
_yawRatePIDController->setSetPoint(_rcMappedCommands[0]);
_pitchRatePIDController->setSetPoint(_rcMappedCommands[1]);
_rollRatePIDController->setSetPoint(_rcMappedCommands[2]);
//Compute rate PID outputs
_ratePIDControllerOutputs[0] = _yawRatePIDController->compute();
_ratePIDControllerOutputs[1] = _pitchRatePIDController->compute();
_ratePIDControllerOutputs[2] = _rollRatePIDController->compute();
}