Go to the documentation of this file.00001 #ifndef AP_IMU_h
00002 #define AP_IMU_h
00003
00004 #include <FastSerial.h>
00005 #include <AP_Math.h>
00006 #include <inttypes.h>
00007 #include "WProgram.h"
00008 #include <AP_ADC.h>
00009 #include <avr/eeprom.h>
00010
00011
00012 class AP_IMU
00013 {
00014
00015 public:
00016
00017 AP_IMU(AP_ADC *adc, uint16_t address) :
00018 _adc(adc),
00019 _address(address)
00020 {}
00021
00022
00023 void init(void);
00024 void init_accel(void);
00025 void init_gyro(void);
00026 void zero_accel(void);
00027
00028 void load_gyro_eeprom(void);
00029 void save_gyro_eeprom(void);
00030 void load_accel_eeprom(void);
00031 void save_accel_eeprom(void);
00032 void print_accel_offsets(void);
00033 void print_gyro_offsets(void);
00034
00035 void ax(const int v) { _adc_offset[3] = v; }
00036 void ay(const int v) { _adc_offset[4] = v; }
00037 void az(const int v) { _adc_offset[5] = v; }
00038
00039
00040
00041 Vector3f get_gyro(void);
00042 Vector3f get_accel(void);
00043
00044
00045 uint8_t adc_constraints;
00046
00047 private:
00048
00049 void read_offsets(void);
00050 float gyro_temp_comp(int i, int temp) const;
00051
00052
00053 uint16_t _address;
00054 float _adc_in[6];
00055 float _adc_offset[6];
00056 Vector3f _accel_vector;
00057 Vector3f _gyro_vector;
00058 AP_ADC * _adc;
00059
00060 float read_EE_float(int address);
00061 void write_EE_float(float value, int address);
00062
00063
00064 static const uint8_t _sensors[6];
00065 static const int _sensor_signs[9];
00066 static const uint8_t _gyro_temp_ch = 3;
00067 static const float _gyro_temp_curve[3][3];
00068 };
00069
00070 #endif