-
Notifications
You must be signed in to change notification settings - Fork 24
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
base auto stop bug fix #152
Conversation
@micheal-parks - if you want to see my attempt at this. still doesn't work with multiple clients on the same machine, but im tracking the touch 'session' locally and cancelling if the base is moving but touch has ended. |
This ended up not being the specific bug Eliot was seeing, but it is similar. |
lib/widgets/joystick.dart
Outdated
) | ||
], | ||
); | ||
} | ||
|
||
void callSetPower(StickDragDetails details) { | ||
touchActive = (details.x != 0 && details.y != 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be ||
for the use case of when I'm fully horizontal (e.g. only fully right). Then X would be non-zero, but Y would be zero
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah you're totally right, great catch, thank you!
I added a perhaps too lengthy comment describing some of the thoughts on this issue in the code, I will explain here as well.
Essentially things tend to work well in normal network conditions, but as soon as the client is in spotty conditions, not enough to end the session but enough to garble the order of some calls or have some not make it through, the joystick widget tends to not auto stop not upon touch release and the base will continue to move in whatever the last command was.
My first thought was to shorten the sessions heartbeat interval, but that is configured per robot and not per client.
So I ended up tracking the touch locally in the widgets state and sending a stop command if the base is still moving but touch has been released, I check 100 milliseconds after each call.
If network conditions allow this will stop the base sooner than the ending session would, though if network conditions do not allow the stop call to make it through the ending session will eventually stop base.
Another option would be to continually check if the bass is moving and if the touch is active every 100ms during the widgets life cycle. I didn't opt for that to limit extraneous calls.