-
Notifications
You must be signed in to change notification settings - Fork 3
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
Added slew rate limiter to drive controls #174
base: main
Are you sure you want to change the base?
Conversation
Gold872
commented
Oct 9, 2024
- Adds slew rate limiter (acceleration limiter) to drive
- Invert right input on bar chart in the drive page
final currentTime = DateTime.now(); | ||
final elapsedSeconds = (currentTime.microsecondsSinceEpoch / 1e6) - | ||
(_previousTime.microsecondsSinceEpoch / 1e6); |
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.
final currentTime = DateTime.now(); | |
final elapsedSeconds = (currentTime.microsecondsSinceEpoch / 1e6) - | |
(_previousTime.microsecondsSinceEpoch / 1e6); | |
final elapsedSeconds = DateTime.now().difference(_previousTime).inMilliseconds; |
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.
This wouldn't work, since this method would be called every 10 ms the output would always be 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.
Oh I just based it off the variable name, now I just changed it to inMilliseconds
-- that should be the same as what you were doing already, right?
List<Message> parseInputs(GamepadState state) { | ||
final leftInput = state.normalLeftY; | ||
final rightInput = -state.normalRightY; | ||
|
||
return [ | ||
DriveCommand(throttle: throttle, setThrottle: true), | ||
DriveCommand(setLeft: true, left: leftLimiter.calculate(leftInput)), | ||
DriveCommand(setRight: true, right: rightLimiter.calculate(rightInput)), |
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.
You can probably remove the variables here to keep it shorter again. You can do -state.normalRightY
instead of -1 * state.normalRightY
though