summaryrefslogtreecommitdiff
path: root/src/sensor/calibration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sensor/calibration.cpp')
-rw-r--r--src/sensor/calibration.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/sensor/calibration.cpp b/src/sensor/calibration.cpp
index 1a2b91e..5626388 100644
--- a/src/sensor/calibration.cpp
+++ b/src/sensor/calibration.cpp
@@ -3,7 +3,8 @@
#include "common/time.hpp"
#include "utils.hpp"
-SensorCalibrator::SensorCalibrator(Sensor &sensor, SerialStream sout)
+SensorCalibrator::SensorCalibrator(common::SharedPtr<Sensor> sensor,
+ common::SharedPtr<SerialStream> sout)
: _sensor(sensor), _sout(sout)
{
}
@@ -31,12 +32,12 @@ bool SensorCalibrator::calibrate(unsigned int throttle_time)
_adjustValues(values);
- _sout << "Accel X: " << values.accel_x << " "
- << "Accel Y: " << values.accel_y << " "
- << "Accel Z: " << values.accel_z << " "
- << "Gyro X: " << values.gyro_x << " "
- << "Gyro Y: " << values.gyro_y << " "
- << "Gyro Z: " << values.gyro_z << endl;
+ *_sout << "Accel X: " << values.accel_x << " "
+ << "Accel Y: " << values.accel_y << " "
+ << "Accel Z: " << values.accel_z << " "
+ << "Gyro X: " << values.gyro_x << " "
+ << "Gyro Y: " << values.gyro_y << " "
+ << "Gyro Z: " << values.gyro_z << endl;
if (_isValuesInRange(values))
{
@@ -51,26 +52,26 @@ bool SensorCalibrator::calibrate(unsigned int throttle_time)
void SensorCalibrator::_updateValues(SensorCalibratorValues &values)
{
- _sensor.read();
+ _sensor->read();
- values.accel_x -= _sensor.getAccelX();
- values.accel_y -= _sensor.getAccelY();
- values.accel_z -= _sensor.getAccelZ();
+ values.accel_x -= _sensor->getAccelX();
+ values.accel_y -= _sensor->getAccelY();
+ values.accel_z -= _sensor->getAccelZ();
- values.gyro_x -= _sensor.getGyroX();
- values.gyro_y -= _sensor.getGyroY();
- values.gyro_z -= _sensor.getGyroZ();
+ values.gyro_x -= _sensor->getGyroX();
+ values.gyro_y -= _sensor->getGyroY();
+ values.gyro_z -= _sensor->getGyroZ();
}
void SensorCalibrator::_adjustCalibrationWithValues(const SensorCalibratorValues &values)
{
- _sensor.accel_cal_x += values.accel_x;
- _sensor.accel_cal_y += values.accel_y;
- _sensor.accel_cal_z += values.accel_z;
+ _sensor->accel_cal_x += values.accel_x;
+ _sensor->accel_cal_y += values.accel_y;
+ _sensor->accel_cal_z += values.accel_z;
- _sensor.gyro_cal_x += values.gyro_x;
- _sensor.gyro_cal_y += values.gyro_y;
- _sensor.gyro_cal_z += values.gyro_z;
+ _sensor->gyro_cal_x += values.gyro_x;
+ _sensor->gyro_cal_y += values.gyro_y;
+ _sensor->gyro_cal_z += values.gyro_z;
}
void SensorCalibrator::_adjustValues(SensorCalibratorValues &values)