-
Notifications
You must be signed in to change notification settings - Fork 69
/
CalibratedSensor.h
61 lines (49 loc) · 1.54 KB
/
CalibratedSensor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef __CALIBRATEDSENSOR_H__
#define __CALIBRATEDSENSOR_H__
#include "common/base_classes/Sensor.h"
#include "BLDCMotor.h"
#include "common/base_classes/FOCMotor.h"
class CalibratedSensor: public Sensor{
public:
// constructor of class with pointer to base class sensor and driver
CalibratedSensor(Sensor& wrapped);
~CalibratedSensor();
/*
Override the update function
*/
virtual void update() override;
/**
* Calibrate method computes the LUT for the correction
*/
virtual void calibrate(BLDCMotor& motor);
// voltage to run the calibration: user input
float voltage_calibration = 1;
protected:
/**
* getSenorAngle() method of CalibratedSensor class.
* This should call getAngle() on the wrapped instance, and then apply the correction to
* the value returned.
*/
virtual float getSensorAngle() override;
/**
* init method of CaibratedSensor - call after calibration
*/
virtual void init() override;
/**
* delegate instance of Sensor class
*/
Sensor& _wrapped;
// lut size, currently constan. Perhaps to be made variable by user?
const int n_lut { 128 } ;
// create pointer for lut memory
float* calibrationLut = new float[n_lut]();
// Init inital angles
float theta_actual { 0.0 };
float elecAngle { 0.0 };
float elec_angle { 0.0 };
float theta_absolute_post { 0.0 };
float theta_absolute_init { 0.0 };
float theta_init { 0.0 };
float avg_elec_angle { 0.0 };
};
#endif