Chandra Tjhai
/
ENGO333_Lab_tiltmeter
Simple tiltmeter using accelerometer
Tiltmeter.h@0:7d6134e052e0, 2019-11-23 (annotated)
- Committer:
- chtjhai
- Date:
- Sat Nov 23 04:58:09 2019 +0000
- Revision:
- 0:7d6134e052e0
Simple tiltmeter using accelerometer
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chtjhai | 0:7d6134e052e0 | 1 | #ifndef TILTMETER_H |
chtjhai | 0:7d6134e052e0 | 2 | #define TILTMETER_H |
chtjhai | 0:7d6134e052e0 | 3 | |
chtjhai | 0:7d6134e052e0 | 4 | class Tiltmeter |
chtjhai | 0:7d6134e052e0 | 5 | { |
chtjhai | 0:7d6134e052e0 | 6 | public: |
chtjhai | 0:7d6134e052e0 | 7 | |
chtjhai | 0:7d6134e052e0 | 8 | // Default constructor |
chtjhai | 0:7d6134e052e0 | 9 | Tiltmeter(); |
chtjhai | 0:7d6134e052e0 | 10 | |
chtjhai | 0:7d6134e052e0 | 11 | |
chtjhai | 0:7d6134e052e0 | 12 | // Detect the presence of tiltmeter sensor and ensure its status is appropriately set. |
chtjhai | 0:7d6134e052e0 | 13 | // |
chtjhai | 0:7d6134e052e0 | 14 | // Arguments: |
chtjhai | 0:7d6134e052e0 | 15 | // None |
chtjhai | 0:7d6134e052e0 | 16 | // |
chtjhai | 0:7d6134e052e0 | 17 | // Returns: |
chtjhai | 0:7d6134e052e0 | 18 | // The function returns true if the sensor is present and ready to use, and false otherwise. |
chtjhai | 0:7d6134e052e0 | 19 | virtual bool TestConnection() = 0; |
chtjhai | 0:7d6134e052e0 | 20 | |
chtjhai | 0:7d6134e052e0 | 21 | |
chtjhai | 0:7d6134e052e0 | 22 | // Compute the tilt angles and store them internally; you can access the computed values by |
chtjhai | 0:7d6134e052e0 | 23 | // calling the GetRoll() and GetPitch() functions. |
chtjhai | 0:7d6134e052e0 | 24 | // |
chtjhai | 0:7d6134e052e0 | 25 | // Arguments: |
chtjhai | 0:7d6134e052e0 | 26 | // None |
chtjhai | 0:7d6134e052e0 | 27 | // |
chtjhai | 0:7d6134e052e0 | 28 | // Returns: |
chtjhai | 0:7d6134e052e0 | 29 | // Nothing |
chtjhai | 0:7d6134e052e0 | 30 | void ComputeTiltAngles(); |
chtjhai | 0:7d6134e052e0 | 31 | |
chtjhai | 0:7d6134e052e0 | 32 | |
chtjhai | 0:7d6134e052e0 | 33 | // Get the most recent roll angle as computed by calling ComputeTilt() |
chtjhai | 0:7d6134e052e0 | 34 | // |
chtjhai | 0:7d6134e052e0 | 35 | // Arguments: |
chtjhai | 0:7d6134e052e0 | 36 | // None |
chtjhai | 0:7d6134e052e0 | 37 | // |
chtjhai | 0:7d6134e052e0 | 38 | // Returns: |
chtjhai | 0:7d6134e052e0 | 39 | // The function returns the roll angle in units of degrees |
chtjhai | 0:7d6134e052e0 | 40 | float GetRoll() const; |
chtjhai | 0:7d6134e052e0 | 41 | |
chtjhai | 0:7d6134e052e0 | 42 | |
chtjhai | 0:7d6134e052e0 | 43 | // Get the most recent roll angle as computed by calling ComputeTilt() |
chtjhai | 0:7d6134e052e0 | 44 | // |
chtjhai | 0:7d6134e052e0 | 45 | // Arguments: |
chtjhai | 0:7d6134e052e0 | 46 | // None |
chtjhai | 0:7d6134e052e0 | 47 | // |
chtjhai | 0:7d6134e052e0 | 48 | // Returns: |
chtjhai | 0:7d6134e052e0 | 49 | // The function returns the roll angle in units of degrees |
chtjhai | 0:7d6134e052e0 | 50 | float GetPitch() const; |
chtjhai | 0:7d6134e052e0 | 51 | |
chtjhai | 0:7d6134e052e0 | 52 | |
chtjhai | 0:7d6134e052e0 | 53 | private: |
chtjhai | 0:7d6134e052e0 | 54 | |
chtjhai | 0:7d6134e052e0 | 55 | // Read the accelerometer data and store the values for later use. You can access the values by |
chtjhai | 0:7d6134e052e0 | 56 | // calling the GetAccelX(), GetAccelY() and/or GetAccelZ(); |
chtjhai | 0:7d6134e052e0 | 57 | // |
chtjhai | 0:7d6134e052e0 | 58 | // Arguments: |
chtjhai | 0:7d6134e052e0 | 59 | // None |
chtjhai | 0:7d6134e052e0 | 60 | // |
chtjhai | 0:7d6134e052e0 | 61 | // Returns: |
chtjhai | 0:7d6134e052e0 | 62 | // Nothing |
chtjhai | 0:7d6134e052e0 | 63 | // |
chtjhai | 0:7d6134e052e0 | 64 | // Remarks: |
chtjhai | 0:7d6134e052e0 | 65 | // The data will be stored in the 'MeasuredAccel' member variable in units of m/s/s |
chtjhai | 0:7d6134e052e0 | 66 | virtual void ReadAccelerometers() = 0; |
chtjhai | 0:7d6134e052e0 | 67 | |
chtjhai | 0:7d6134e052e0 | 68 | |
chtjhai | 0:7d6134e052e0 | 69 | // Get the most recently measured X-axis acceleration as stored during the last call to |
chtjhai | 0:7d6134e052e0 | 70 | // ReadAccelerometer() |
chtjhai | 0:7d6134e052e0 | 71 | // |
chtjhai | 0:7d6134e052e0 | 72 | // Arguments: |
chtjhai | 0:7d6134e052e0 | 73 | // None |
chtjhai | 0:7d6134e052e0 | 74 | // |
chtjhai | 0:7d6134e052e0 | 75 | // Returns: |
chtjhai | 0:7d6134e052e0 | 76 | // The function returns the most recently measured X-axis acceleration in units of m/s/s |
chtjhai | 0:7d6134e052e0 | 77 | virtual float GetAccelX() const = 0; |
chtjhai | 0:7d6134e052e0 | 78 | |
chtjhai | 0:7d6134e052e0 | 79 | |
chtjhai | 0:7d6134e052e0 | 80 | // Get the most recently measured Y-axis acceleration as stored during the last call to |
chtjhai | 0:7d6134e052e0 | 81 | // ReadAccelerometer() |
chtjhai | 0:7d6134e052e0 | 82 | // |
chtjhai | 0:7d6134e052e0 | 83 | // Arguments: |
chtjhai | 0:7d6134e052e0 | 84 | // None |
chtjhai | 0:7d6134e052e0 | 85 | // |
chtjhai | 0:7d6134e052e0 | 86 | // Returns: |
chtjhai | 0:7d6134e052e0 | 87 | // The function returns the most recently measured Y-axis acceleration in units of m/s/s |
chtjhai | 0:7d6134e052e0 | 88 | virtual float GetAccelY() const = 0; |
chtjhai | 0:7d6134e052e0 | 89 | |
chtjhai | 0:7d6134e052e0 | 90 | |
chtjhai | 0:7d6134e052e0 | 91 | // Get the most recently measured Z-axis acceleration as stored during the last call to |
chtjhai | 0:7d6134e052e0 | 92 | // ReadAccelerometer() |
chtjhai | 0:7d6134e052e0 | 93 | // |
chtjhai | 0:7d6134e052e0 | 94 | // Arguments: |
chtjhai | 0:7d6134e052e0 | 95 | // None |
chtjhai | 0:7d6134e052e0 | 96 | // |
chtjhai | 0:7d6134e052e0 | 97 | // Returns: |
chtjhai | 0:7d6134e052e0 | 98 | // The function returns the most recently measured Z-axis acceleration in units of m/s/s |
chtjhai | 0:7d6134e052e0 | 99 | virtual float GetAccelZ() const = 0; |
chtjhai | 0:7d6134e052e0 | 100 | |
chtjhai | 0:7d6134e052e0 | 101 | |
chtjhai | 0:7d6134e052e0 | 102 | private: |
chtjhai | 0:7d6134e052e0 | 103 | |
chtjhai | 0:7d6134e052e0 | 104 | // Variables to store the roll and pitch values in units of degrees |
chtjhai | 0:7d6134e052e0 | 105 | float RollAngle, PitchAngle; |
chtjhai | 0:7d6134e052e0 | 106 | |
chtjhai | 0:7d6134e052e0 | 107 | |
chtjhai | 0:7d6134e052e0 | 108 | }; |
chtjhai | 0:7d6134e052e0 | 109 | |
chtjhai | 0:7d6134e052e0 | 110 | #endif |
chtjhai | 0:7d6134e052e0 | 111 | |
chtjhai | 0:7d6134e052e0 | 112 |