Files
README.mdSensors
All the base classes are inherited from the
Sensorclass, which is a virtual class and cannot be used as-is.Sensorclass also contains static variables and functions to access the available sensors (manually configured / detected at runtime).As many as requested sensors can be used ( within the limits of how many sensors the I2C/SPI/other busses support ). Attitude sensors and GPSs are mixed together (by
IMU::UpdateSensors()) if several of them are used.Any axis of each sensors can be swapped ( or the whole vector can be multiplied by a matrix ) to allow easier alignement between the sensor and drone's frame. ( see
Sensor::setAxisSwap()andSensor::setAxisMatrix(), used in LUA configuration asaxis_swap). Applying the swap must be implemented in each sensor driver inside theReadfunction.Adding new device driver
New sensor drivers must inherit from one of the following classes : * Gyroscope * Accelerometer * ~~Magnetometer~~ ( Not used yet ) * ~~Altimeter~~ ( WIP ) * ~~GPS~~ ( Not used yet ) * Voltmeter * CurrentSensor
Gyroscopes, accelerometers and magnetometers
These sensors are used for attitude computation. Each attitude sensor must return a 3-axis vector from its ::Read() function, if the sensor has only 1 or 2 axes, it must fill the relevant parts of the returned 3-axis vector and put the others to 0.
The following virtual members must be implemented : *
virtual void Calibrate( float dt, bool last_pass = false )Called several times (a few hundred times) on automatic/manual sensors calibration,dtis the the time in seconds since the last call to this function,last_passis set to true when this function is called for the last time. The function can be let empty if no calibration is needed. *virtual void Read( Vector3f* v, bool raw = false );Called every time the IMU needs new attitude data, current values must be swapped usingaxis_swapif set and finally put tov. Ifrawis true, calibration offsets must be ignored and data returned as-is after axis-swap.The following virtual members can be implemented : *
virtual string infos()Returns a string containing sensor informations (manufacturer, model, bus type and speed, etc)Voltmeter
Required members : *
virtual void Calibrate( float dt, bool last_pass = false )Same as above *virtual float Read( int channel = 0 )Must return current measured voltage on specifiedchannelOptional members : *
virtual string infos()Same as aboveGPS
Required members : *
virtual void Calibrate( float dt, bool last_pass = false )Same as above *virtual bool Read( float* latitude, float* longitude, float* altitude, float* speed )Must setlatitude,longitude,altitudeandspeedwith current GPS data and return true if current position is known, otherwise return false. *virtual time_t getTime()Must return current time in seconds since Epoch if known from GPS module, otherwise return 0.Optional members : *
virtual string infos()Same as above