Implement new controller

Dependencies:   mbed-rtos mbed QEI BNO055 MPU6050_DMP_Nucleo-I2Cdev virgo3_imuHandler_Orion_PCB MAX17048 Servo

Fork of Orion_newPCB_test by Team Virgo v3

01_DriveTrain/odometer.h

Committer:
akashvibhute
Date:
2016-01-18
Revision:
2:761e3c932ce0
Child:
4:315716ef8178

File content as of revision 2:761e3c932ce0:

#ifndef odometer_H
#define odometer_H

#include "mbed.h"
#include "generalFunctions.h"
#include "QEI.h"


class odometer
{
public:
    odometer(PinName encLeft_ChA, PinName encLeft_ChB, PinName encRight_ChA, PinName encRight_ChB, unsigned int enc_resolution, unsigned int movWindow_size);
    void update();
    void getRevolutions(float *revolutions[2]);
    void getRPM(float *rpm[2]);
    
private:
    QEI encLeft;
    QEI encRight;
    
    Timer enc_timer;
    float timer_s;
    
    unsigned int movWindow_len;
    unsigned int movWindow_index;
    float encRes;
    
    static const unsigned int movWindow_lenMax = 64; //to prevent excessive RAM usage at program runtime
    
    int32_t pulse_counter[2][2]; // [0:left / 1:right], [0:previous / 1:current]
    float rpmWindow_left[]; // [movWindow_index: instantaneous velocity in rpm]
    float rpmWindow_right[]; // [movWindow_index: instantaneous velocity in rpm]
    
    float filtered_reading[2][2]; // [0:left / 1:right], [0:revolutions / 1:velocity in rpm]
};


#endif