QuadroCopter  0.1.4
quadro::orientation Class Reference

#include <orientation.h>

Public Types

enum  dataFilter { KALMAN = 1, COMPLIMENTARY = 2 }
 

Public Member Functions

 orientation ()
 
 ~orientation () noexcept
 
void setDataFilterSelection (int)
 

Public Attributes

const float DATA_RATE = 0.02
 
const float COMPLIMENTARY_FILTER_TUNING = 0.98
 
float roll
 Filtered roll value stored as a float. More...
 
float pitch
 Filtered pitch value stored as a float. More...
 
float yaw
 Filtered yaw value stored as a float. More...
 
float baroHeight
 Filtered baroHeight value stored as a float. More...
 
float sonicHeight
 Filtered sonicHeight value stored as a float. More...
 
float height
 Filtered height value stored as a float. More...
 
float heading
 Filtered heading value stored as a float. More...
 
int dataFilterSelection
 Contains the currently selected data filter algorithm. More...
 
PIDpitchPID
 
PIDrollPID
 

Member Enumeration Documentation

select a Filter type

Enumerator
KALMAN 

Kalman Filter algorithm.

COMPLIMENTARY 

Complimentary Filter algorithm.

87  {
88  KALMAN = 1,
89  COMPLIMENTARY = 2
90  };
Complimentary Filter algorithm.
Definition: orientation.h:89
Kalman Filter algorithm.
Definition: orientation.h:88

Constructor & Destructor Documentation

orientation::orientation ( )

Orientation constructor - This class initiates a thread that activates sensors and constantly updates/reads all values. From within this class I should have access to everything orientation related : e.g Accelerometer, Magnetometer, Gyroscope, Barometer and Sonic Sensor.

none

Exceptions
setupException
23 {
24  try {
25  //Create a new LVMaxSonarEZ object
26  sonicSensor = new LVMaxSonarEZ();
27 
28  //Set the height calculation mode to Centimetres.
29  sonicSensor->setMode( LVMaxSonarEZ::deviceMode::Cm );
30 
31  //Start the sensors main thread, runs while the sensor is on.
32  sonicSensor->start();
33 
34  //Create a new LSM303Accelerometer, this sensors thread is initiated in the constructor
35  accelerometer = new LSM303Accelerometer();
36 
37  //Start the sensors main thread, runs while the sensor is on.
38  accelerometer->start();
39 
40  //Create a new LSM303Magnetometer, this sensors thread is initiated in the constructor
41  magnetometer = new LSM303Magnetometer();
42 
43  //Start the sensors main thread, runs while the sensor is on.
44  magnetometer->start();
45 
46  //Create a new L3GD20H, this sensors thread is initiated in the constructor
47  gyroscope = new L3GD20H();
48 
49  //Start the sensors main thread, runs while the sensor is on.
50  gyroscope->start();
51  }
52  catch( analog::analogSetupException& e ){
53  throw new setupException( analog::STARTUP_FAILURE + " Details : " + e.what() );
54  }
55  catch( i2c::i2cSetupException& e ){
56  throw new setupException( i2c::STARTUP_FAILURE + " Details : " + e.what() );
57  }
58 
59  //Set up a new PID object for Pitch
60  pitchPID = new PID( 0.2, 100, -100, 0.1, 0.01, 0.5 );
61 
62  //Set up a new PID object for Roll
63  rollPID = new PID( 0.2, 100, -100, 0.1, 0.01, 0.5 );
64 
65  //select the Kalman filter method by default, this can be altered using the public setDataFilterSelection method.
67 
68  //Start the orientation main thread that calculates it's own values based on sensor thread updated values.
69  pthread_create( &orientationNotifyer, NULL, orientation::setValues, this );
70 }
void setMode(deviceMode _mode)
Definition: LVMaxSonarEZ.cpp:120
int start()
Definition: LSM303Magnetometer.cpp:63
Definition: analogSetupException.h:40
Definition: i2cSetupException.h:24
const char * what() const
Definition: setupException.h:42
Definition: L3GD20H.h:51
Definition: LVMaxSonarEZ.h:28
int start()
Definition: LVMaxSonarEZ.cpp:30
Definition: LSM303Accelerometer.h:20
Definition: LSM303Magnetometer.h:31
int start()
Definition: L3GD20H.cpp:56
int start()
Definition: LSM303Accelerometer.cpp:28
void setDataFilterSelection(int)
Definition: orientation.cpp:134
PID * rollPID
Definition: orientation.h:100
Definition: PID.h:7
Kalman Filter algorithm.
Definition: orientation.h:88
const string STARTUP_FAILURE
Definition: analogSetupException.h:31
PID * pitchPID
Definition: orientation.h:95
const string STARTUP_FAILURE
Definition: i2cSetupException.h:18
orientation::~orientation ( )
noexcept

Destructor : Kills all threads.

73 {
74  sonicSensor->stop( );
75  accelerometer->stop( accelerometer->threadHandle );
76  magnetometer->stop( magnetometer->threadHandle );
77  gyroscope->stop( gyroscope->threadHandle );
78 }
int stop(pthread_t threadHandle)
Definition: i2cDevice.cpp:179
int stop()
Definition: LVMaxSonarEZ.cpp:74

Member Function Documentation

void orientation::setDataFilterSelection ( int  _dataFilter)

Select a Data Filter from the selection found in dataFilter

Parameters
intdataFilter type : 1 = Kalman Filter, 2 = Complimentary Filter.
135 {
136  dataFilterSelection = _dataFilter;
137 }
int dataFilterSelection
Contains the currently selected data filter algorithm.
Definition: orientation.h:82

Member Data Documentation

float quadro::orientation::baroHeight

Filtered baroHeight value stored as a float.

const float quadro::orientation::COMPLIMENTARY_FILTER_TUNING = 0.98

COMPLIMENTARY_FILTER_TUNING is the percentage of the first value used in the filter, it is offset by subtracting it from 1 and using the remainder percentage in the filters algorithm.

const float quadro::orientation::DATA_RATE = 0.02

DATA_RATE is the speed that data is being refreshed.

int quadro::orientation::dataFilterSelection

Contains the currently selected data filter algorithm.

float quadro::orientation::heading

Filtered heading value stored as a float.

float quadro::orientation::height

Filtered height value stored as a float.

float quadro::orientation::pitch

Filtered pitch value stored as a float.

PID* quadro::orientation::pitchPID

Pointer for a new PID (Proportional–Integral–Derivative) object for pitch values

float quadro::orientation::roll

Filtered roll value stored as a float.

PID* quadro::orientation::rollPID

Pointer for a new PID (Proportional–Integral–Derivative) object for roll values

float quadro::orientation::sonicHeight

Filtered sonicHeight value stored as a float.

float quadro::orientation::yaw

Filtered yaw value stored as a float.


The documentation for this class was generated from the following files:
  • /Users/michaelbrookes/ClionProjects/Quadro/lib/orientation/orientation.h
  • /Users/michaelbrookes/ClionProjects/Quadro/lib/orientation/orientation.cpp