Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Python (http://www.chiefdelphi.com/forums/forumdisplay.php?f=187)
-   -   Initial release of MagicBot framework (http://www.chiefdelphi.com/forums/showthread.php?t=143091)

virtuald 03-02-2016 12:37

Initial release of MagicBot framework
 
In the spirit of "release early, release often", I'm happy to announce the first version of MagicBot, which is bundled with robotpy-wpilib-utilities 2016.3.0.

MagicBot is an opinionated framework for creating Python robot programs for the FIRST Robotics Competition. It is envisioned to eventually be an easier to use pythonic alternative to the Command framework.

This initial release tackles the following problems:
  • Reduced boilerplate associated with creating multiple component objects and passing them around
  • Providing a solid foundation for developing robot programs structured in a particular way
  • Automatic integration of the autonomous mode chooser

Future problem areas I intend to tackle:
  • Automatic NetworkTable value publishing
  • Generalized state machine via decorators (similar to StatefulAutonomous)

It's still lightly tested, not complete by any means, and I still have a few more ideas to add to it. However, what's there will probably work. ;)

Read more | Simple example program

Feedback and bug reports welcome!

virtuald 26-04-2016 14:04

Re: Initial release of MagicBot framework
 
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:
  1. There is a 'tunable' property that you can add to automatically add variables to networktables (sorta like ntproperty, but less verbose)
  2. 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.


All times are GMT -5. The time now is 21:37.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi