-
Notifications
You must be signed in to change notification settings - Fork 20
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
Conversation
Hm. I think teams have been using |
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. |
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.
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.
magicbot/magicrobot.py
Outdated
if hasattr(mode, 'setup'): | ||
mode.setup() | ||
|
||
|
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.
What's up with the extra blank line here?
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.
Just an extra blank line, I should have removed it
I suppose this is fine. I would prefer to fix #21 instead, really. |
But yes, please add some documentation in the right place and this is fine. |
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? |
Huh, I thought there was like a stub class documenting the interface somewhere here. I guess it is all in the robotpy-docs repo. |
This allows accessing magic injected variables from autonomous modes during initialization