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

Call setup() on autonomous modes, fixing #19 #113

Merged
merged 3 commits into from
Sep 19, 2018
Merged

Call setup() on autonomous modes, fixing #19 #113

merged 3 commits into from
Sep 19, 2018

Conversation

Noskcaj19
Copy link
Contributor

This allows accessing magic injected variables from autonomous modes during initialization

@auscompgeek
Copy link
Member

Hm. I think teams have been using on_enable to work around this.

@Noskcaj19
Copy link
Contributor Author

That can work, however that is called when the mode is enabled, not when the robot starts. If you have somewhat expensive operations, that may not be entirely practical.

auscompgeek
auscompgeek previously approved these changes Sep 15, 2018
Copy link
Member

@auscompgeek auscompgeek left a comment

Choose a reason for hiding this comment

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

I suppose this is probably something we should allow. However, it should be noted that if you're doing any expensive operations in setup(), all n of your autonomous modes will have setup called, potentially making your robot startup very slow. I imagine an FTA wouldn't be very happy with a team whose robot takes more than a minute to start, for example.

This will have to be documented, otherwise LGTM.

if hasattr(mode, 'setup'):
mode.setup()


Copy link
Member

Choose a reason for hiding this comment

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

What's up with the extra blank line here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just an extra blank line, I should have removed it

@virtuald
Copy link
Member

I suppose this is fine. I would prefer to fix #21 instead, really.

@virtuald
Copy link
Member

But yes, please add some documentation in the right place and this is fine.

@Noskcaj19
Copy link
Contributor Author

Sorry for the delay, as for the documentation, is there anywhere specific it should be added? Perhaps in robotpy-docs magicbot.rst in autonomous mode. If so, should I open a pr in that repo?

@auscompgeek
Copy link
Member

Huh, I thought there was like a stub class documenting the interface somewhere here. I guess it is all in the robotpy-docs repo.

virtuald added a commit to robotpy/robotpy-docs that referenced this pull request Sep 19, 2018
@virtuald virtuald merged commit 7930380 into robotpy:master Sep 19, 2018
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.

3 participants