Skip to content

Instantly share code, notes, and snippets.

@calebeby
Last active March 28, 2017 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calebeby/b6daca87758c5beda7e4b781cbb70be5 to your computer and use it in GitHub Desktop.
Save calebeby/b6daca87758c5beda7e4b781cbb70be5 to your computer and use it in GitHub Desktop.
import wpilib
from magicbot import magic_motion_profile
class Drive(magic_motion_profile):
robot_drive = wpilib.RobotDrive
left_drive_motor = wpilib.Spark
right_drive_motor = wpilib.Spark
rotation_speed = resetsTo(0)
forwards_speed = resetsTo(0)
def __init__(self):
self.set_profile_forwards(max_feet_per_second=8, acceleration_seconds=1.5, deceleration_seconds=1)
self.set_profile_rotation(max_degrees_per_second=90, acceleration_seconds=0.5, deceleration_seconds=0.5)
def execute(self):
self.robot_drive.arcadeDrive(self.forwards, self.rotation)
from components import drive
from robotpy_ext.autonomous import state, StatefulAutonomous
import wpilib
from magicbot.magic_tunable import tunable
class sideLift(StatefulAutonomous):
MODE_NAME = "Side Lift"
DEFAULT = False
drive = drive.Drive
camera = camera.Camera
@state(first=True)
def forward(self):
if self.drive.forwards(feet=3):
self.next_state('turn')
@state
def turn(self):
if self.drive.turn_right(degrees=60):
self.next_state('forward_to_airship')
@state
def forward_to_airship(self):
self.drive.forwards(feet=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment