Handling of TACHOMETER value overflow
nyxrobotics opened this issue · comments
TakaakiNumai commented
Abstract
The TACHOMETER value is converted to double, which results in an incorrect value during overflow.
vesc/vesc_driver/src/vesc_packet.cpp
Lines 276 to 283 in 3d25c6a
How to Reproduce the Bug
If the motor continues to rotate until TACHOMETER overflows, the return value of getPosition jumps
Suggestion
Calculate the difference from the previous value and cast the value to double.
The difference shall not exceed the maximum value of int.
int tachometer = (int)readBuffer(TACHOMETER, 4);
static int tachometer_last = tachometer ;
current_pose += (double)(tachometer - tachometer_last);
tachometer_last = tachometer;