libcreate icon indicating copy to clipboard operation
libcreate copied to clipboard

Encoder Overflow when driving backwards

Open Snaw3 opened this issue 2 years ago • 2 comments

When driving backwards, the encoders of the Create Roomba 600 overflow, because the wrap around handler is implemented in a way, which only works in one direction https://github.com/AutonomyLab/libcreate/blob/d75d41c63843581cfd113fd8ceac976d65bc06b4/src/create.cpp#L164

Snaw3 avatar Mar 13 '23 22:03 Snaw3

grafik

Snaw3 avatar Mar 13 '23 22:03 Snaw3

This fixes the issue:

// Handle wrap around
if (ticksLeft > 0.9 * util::V_3_MAX_ENCODER_TICKS) {
    ticksLeft -= util::V_3_MAX_ENCODER_TICKS;
} else if (ticksLeft < -0.9 * util::V_3_MAX_ENCODER_TICKS) {
    ticksLeft += util::V_3_MAX_ENCODER_TICKS;
}

if (ticksRight > 0.9 * util::V_3_MAX_ENCODER_TICKS) {
    ticksRight -= util::V_3_MAX_ENCODER_TICKS;
} else if (ticksRight < -0.9 * util::V_3_MAX_ENCODER_TICKS) {
    ticksRight += util::V_3_MAX_ENCODER_TICKS;
}

Snaw3 avatar Mar 15 '23 12:03 Snaw3