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

[commands] Add CommandRobot #6859

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

spacey-sooty
Copy link
Contributor

Resolves #6624

@spacey-sooty spacey-sooty requested a review from a team as a code owner July 20, 2024 13:42
Copy link
Contributor

This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR.

@spacey-sooty
Copy link
Contributor Author

This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR.

Python already has TimedCommandRobot. Should that be replaced with this? Should that stay and this not be added? Should this be added and that stay?

@spacey-sooty spacey-sooty force-pushed the commandrobot branch 2 times, most recently from 8bd5018 to d840979 Compare July 20, 2024 14:06
@spacey-sooty spacey-sooty requested review from a team as code owners July 20, 2024 14:06
@spacey-sooty spacey-sooty force-pushed the commandrobot branch 2 times, most recently from 63269be to cde09bd Compare July 20, 2024 14:54
@spacey-sooty spacey-sooty marked this pull request as draft July 20, 2024 15:12
@spacey-sooty spacey-sooty force-pushed the commandrobot branch 3 times, most recently from 504f6ab to c761646 Compare July 21, 2024 02:47
@sciencewhiz
Copy link
Contributor

This would need a corresponding change in robotbuilder

@spacey-sooty spacey-sooty marked this pull request as ready for review July 21, 2024 03:56
@spacey-sooty spacey-sooty force-pushed the commandrobot branch 5 times, most recently from fa3d279 to 6610438 Compare July 21, 2024 12:42
@spacey-sooty spacey-sooty force-pushed the commandrobot branch 3 times, most recently from 4181cbf to 19f46cc Compare July 26, 2024 04:53
Comment on lines +52 to +55
m_autonomousCommand = m_autoChooser.getSelected();
if (m_autonomousCommand != null) {
m_scheduler.schedule(m_autonomousCommand);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use the Autonomous Start trigger for this

@spacey-sooty
Copy link
Contributor Author

@Oblarg can you review?

@Starlight220
Copy link
Member

There seem to be merge conflicts?

Copy link
Member

@Starlight220 Starlight220 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm fully onboard with the design here.
For instance, the abstraction here over the sendablechooser feels leaky, similar to the control subsystems. It doesn't save much code, and bites teams doing other stuff (such as the EventLoop/Trigger-based auto idea I've seen thrown around). It being an "invisible" protected field that teams are supposed to know exist and modify is suspect to me.

The mode-specific fields are locked away, yet there isn't infrastructure to replace their use cases. Not much benefit over just not overriding them in team code, as long as there's no actual content in the final implementation.

I think cutting the empty overrides from the templates/examples and merging RobotContainer into Robot would bring most of the value here without adding a new base class (which is a somewhat orthogonal enhancement, but needs to be further fleshed out imo).

This feels like an empty yet leaking abstraction; the main convenience here is that the scheduler is called automatically.

Going for a multi-EventLoop base class might be an idea worth pursuing (though others will have to convey their thoughts on that), but that's more of an EventRobot than CommandRobot.

Going Trigger-based would likely be easier and closer to paradigms that are already starting to circulate.


I'll assume there have been discussions about this. Since I'm nearly not involved, feel free to ignore my review if others have been involved and this is the design that was agreed upon.

@spacey-sooty
Copy link
Contributor Author

For instance, the abstraction here over the sendablechooser feels leaky, similar to the control subsystems. It doesn't save much code, and bites teams doing other stuff (such as the EventLoop/Trigger-based auto idea I've seen thrown around). It being an "invisible" protected field that teams are supposed to know exist and modify is suspect to me.

This is probably my biggest concern. The reason I added it was as a way to support having an autonomous command by default. Originally I did this with an autonomous command variable but @virtuald suggested it should be easier to integrate with a sendable chooser. When I get around to documentation for this then it will obviously be explained how to use it then.

As for using Trigger based autos this is actually something that was discussed quite in depth, there are a few seperate ways that you can achieve this with this model, such as your command factory also creating Triggers then deferring your command factory.

The mode-specific fields are locked away, yet there isn't infrastructure to replace their use cases. Not much benefit over just not overriding them in team code, as long as there's no actual content in the final implementation.

What functionality are teams missing with these functions locked away? Fundamentally the idea of this pr is that if you are using CommandBased correctly you shouldn't need these functions. If your doing something custom like periodic sensor or odometry refresh then you will use addPeriodic for that anyways but other than that you should only need Commands and Triggers.

This feels like an empty yet leaking abstraction; the main convenience here is that the scheduler is called automatically.

The idea here isn't convenience, it's meant to point teams towards using Command based correctly.

Going Trigger-based would likely be easier and closer to paradigms that are already starting to circulate.

The idea of this is to encourage people to go Trigger based by making it more difficult for them to not use Triggers.

@spacey-sooty
Copy link
Contributor Author

There seem to be merge conflicts?

Yes there are conflicts with the examples I'll address those.

@Override
public final void teleopInit() {
if (m_autonomousCommand != null) {
m_scheduler.cancel(m_autonomousCommand);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What’s the reasoning for having the auto command cancelled in teleopInit() rather than autonomousExit()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how it was before no particular reason

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

Successfully merging this pull request may close these issues.

CommandRobot discussion
6 participants