• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/home/jgoppert/Projects/ap/libraries/AP_IMU/AP_IMU.h

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         // Constructors
00017         AP_IMU(AP_ADC *adc, uint16_t address) :
00018                 _adc(adc), 
00019                 _address(address)
00020         {}
00021         
00022         // Methods
00023         void            init(void);                                     // inits both
00024         void            init_accel(void);                       // just Accels
00025         void            init_gyro(void);                        // just gyros
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         // raw ADC values - called by DCM
00041         Vector3f        get_gyro(void);                                                                 // Radians/second
00042         Vector3f        get_accel(void);                                                                // meters/seconds squared
00043                                 
00044         // Members
00045         uint8_t         adc_constraints;                // a check of how many times we get non-sensical values
00046         
00047 private:
00048         // Methods
00049         void            read_offsets(void);
00050         float           gyro_temp_comp(int i, int temp) const;
00051 
00052         // members
00053         uint16_t        _address;                                       // EEPROM start address for saving/retrieving offsets
00054         float           _adc_in[6];                                     // array that store the 6 ADC channels used by IMU
00055         float           _adc_offset[6];                         // Array that store the Offset of the gyros and accelerometers
00056         Vector3f        _accel_vector;                          // Store the acceleration in a vector
00057         Vector3f        _gyro_vector;                           // Store the gyros turn rate in a vector
00058         AP_ADC          * _adc;                                         // Analog to digital converter pointer
00059         
00060         float           read_EE_float(int address);
00061         void            write_EE_float(float value, int address);
00062 
00063         // constants
00064         static const uint8_t    _sensors[6];
00065         static const int        _sensor_signs[9];
00066         static const uint8_t    _gyro_temp_ch = 3;                                              // The ADC channel reading the gyro temperature
00067         static const float              _gyro_temp_curve[3][3];
00068 };
00069 
00070 #endif

Generated for ArduPilot Libraries by doxygen