Magicbot has had a lot of upgrades this season, and hopefully in the offseason I'll be able to add some more things and document them.
Two particular new features in today's release that I wanted to highlight:
- There is a 'tunable' property that you can add to automatically add variables to networktables (sorta like ntproperty, but less verbose)
- Do you like the autonomous state machine builder? Of course you do! Well, you can create magicbot components using the same style of declarative state machine helpers!
As an example, here's a theoretical shooter component:
Code:
class ShooterAutomation:
# Some other component
shooter = Shooter
ball_pusher = BallPusher
def fire(self):
"""This is called from the main loop"""
self.engage()
@state(first=True)
def begin_firing(self):
self.shooter.enable()
if self.shooter.ready():
self.next_state('firing')
@timed_state(duration=1.0, must_finish=True)
def firing(self):
"""This state will continue executing even if engage isn't called"""
self.shooter.enable()
self.ball_pusher.push()
...
class MyRobot(magicbot.MagicRobot):
...
def teleopPeriodic(self):
if self.joystick.getTrigger():
self.shooter_automation.fire()
If you're competing at the Championship, you probably won't want to upgrade. But for the rest of you, download it and give it a shot.