Go to Post Exactly matching weight at two different regionals is an indicator of something fishy. :p - Alan Anderson [more]
Home
Go Back   Chief Delphi > Technical > Programming > Python
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 23-03-2014, 11:27
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,040
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
pyfrc autonomous framework teaser

Continuing some work from the last few years with Team 2423's code, I've been developing generic python modules that will allow python teams to develop autonomous modes that have the following characteristics:
  • Dynamic detection of autonomous modes at runtime
  • Automatic support of selection of which autonomous mode to use via SmartDashboard
  • Supports simple built-in tuning of autonomous mode parameters via SmartDashboard
  • Easy to create autonomous modes that support state machine or time-based operation
  • Autonomous modes that are easy to read and understand

Team 1418 has been using this framework this year with great success, and at some point in the near future I'll be releasing it as part of pyfrc. New features in pyfrc will allow this (and other useful libraries) to be installed directly to the robot.

Here's one of Team 1418's autonomous modes that can score two balls.

Code:
try:
    import wpilib
except ImportError:
    from pyfrc import wpilib

from common.autonomous_helper import StatefulAutonomous, timed_state

class TwoBall(StatefulAutonomous):
    
    MODE_NAME = 'Two balls'
    DEFAULT = True   
    
    def __init__(self, components):
        super().__init__(components)
        
        self.register_sd_var('drive_speed', 0.5)
        
    def on_enable(self):
        super().on_enable()
        
    def update(self, tm):
        if tm > 0.3:
            self.catapult.pulldown()
            
        super().update(tm)
    
    @timed_state(duration=1.2, next_state='drive', first=True)       
    def drive_wait(self, tm, state_tm):
        '''Wait some period before we start driving'''
        self.intake.armDown()
        
    @timed_state(duration=1.4, next_state='launch')
    def drive(self, tm, state_tm):
        '''Start the launch sequence! Drive slowly forward for N seconds'''
        self.drive.move(0, self.drive_speed, 0)
        self.intake.armDown()
    
    @timed_state(duration=1, next_state='go_back') 
    def launch(self, tm):
        '''Fire and keep firing for 1 seconds'''
        self.catapult.launchNoSensor()
        
    @timed_state(duration=2.9,next_state='drive2') 
    def go_back(self):
        '''Go back to get the next ball'''
        self.drive.move(0, -1*self.drive_speed, 0)
        self.intake.ballIn()
            
    @timed_state(duration=2.5, next_state='launch2')
    def drive2(self, tm, state_tm):
        '''Once we get it, drive forward'''
        self.drive.move(0, self.drive_speed, 0)
        self.intake.ballIn()
    
    @timed_state(duration=1) 
    def launch2(self, tm):
        '''And shoot!'''
        self.catapult.launchNoSensor()
        self.intake.ballIn()

Seems too simple to work? Well, here's a video of this autonomous mode in the Virginia Regional scoring both balls in team 1418's last qualifying match.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #2   Spotlight this post!  
Unread 23-03-2014, 17:54
geipel geipel is offline
Registered User
AKA: Mike Geipel
FRC #1086 (Blue Cheese)
Team Role: Mentor
 
Join Date: May 2011
Rookie Year: 2009
Location: Glen Allen, VA
Posts: 2
geipel will become famous soon enoughgeipel will become famous soon enough
Re: pyfrc autonomous framework teaser

This looks very interesting! I would like to try this out during the off-season.

Thanks for making this available,
__________________
Mike Geipel
Reply With Quote
  #3   Spotlight this post!  
Unread 03-04-2014, 23:42
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,040
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: pyfrc autonomous framework teaser

Team 1418's code for 2014 has been released, which includes the current version of the autonomous framework in it. I'll be polishing it up a bit and adding it to pyfrc later this year.

See this CD post for the code release announcement.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #4   Spotlight this post!  
Unread 05-02-2015, 03:22
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,040
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: pyfrc autonomous framework teaser

FYI: this has finally been integrated into robotpy-wpilib-utilities. Documentation can be found at http://robotpy-wpilib-utilities.read...utonomous.html.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 19:50.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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