Bayley Wang
/
foc-ed_in_the_bot_compact
robot
Diff: PositionSensor/PositionSensor.cpp
- Revision:
- 15:b583cd30b063
- Parent:
- 9:074575151e4b
- Child:
- 24:5e18a87a0e95
--- a/PositionSensor/PositionSensor.cpp Sun Oct 30 02:19:41 2016 +0000 +++ b/PositionSensor/PositionSensor.cpp Sun Oct 30 22:16:30 2016 +0000 @@ -1,7 +1,7 @@ #include "mbed.h" #include "PositionSensor.h" -#include "config.h" +#include "config_motor.h" #include <math.h> /* @@ -57,12 +57,11 @@ int raw = TIM2->CNT; if (raw < 0) raw += _cpr; if (raw >= _cpr) raw -= _cpr; - float signed_elec = fmod(6.28318530718f * (raw) / (float)_cpr + _offset, 6.28318530718f); - if (signed_elec < 0){ - return signed_elec + 6.28318530718f; - } - else{ - return signed_elec; + float signed_mech = fmod(6.28318530718f * (raw) / (float)_cpr + _offset, 6.28318530718f); + if (signed_mech < 0){ + return signed_mech + 6.28318530718f; + } else { + return signed_mech; } }