|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Coding in jython
Have any teams tried to code the FRC robot in jython?
I was thinking about trying this to help explain coding to the new programmers, but I don't know if it works. Has anyone tried it? |
|
#2
|
|||
|
|||
|
Re: Coding in jython
Quote:
Not that I'd use it, personally; I don't see how Python makes "explaining coding" to new programmers easier than any other language, contrary to popular opinion. |
|
#3
|
||||
|
||||
|
Re: Coding in jython
THink, no brackets, no semicolins, no parentheses unless they are req'd, its easier
|
|
#4
|
|||
|
|||
|
Re: Coding in jython
I've been working on a Jython interpreter port (alongside a rhino JS interpreter)...
It's a little tricky however, because these things are all written for Java 5/6 and have to be retrowoven/hacked back to be 1.3 compliant... The bigger issue, however, is getting java bindings working(which you will need if you want to use anything in WPILibJ) because J2ME does not allow dynamic class loading...something both rhino and jython rely on in their java bindings. Thus, my rhino intepreter works but it pretty much justs prints stuff for the moment...Jython is a bit more tricky to work with. |
|
#5
|
||||
|
||||
|
Re: Coding in jython
If you're trying to explain code to new programmers, shouldn't you use a language that is well-supported?
In other words, I don't know many FIRST teams (or anybody, really) using Jython. What if they have problems? |
|
#6
|
|||
|
|||
|
Re: Coding in jython
Getting new programmers to remember their brackets, semicolons, and parentheses is by far the easiest part of teaching them to be good programmers. The difficult is getting them to use simple and effective design patterns, which Python (/Jython) does not do a good job of encouraging, IMO.
|
|
#7
|
|||
|
|||
|
Re: Coding in jython
Quote:
However, I do feel that using high-level languages and not having to deal with the low-level stuff is something you can only do properly after you are capable of actually doing that stuff yourself. |
|
#8
|
|||
|
|||
|
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...
|
|
#9
|
||||
|
||||
|
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 | 01-18-2010 08:04 PM |
| Pneumatics coding | Nguyen | Programming | 19 | 02-14-2008 08:47 PM |
| C coding | ExarKun666 | General Forum | 12 | 12-21-2007 02:13 PM |
| Photoswitch coding | magical hands | Programming | 0 | 01-17-2006 09:20 PM |
| Coding conventions | Anthony Kesich | Programming | 20 | 01-08-2004 10:50 AM |