-
Notifications
You must be signed in to change notification settings - Fork 612
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
[commands] Add TimedCommandRobot class #4871
[commands] Add TimedCommandRobot class #4871
Conversation
/format |
/format |
Note that it's generally preferred to use present imperative tense for commit messages, (e.g. add instead of added). https://reflectoring.io/meaningful-commit-messages/#active-voice |
wpilibNewCommands/src/main/native/include/frc2/command/CommandRobot.h
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandRobot.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/native/include/frc2/command/CommandRobot.h
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/native/include/frc2/command/CommandRobot.h
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/native/include/frc2/command/CommandRobot.h
Outdated
Show resolved
Hide resolved
I don't think that templates and examples should be merged for 2023, given that none of this would be beta tested. |
I agree, further testing is needed to confirm the side effects of bringing the CommandScheduler run outside of the main loop |
wpilibNewCommands/src/main/native/include/frc2/command/CommandRobot.h
Outdated
Show resolved
Hide resolved
* Command Based Programming. | ||
*/ | ||
public class CommandRobot extends TimedRobot { | ||
private static final double kSchedulerOffset = 0.005; |
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.
Why is there an offset? RobotPy put ours in RobotPeriodic, which is where I think most examples put theirs... it feels like this could potentially lead to a difference in behavior.
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.
@Starlight220 , @rzblue , and I had a conversation over discord about whether an offset should be included or not. The command scheduler call is normally placed in the RobotPeriodic method which is why testing is required to rule out any potential issues.
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.
Having the scheduler run at the end of robotPeriodic can result in inconsistent timing if a lot of stuff runs before it. By adding an offset, the scheduler timing should be more consistent.
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.
But in a command based robot, aren't most things running on the scheduler anyways?
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.
Yes, but there's a lot of other stuff that runs in the TimedRobot loop, and teams can also choose to run code inside periodic methods as well.
/format |
wpilibNewCommands/src/main/native/include/frc2/command/TimedCommandRobot.h
Outdated
Show resolved
Hide resolved
I don't think there will be any side effects- it is still being run in the same loop, just at a different time. |
…mmandRobot.h Co-authored-by: David Vo <[email protected]>
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.
Add some unit tests, maybe?
What should be added? This class is just TimedRobot with an addPeridic. If that works, this will |
There should be a test to confirm that |
I think it's out of scope, but a subsequent PR would be totally fine. |
Abandoned by author. |
CommandRobot
class extendsTimedRobot
and is intended to add the CommandScheduler run method into the periodic loop without exposing it to the user.Depending on when this merges, I can update the templates and examples to use this
@Oblarg's idea via discord