Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions AutonInterpreter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import wpilib
#from PracticeDriveCode import drive, operatorFunctions, robot
from GUI import convert

class AutonInterpreter():

def getList(self, name):
masterList = []
with open("GUI/convert/" + name, "r") as f:
data = f.readlines()
for line in data:
line = line[:-1]
temp = line.split(",")
#temp.remove("\n")
masterList.append(temp)
#print(masterList)
f.close()
for i in masterList:
if i[0] == "0":
i[0] = "driveCommand"
elif i[0] == "1":
i[0] = "turnCommand"
elif i[0] == "2":
i[0] = "genericCommand"
return(masterList)

AutonInterpreter.getList(None, "output")
pass
25 changes: 25 additions & 0 deletions Auton_Data_Handling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

speed="None"
direction="None"
angle="None"
testCommand ="None"
import DriveCommand, TurnCommand, AutonInterpreter
from PracticeDriveCode import driveTrain, operatorFunctions

class AutonHandling():

def readCommandList(self, alist):
i = 0 #Sets up iterator variable
cmdList = AutonInterpreter.AutonInterpreter.getList(None, alist)
for i in cmdList: #Basically, 'While i is less than or equal to the number or items in the list;'
if i[0] == "driveCommand":#Checking first item in list to see if it's a drive command
DriveCommand.DriveCommand(i[1], i[2], i[3], i[4]).runCommand()#It was a drive command! now it pulls all
#of the data from the list and plugs it into the DriveCommand function
elif i[0] == "turnCommand":#Repeat above process, just checking for a different variable
TurnCommand.TurnCommand(i[1]).runCommand()

AutonHandling.readCommandList(None, "haha")
''' # Used to work with runCommands, need to update in order to test out readCommandList
commands = DriveCommand.DriveCommand("Fast","Forward","Test"), TurnCommand.TurnCommand("Slow","Left"), DriveCommand.DriveCommand("Slow", "Backwards", "Test")
AutonHandling().runCommands(commands)
'''
16 changes: 16 additions & 0 deletions DriveCommand.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

speed="None"
direction="None"
angle="None"
testCommand ="None"


class DriveCommand():

def __init__(self, lspeed, ldistance, rspeed, rdistance):
self.lspeed = lspeed
self.ldistance = ldistance
self.rspeed = rspeed
self.rdistance = rdistance
def runCommand(self):
print ("LeftSpeed: " + self.lspeed + ", LeftDistance " + self.ldistance + "RightSpeed: " + self.rspeed + ", RightDistance: " + self.rdistance)
Binary file not shown.
78 changes: 38 additions & 40 deletions PracticeDriveCode/robot.py → PracticeDriveCode/autonTesting.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
"""
File Author: Jacob Harrelson
File Name: robot.py
File Creation Date: 1/8/2018
File Purpose: To create our drive functions
"""
import wpilib
from xbox import XboxController
from wpilib.drive import DifferentialDrive
from drive import driveTrain
#from operatorFunctions import operatorControl
from wpilib import RobotDrive

class MyRobot(wpilib.IterativeRobot):

def robotInit(self):
self.drive = driveTrain(self)
self.controllerOne = XboxController(0)
self.controllerTwo = XboxController(1)
#self.speedLimiter = 1 #1 = standard speed, greater than 1 to slow down, less than 1 to speed up

self.dashTimer = wpilib.Timer()# Timer for SmartDashboard updating
self.dashTimer.start()

def autonomousInit(self):
self.auto_loop_counter = 0
gameData = DriverStation.getInstance().getGameSpecificMessage()
print (gameData)

def autonomousPeriodic(self):
if self.auto_loop_counter < 100:#~50 loops a second
self.drive.autonDrive(.5, -.5) # Drive forwards at half speed
self.auto_loop_counter += 1
else:
self.robot_drive.drive(0, 0)
def teleopPeriodic(self):
self.drive.drivePass(self.controllerOne.getLeftY(), self.controllerOne.getRightY(), self.controllerOne.getLeftX(), self.controllerOne.getLeftBumper())
#self.operatorControl.operate(self.controllerTwo.getLeftY, self.controllerTwo.getLeftX(), self.controllerTwo.getRightY(), self.controllerTwo.getRightX(), self.controllerTwo.getButtonA(),self.controllerTwo.getButtonB(), self.controllerTwo.getButtonX(), self.controllerTwo.getButtonY(), self.controllerTwo.getRightTrigger(), self.controllerTwo.getRightBumper(), self.controllerTwo.getLeftTrigger(), self.controllerTwo.getLeftBumper())
if __name__ == "__main__":
wpilib.run(MyRobot)
"""
File Author: Jacob Harrelson
File Name: robot.py
File Creation Date: 1/8/2018
File Purpose: To create our drive functions
"""
import wpilib
from xbox import XboxController
from wpilib.drive import DifferentialDrive
from drive import driveTrain
from operatorFunctions import operatorControl
from wpilib import RobotDrive

class MyRobot(wpilib.IterativeRobot):

def robotInit(self):
self.drive = driveTrain(self)
self.controllerOne = XboxController(0)
self.controllerTwo = XboxController(1)
#self.speedLimiter = 1 #1 = standard speed, greater than 1 to slow down, less than 1 to speed up

self.dashTimer = wpilib.Timer()# Timer for SmartDashboard updating
self.dashTimer.start()

def autonomousInit(self):
self.gameData = DriverStation.getInstance().getGameSpecificMessage()
print (self.gameData)

def autonomousPeriodic(self):
if self.lfMotor.getSelectedSensorPosition(0) < 16000:
self.drive.autonDrive(1, 1)
else:
self.robot_drive.drive(0, 0)
def teleopPeriodic(self):
self.drive.drivePass(self.controllerOne.getLeftY(), self.controllerOne.getRightY(), self.controllerOne.getLeftX(), self.controllerOne.getLeftBumper())
#self.operatorControl.operate(self.controllerTwo.getLeftY, self.controllerTwo.getLeftX(), self.controllerTwo.getRightY(), self.controllerTwo.getRightX(), self.controllerTwo.getButtonA(),self.controllerTwo.getButtonB(), self.controllerTwo.getButtonX(), self.controllerTwo.getButtonY(), self.controllerTwo.getRightTrigger(), self.controllerTwo.getRightBumper(), self.controllerTwo.getLeftTrigger(), self.controllerTwo.getLeftBumper())
if __name__ == "__main__":
wpilib.run(MyRobot)
84 changes: 0 additions & 84 deletions PracticeDriveCode/drive.py

This file was deleted.

89 changes: 0 additions & 89 deletions PracticeDriveCode/operator.py

This file was deleted.

Loading