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

Potential Cause of Command Scheduler Overruns: Repeated Execution Of Commands? #27

Open
rakrakon opened this issue Aug 29, 2024 · 1 comment · May be fixed by #90
Open

Potential Cause of Command Scheduler Overruns: Repeated Execution Of Commands? #27

rakrakon opened this issue Aug 29, 2024 · 1 comment · May be fixed by #90
Assignees
Labels
bug Something isn't working high priority Critical tasks that need to be addressed soon question Further information is requested wtf?? wtf??

Comments

@rakrakon
Copy link
Contributor

Issue Description

In many places in our codebase, the setAngle function or similiar set functions are implemented like this:

fun setAngle(angle: Measure<Angle>): Command {
    return run { 
        angleSetpoint = angle
        io.setAngle(angle)
    }.withName("Set Angle Hood")
}

Use of run { ... } in Commands

The run { ... } construct creates a RunCommand, which repeatedly executes the specified action in every cycle until the command ends. This continuous execution may lead to our Command Scheduler overruns.

Fix:

  • Switch to using runOnce { ... }
    By doing so i believe we will no longer have overruns.

@katzuv Please correct me if I misread documentation or am missing something here.

@rakrakon rakrakon added the question Further information is requested label Aug 29, 2024
@katzuv
Copy link
Member

katzuv commented Aug 29, 2024

First, great issue! Well written.

To your question, this might be a problem, although I believe some optimizations are in place: IIRC, AdvantageKit won't log again values which haven't changed, and Talon FX code won't send an additional command if the command didn't change.
A few years back it was problematic to not send a command in every loop (the watchdog would kick in and disable the motor for safety reasons) but I believe this is not a problem nowadays.

You can always open VisualVM and compare the performance.

Note also that instead of using until we'll need to run a waitUntil after the command because it'll end immediately.

Do some testing and report back! 😃

@Emma03L Emma03L added bug Something isn't working high priority Critical tasks that need to be addressed soon wtf?? wtf?? labels Oct 30, 2024
@rakrakon rakrakon linked a pull request Nov 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority Critical tasks that need to be addressed soon question Further information is requested wtf?? wtf??
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants