Comments (7)
I have an alternative idea for this. What if instead we used a prefix scheme to inject things? Something like...
class Component:
motor = wpilib.Talon
class MyRobot:
left_component = Component
right_component = Component
def create_objects(self):
left_component_motor = wpilib.Talon
right_component_motor = wpilib.Talon
So when it was looking for variables to inject, it looks first for the actual name, and if it doesn't find it then it looks for the variable name prefixed by the component name? This would solve your issue, yeah?
Keep in mind that you could inject anything you wanted, it doesn't have to be a motor -- it could be a tuple too I think.
from robotpy-wpilib-utilities.
The thing I'm undecided on is whether it should look for the prefixed version of the variable first, or whether it should look for the variable name first. For backwards compatibility, probably variable name first..
from robotpy-wpilib-utilities.
So my main issue is that there is a lot of things in my constructor. To use magic bot components I would have to create two motor object and one encoder object for each Swerve Module. Then I would have to call multiple functions to turn off and on flags and also set the zero value for the encoder. For each module that I initialized it would be around 8 lines of code. I would end up with around 32 lines of just creating swerve module things.
from robotpy-wpilib-utilities.
I would be happy if some how we had access to the arguments passed to the setup()
method.
from robotpy-wpilib-utilities.
You could do:
class MyRobot:
module_args = (1,2,3,4)
class Component:
module_args = tuple
from robotpy-wpilib-utilities.
Turns out I had already implemented the prefix thing. You should use a tuple to pass your args to the underlying component. I'll write some docs.
from robotpy-wpilib-utilities.
Docs are up here: http://robotpy.readthedocs.io/en/stable/frameworks/magicbot.html#variable-injection
from robotpy-wpilib-utilities.
Related Issues (20)
- Calling the super() methods in robot.py is required for command code, but outputs a warning that they need to be overridden. HOT 5
- NotifierDelay is broken
- Autonomous mode test cycler doesn't work HOT 1
- magicbot: Running teleop code during autonomous HOT 3
- magicbot: Add tunable setter
- magicbot: tunables shuffleboard integration ala oblog HOT 1
- Simple WatchDog Object has no attribute printEpochs HOT 1
- AttributeError: "SimpleWatchdog" object has no attribute "printEpochs" HOT 6
- New command-based framework HOT 11
- magicbot doesn't understand the typing module
- will_reset_to resets before the execute method in a component when using StateMachines HOT 1
- segfault HOT 2
- Cannot import commandbased HOT 1
- Move commandbased to robotpy-commands-v1
- MagicRobot does not execute setup or execute after injection HOT 2
- Add simulation support for distance sensors
- magicbot: use ntcore poller instead of callbacks?
- magicbot mode exit methods HOT 1
- Misleading error occurs when automodes aren't successfully loaded
- magicbot.feedback should work for the selected auto mode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from robotpy-wpilib-utilities.