Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoder Overflow when driving backwards #71

Open
Snaw3 opened this issue Mar 13, 2023 · 2 comments
Open

Encoder Overflow when driving backwards #71

Snaw3 opened this issue Mar 13, 2023 · 2 comments

Comments

@Snaw3
Copy link

Snaw3 commented Mar 13, 2023

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

ticksLeft = (ticksLeft % util::V_3_MAX_ENCODER_TICKS) + 1;

@Snaw3
Copy link
Author

Snaw3 commented Mar 13, 2023

grafik

@Snaw3
Copy link
Author

Snaw3 commented Mar 15, 2023

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant