mirror of https://github.com/ArduPilot/ardupilot
uncrustify libraries/AP_ADC/AP_ADC_HIL.cpp
This commit is contained in:
parent
0fcf421752
commit
bd0b3ee6b2
|
@ -1,46 +1,46 @@
|
||||||
#include "AP_ADC_HIL.h"
|
#include "AP_ADC_HIL.h"
|
||||||
#if defined(ARDUINO) && ARDUINO >= 100
|
#if defined(ARDUINO) && ARDUINO >= 100
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#else
|
#else
|
||||||
#include "WProgram.h"
|
#include "WProgram.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
AP_ADC_HIL.cpp
|
* AP_ADC_HIL.cpp
|
||||||
Author: James Goppert
|
* Author: James Goppert
|
||||||
|
*
|
||||||
License:
|
* License:
|
||||||
This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const uint8_t AP_ADC_HIL::sensors[6] = {1,2,0,4,5,6};
|
const uint8_t AP_ADC_HIL::sensors[6] = {1,2,0,4,5,6};
|
||||||
const int8_t AP_ADC_HIL::sensorSign[6] = { 1, -1, -1,-1, 1, 1};
|
const int8_t AP_ADC_HIL::sensorSign[6] = { 1, -1, -1,-1, 1, 1};
|
||||||
const float AP_ADC_HIL::gyroBias[3] = {1665,1665,1665};
|
const float AP_ADC_HIL::gyroBias[3] = {1665,1665,1665};
|
||||||
const float AP_ADC_HIL::accelBias[3] = {2025,2025,2025};
|
const float AP_ADC_HIL::accelBias[3] = {2025,2025,2025};
|
||||||
// gyroScale = 1/[GyroGain*pi/180] GyroGains (0.4,0.41,0.41)
|
// gyroScale = 1/[GyroGain*pi/180] GyroGains (0.4,0.41,0.41)
|
||||||
const float AP_ADC_HIL::gyroScale[3] = {143.239, 139.746, 139.746};
|
const float AP_ADC_HIL::gyroScale[3] = {143.239, 139.746, 139.746};
|
||||||
const float AP_ADC_HIL::accelScale[3] = {418,418,418}; // adcPerG
|
const float AP_ADC_HIL::accelScale[3] = {418,418,418}; // adcPerG
|
||||||
|
|
||||||
AP_ADC_HIL::AP_ADC_HIL()
|
AP_ADC_HIL::AP_ADC_HIL()
|
||||||
{
|
{
|
||||||
// gyros set to zero for calibration
|
// gyros set to zero for calibration
|
||||||
setGyro(0,0);
|
setGyro(0,0);
|
||||||
setGyro(1,0);
|
setGyro(1,0);
|
||||||
setGyro(2,0);
|
setGyro(2,0);
|
||||||
|
|
||||||
// accels set to zero for calibration
|
// accels set to zero for calibration
|
||||||
setAccel(0,0);
|
setAccel(0,0);
|
||||||
setAccel(1,0);
|
setAccel(1,0);
|
||||||
setAccel(2,0);
|
setAccel(2,0);
|
||||||
|
|
||||||
// set diff press and temp to zero
|
// set diff press and temp to zero
|
||||||
setGyroTemp(0);
|
setGyroTemp(0);
|
||||||
setPressure(0);
|
setPressure(0);
|
||||||
|
|
||||||
last_hil_time = millis();
|
last_hil_time = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AP_ADC_HIL::Init( AP_PeriodicProcess * scheduler )
|
void AP_ADC_HIL::Init( AP_PeriodicProcess * scheduler )
|
||||||
|
@ -50,41 +50,41 @@ void AP_ADC_HIL::Init( AP_PeriodicProcess * scheduler )
|
||||||
// Read one channel value
|
// Read one channel value
|
||||||
float AP_ADC_HIL::Ch(unsigned char ch_num)
|
float AP_ADC_HIL::Ch(unsigned char ch_num)
|
||||||
{
|
{
|
||||||
return adcValue[ch_num];
|
return adcValue[ch_num];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read 6 channel values
|
// Read 6 channel values
|
||||||
uint32_t AP_ADC_HIL::Ch6(const uint8_t *channel_numbers, float *result)
|
uint32_t AP_ADC_HIL::Ch6(const uint8_t *channel_numbers, float *result)
|
||||||
{
|
{
|
||||||
for (uint8_t i=0; i<6; i++) {
|
for (uint8_t i=0; i<6; i++) {
|
||||||
result[i] = Ch(channel_numbers[i]);
|
result[i] = Ch(channel_numbers[i]);
|
||||||
}
|
}
|
||||||
return ((millis() - last_hil_time)*2)/5;
|
return ((millis() - last_hil_time)*2)/5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set one channel value
|
// Set one channel value
|
||||||
void AP_ADC_HIL::setHIL(int16_t p, int16_t q, int16_t r, int16_t gyroTemp,
|
void AP_ADC_HIL::setHIL(int16_t p, int16_t q, int16_t r, int16_t gyroTemp,
|
||||||
int16_t aX, int16_t aY, int16_t aZ, int16_t diffPress)
|
int16_t aX, int16_t aY, int16_t aZ, int16_t diffPress)
|
||||||
{
|
{
|
||||||
// gyros
|
// gyros
|
||||||
setGyro(0,p);
|
setGyro(0,p);
|
||||||
setGyro(1,q);
|
setGyro(1,q);
|
||||||
setGyro(2,r);
|
setGyro(2,r);
|
||||||
|
|
||||||
// temp
|
// temp
|
||||||
setGyroTemp(gyroTemp);
|
setGyroTemp(gyroTemp);
|
||||||
|
|
||||||
// accel
|
// accel
|
||||||
setAccel(0,aX);
|
setAccel(0,aX);
|
||||||
setAccel(1,aY);
|
setAccel(1,aY);
|
||||||
setAccel(2,aZ);
|
setAccel(2,aZ);
|
||||||
|
|
||||||
// differential pressure
|
// differential pressure
|
||||||
setPressure(diffPress);
|
setPressure(diffPress);
|
||||||
}
|
}
|
||||||
|
|
||||||
// see if new data is available
|
// see if new data is available
|
||||||
bool AP_ADC_HIL::new_data_available(const uint8_t *channel_numbers)
|
bool AP_ADC_HIL::new_data_available(const uint8_t *channel_numbers)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue