added direct setting of accel offsets

git-svn-id: https://arducopter.googlecode.com/svn/trunk@1160 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
jasonshort 2010-12-19 03:21:38 +00:00
parent 3f9a077dbd
commit 82c4815e2c
2 changed files with 9 additions and 2 deletions

View File

@ -224,10 +224,12 @@ AP_IMU::get_accel(void)
for (int i = 3; i < 6; i++) { for (int i = 3; i < 6; i++) {
_adc_in[i] = _adc->Ch(_sensors[i]); _adc_in[i] = _adc->Ch(_sensors[i]);
_adc_in[i] -= 2025; // Subtract typical accel bias _adc_in[i] -= 2025; // Subtract typical accel bias
if (_sensor_signs[i] < 0) if (_sensor_signs[i] < 0)
_adc_in[i] = (_adc_offset[i] - _adc_in[i]); _adc_in[i] = _adc_offset[i] - _adc_in[i];
else else
_adc_in[i] = (_adc_in[i] - _adc_offset[i]); _adc_in[i] = _adc_in[i] - _adc_offset[i];
if (fabs(_adc_in[i]) > ADC_CONSTRAINT) { if (fabs(_adc_in[i]) > ADC_CONSTRAINT) {
adc_constraints++; // We keep track of the number of times adc_constraints++; // We keep track of the number of times
_adc_in[i] = constrain(_adc_in[i], -ADC_CONSTRAINT, ADC_CONSTRAINT); // Throw out nonsensical values _adc_in[i] = constrain(_adc_in[i], -ADC_CONSTRAINT, ADC_CONSTRAINT); // Throw out nonsensical values

View File

@ -32,6 +32,11 @@ public:
void print_accel_offsets(void); void print_accel_offsets(void);
void print_gyro_offsets(void); void print_gyro_offsets(void);
void ax(const int v) { _adc_offset[3] = v; }
void ay(const int v) { _adc_offset[4] = v; }
void az(const int v) { _adc_offset[5] = v; }
// raw ADC values - called by DCM // raw ADC values - called by DCM
Vector3f get_gyro(void); // Radians/second Vector3f get_gyro(void); // Radians/second
Vector3f get_accel(void); // meters/seconds squared Vector3f get_accel(void); // meters/seconds squared