|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: Coding in jython
I'd say that the rationale for python should not be that it is syntatically easier for students to learn, but more that as a dynamically typed and fully interpreted language it allows advanced developers to utilize some neat python features...
|
|
#2
|
||||
|
||||
|
Re: Coding in jython
I can't say i don't agree. I did port this year's code to jython:
Code:
from edu.wpi.first.wpilibj import SimpleRobot, Timer
from com.shadowh511.mayor.inputs import Xbox, Switch, DomBoard, GreenAsia
from com.shadowh511.mayor.outputs import Driver, FiringThread
class RobotMain(SimpleRobot):
"""
This is the main robot class, hopefully the robot is smart enough to load
it :S
"""
def __init__ (self):
"""
Makes the robot class variables
"""
self.driver = Xbox(1)
self.gunner = GreenAsia(2)
self.motors = Driver(1,2,3,4,True)
self.firing = FiringThread()
self.switch = Switch(4,4)
self.DomBoard = DomBoard()
self.watchDog = SimpleRobot.getWatchdog()
def robotInit(self):
self.watchDog.setEnabled(False)
self.watchDog.kill()
def autonomous(self):
robotInit()
print "Autonomous Starting"
balls = 2
while SimpleRobot.isEnabled() and balls > 0:
if switch.ternaryGet():
self.motors.stop()
self.firing.autoFire()
Timer.delay(3)
balls -=1
else:
self.motors.drive(0.5)
self.motors.stop()
def operatorControl(self):
robotInit()
print "Starting Teleop"
while SimpleRobot.isEnabled():
self.motors.mecanumDrive(driver)
if self.gunner.getCross():
self.firing.autoFire()
elif self.gunner.getSquare():
self.firing.autoTap()
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Coding Question | ZP8892 | Programming | 1 | 18-01-2010 20:04 |
| Pneumatics coding | Nguyen | Programming | 19 | 14-02-2008 20:47 |
| C coding | ExarKun666 | General Forum | 12 | 21-12-2007 14:13 |
| Photoswitch coding | magical hands | Programming | 0 | 17-01-2006 21:20 |
| Coding conventions | Anthony Kesich | Programming | 20 | 08-01-2004 10:50 |