Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Removed lots of redundant includes + definitions
  • Loading branch information
Matthew Watson committed Apr 27, 2013
1 parent 3d3dd02 commit 59729ad
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 60 deletions.
3 changes: 1 addition & 2 deletions AHRS.cpp
Expand Up @@ -8,7 +8,6 @@
#include "AHRS.h"
#include "HMC5883L.h"
#include "MS5611.h"
#include "unistd.h"

//Values calculated from matlab script MgnCalibration
const double accelZeroX = 0.2238;
Expand Down Expand Up @@ -109,7 +108,7 @@ void AHRSClass::calibrateData_() {
//End Altitude LPF
}

inline void AHRSClass::temperatureCompensate_() {
void AHRSClass::temperatureCompensate_() {
static double tempPow1 = calibratedData.temp;
static double tempPow2 = pow(calibratedData.temp, 2);
static double tempPow3 = pow(calibratedData.temp, 3);
Expand Down
8 changes: 1 addition & 7 deletions AHRS.h
Expand Up @@ -9,8 +9,6 @@
#define AHRS_H

#include <iostream>
#include <stdint.h>
#include <math.h>

#include "Timer.h"
#include "MPU6050.h"
Expand All @@ -22,12 +20,8 @@
#include "struct_euler.h"
#include "Quaternion.h"

#define pi 3.14159265358979
const double g = 9.81816;




class AHRSClass
{
public:
Expand All @@ -47,7 +41,7 @@ class AHRSClass
void fuse_();
void quaternionToYPR_(QuaternionClass* q, s_euler* orientation);
double magnitude_(double x, double y, double z);
KalmanClass kalmanPhi_, kalmanPsi_;
// KalmanClass kalmanPhi_, kalmanPsi_;
ExtendedKalmanClass EKF;
};

Expand Down
1 change: 0 additions & 1 deletion CommandLineInterface.cpp
Expand Up @@ -6,7 +6,6 @@
*/

#include "CommandLineInterface.h"
#include "PICInterface.h"

CLI_class CLI;
pthread_mutex_t CLImutex;
Expand Down
7 changes: 1 addition & 6 deletions CommandLineInterface.h
Expand Up @@ -8,18 +8,13 @@
#ifndef COMMANDLINEINTERFACE_H
#define COMMANDLINEINTERFACE_H

#include <cstdlib>
#include <iostream>
#include <map>
#include <pthread.h>
#include <string>
#include <stdio.h>
#include <sys/types.h>
#include <sstream>

#include "Logger.h"
#include "Timer.h"
#include "Control.h"
#include "PICInterface.h"


enum lineString
Expand Down
1 change: 0 additions & 1 deletion HMC5883L.cpp
Expand Up @@ -6,7 +6,6 @@
*/

#include "HMC5883L.h"
#include "I2CInterface.h"

HMC5883LClass HMC5883L;

Expand Down
1 change: 1 addition & 0 deletions HMC5883L.h
Expand Up @@ -9,6 +9,7 @@
#define HMC5883L_H

#include "struct_rawData.h"
#include "I2CInterface.h"

const uint8_t HMC5883L_ADDRESS = 0x1E;

Expand Down
10 changes: 5 additions & 5 deletions Kalman.cpp
Expand Up @@ -29,11 +29,11 @@ KalmanClass::~KalmanClass()
{
}

void KalmanClass::predict(double* u, double* x1, float* dt)
void KalmanClass::predict(double* u, double* x, float* dt)
{
//Predicted state estimate
//x = F.x + B.u
*x1 += (*u - bias_) * *dt;
*x += (*u - bias_) * *dt;

//Predicted estimate covariance
//P = F.P.F' + Q
Expand All @@ -43,11 +43,11 @@ void KalmanClass::predict(double* u, double* x1, float* dt)
P_[1][1] += Q_bias_;
}

void KalmanClass::update(double* z, double* x1)
void KalmanClass::update(double* z, double* x)
{
//Innovation
//y = z - H.x
y_ = *z - *x1;
y_ = *z - *x;

//Innovation covariance
//S = H.P.H' + R
Expand All @@ -60,7 +60,7 @@ void KalmanClass::update(double* z, double* x1)

//Updated state estimate
//x = x + K.y
*x1 += K_[0] * y_;
*x += K_[0] * y_;
bias_ += K_[1] * y_;

//Updated estimate covariance
Expand Down
4 changes: 2 additions & 2 deletions Kalman.h
Expand Up @@ -15,8 +15,8 @@ class KalmanClass
KalmanClass(const KalmanClass& orig);
virtual ~KalmanClass();

void predict(double* u, double* x1, float* dt);
void update(double* z, double* x1);
void predict(double* u, double* x, float* dt);
void update(double* z, double* x);

private:
double bias_;
Expand Down
1 change: 0 additions & 1 deletion MS5611.cpp
Expand Up @@ -6,7 +6,6 @@
*/

#include "MS5611.h"
#include "I2CInterface.h"

MS5611Class MS5611;

Expand Down
3 changes: 2 additions & 1 deletion MS5611.h
Expand Up @@ -8,7 +8,8 @@
#ifndef MS5611_H
#define MS5611_H

#include <stdint.h>
#include <iostream>
#include "I2CInterface.h"

const uint8_t MS5611_ADDRESS = 0x77;
const uint8_t C0_ADDRESS = 0xA0;
Expand Down
1 change: 0 additions & 1 deletion PICInterface.h
Expand Up @@ -9,7 +9,6 @@
#define PICINTERFACE_H

#include <iostream>
#include <stdint.h>

#include "I2CInterface.h"

Expand Down
2 changes: 0 additions & 2 deletions Timer.cpp
Expand Up @@ -6,8 +6,6 @@
*/

#include "Timer.h"
#include "PICInterface.h"
#include "Control.h"

#define PERIOD 2500000

Expand Down
18 changes: 7 additions & 11 deletions Timer.h
Expand Up @@ -9,17 +9,13 @@
#define TIMER_H

#include <signal.h>
#include <sys/time.h>
#include <iostream>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fstream>

#include "MPU6050.h"
#include "AHRS.h"
#include "Logger.h"
#include "PICInterface.h"
#include "Control.h"

class TimerClass
{
Expand All @@ -32,14 +28,14 @@ class TimerClass
void stop();

float dt;
timer_t timerId; /* id for the posix timer */
struct sigaction signalAction; /* signal action handler struct */
timer_t timerId; //id for the posix timer
struct sigaction signalAction; //signal action handler struct
bool started;
private:
static void sig_handler_(int signum);
struct itimerspec timeToSet_; /* time to be set */
struct timespec timeValue_; /* timer expiration value */
struct timespec timeInterval_; /* timer period */
struct itimerspec timeToSet_; //time to be set
struct timespec timeValue_; //timer expiration value
struct timespec timeInterval_; //timer period
timespec oldtime_;
timespec time_;
timespec iterationtime_;
Expand Down
16 changes: 2 additions & 14 deletions main.cpp
Expand Up @@ -9,25 +9,13 @@
#include "main.h"
#include "PICInterface.h"
#include "HMC5883L.h"
/*
*
*/
template <class T, void(T::*member_function)()>
void* thunk(void* p)
{
(static_cast<T*> (p)->*member_function)();
return 0;
}

int main(int argc, char** argv)
{
MPU6050.initialise();
HMC5883L.initialise();
// pthread_t CLIthread;
// pthread_create(&CLIthread, NULL, thunk<CLI_class, &CLI_class::open>, &CLI);
HMC5883L.initialise();
Timer.start();
CLI.open();

CLI.open();
while (1)
{
sleep(1000);
Expand Down
6 changes: 0 additions & 6 deletions main.h
Expand Up @@ -8,19 +8,13 @@
#ifndef MAIN_H
#define MAIN_H

#include "I2CInterface.h"
#include "MPU6050.h"
#include "Logger.h"
#include "AHRS.h"
#include "CommandLineInterface.h"
#include "Timer.h"


#include <iostream>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif /* MAIN_H */


0 comments on commit 59729ad

Please sign in to comment.