Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Ported: Javascript for 2010 (http://www.chiefdelphi.com/forums/showthread.php?t=78983)

alivemyst 16-11-2009 05:30

Ported: Javascript for 2010
 
After a solid night of hacking, I've managed to port Mozilla's Rhino Javascript Engine(http://www.mozilla.org/rhino/) over from a half baked J2ME implementation(http://sourceforge.net/projects/rhinoj2mecldc/) to the 2010 FRC Java system--squawk VM etc.
I'll post the code shortly, but some notable features

Running the rhino js engine allows you direct access to Java libraries and classes as well as Javascript code.
Javascript is fully interpreted in rhino(if someone wants to work on a JIT compiled V8 implementation, let me know ;)), but any Java calls will have equal performance to a normal java setup because they go straight to the JVM.
My implementation of rhino utilizes a socket on the cRIO, allowing users an interactive console with the cRIO as code is executed.

What does this mean for FRC? Well to put this in perspective--
Using this system, you can write as much of your code as you please in javascript(the benefits and conveniences of which are many) and still utilize the robot control libraries that are part of the new WPILibJ.
Using this system you can have an interactive console to your robot, and have code interpreted on the fly--that's right, no deploy, no compile.
[If you are nuts, you can replace your driverstation joysticks with a keyboard and a pair of competent coders, and drive your robot with code :P]
You can easily toy with code as it runs on the robot.
You can teach and learn javascript with your team members, which is in many ways friendlier than Java while maintaining an un-weird syntax.
And much more...

EricVanWyk 16-11-2009 09:02

Re: Ported: Javascript for 2010
 
You, good sir, are what we describe as "good insane".

Sounds pretty cool!

Bharat Nain 17-11-2009 14:58

Re: Ported: Javascript for 2010
 
Quote:

Originally Posted by alivemyst (Post 882724)
If you are nuts, you can replace your driverstation joysticks with a keyboard and a pair of competent coders, and drive your robot with code :P

Oh cool. We can save money on joysticks this year to pay for registration. After all, who uses joysticks these days. We play games with a keyboard and mouse. Maybe we'll do that this year. :p

biojae 17-11-2009 22:55

Re: Ported: Javascript for 2010
 
Quote:

Oh cool. We can save money on joysticks this year to pay for registration. After all, who uses joysticks these days. We play games with a keyboard and mouse. Maybe we'll do that this year.
Just keep in mind, the driverstation only passes joystick data.
Just try to plug a mouse or keyboard into the bluebox DS and it gives weird results.
Your mileage may vary.

bronxbomber92 20-11-2009 21:47

Re: Ported: Javascript for 2010
 
How fast does the JIT run on the cRIO (say compared to Java)?

DonRotolo 21-11-2009 00:54

Re: Ported: Javascript for 2010
 
Quote:

Originally Posted by biojae (Post 883069)
Just keep in mind, the driverstation only passes joystick data.
Just try to plug a mouse or keyboard into the bluebox DS and it gives weird results.
Your mileage may vary.

Aside from the sarcasm in Bharat's post, the 2010 Driver Station has its own keyboard.

biojae 21-11-2009 01:48

Re: Ported: Javascript for 2010
 
Quote:

Originally Posted by Don Rotolo (Post 883675)
Aside from the sarcasm in Bharat's post, the 2010 Driver Station has its own keyboard.

Yes, it may have its keyboard, but only joysticks are passed.
Quote:

Originally Posted by Joe Ross, DS Presentation
Joysticks
● Supports 3 joysticks + Stop button or 4
joysticks without stop button

But, if you could make a keyboard look like a joystick to the DirectInput API it would be passed
http://forums.usfirst.org/showthread.php?t=13368

alivemyst 21-11-2009 11:46

Re: Ported: Javascript for 2010
 
Actually, I've written a shell/pair of shells that bypass the driverstation issue--
one exploits the ability of the cRIO to open ServerSockets via javaME's Generic Connection Foundation, so i can pull up a socket on whatever port i like, and either telnet to it or write a proper client app.
The other shell is incomplete, but handles Stdin via an open and undocumented UDP port on the cRIO, passing keystrokes directly to the device. Personally I like the serversocket approach a lot more.

@bronxbomber92: I haven't played with Rhino's AOT compilation system yet, and I know it doesnt have a JIT compiler... so no idea.

On a side note, I'm running into some really nasty hitches in the Java-Javascript wrapper/classloader system, that I believe are the product of the crappy j2me rhino implementation i'm using.
If I cant hack the wrapper system together, I may be forced to switch to a full Java 5 SE version of rhino and will probably retroweave it to work with J2ME. Still that will take a little more work... If anybody knows stuff about this and would like to help out it'd be great. Its eating my hours right now, and I have work. :(
This is the last hurdle before WPILibJ works fully. If this can be thrown together in a week then it could be released to coincide with the FRC Java release, which would be amazing. 4 Languages for FRC :)

pm me if you are interested or post here. I can put up a repo &c, although if you are not a beta tester/[hacker] you will have to test your stuff in the SunSPOT environment. Nbd, just no WPILibJ for u!

EricVanWyk 21-11-2009 12:18

Re: Ported: Javascript for 2010
 
Quote:

Originally Posted by alivemyst (Post 883703)
Actually, I've written a shell/pair of shells that bypass the driverstation issue--
one exploits the ability of the cRIO to open ServerSockets via javaME's Generic Connection Foundation, so i can pull up a socket on whatever port i like, and either telnet to it or write a proper client app.
The other shell is incomplete, but handles Stdin via an open and undocumented UDP port on the cRIO, passing keystrokes directly to the device. Personally I like the serversocket approach a lot more.

Please bear in mind that using "undocumented ports" or "bypassing XYZ" run a good chance of only working at home. The at home network is intended to be as open as possible, to allow you the best possible prototyping environment. The at competition network is intended to guarantee good communication to all 6 robots, and may therefore deny some things.

If your communication does not adhere to the specified protocol, you will not have a leg to stand on should it suddenly be blocked.

nathanww 26-11-2009 02:26

Re: Ported: Javascript for 2010
 
As I recall, last year, anything except the standard DS UDP transmissions were firewalled. Some teams built tunneling protocols to sneak video data through, but this would be much more complicated for what you're proposing.

On the other hand, Java...script? I think my brain just exploded.

alivemyst 01-12-2009 23:13

Re: Ported: Javascript for 2010
 
Stdin is now being integrated into FRC Java images, so no more undocumentedness.

Also, I'm working on getting the Java5 version of rhino ported, because it is possible to run Java 5 stuff in J2ME -- see sun's playsim project presentation for a hint.

Robototes2412 10-02-2010 19:55

Re: Ported: Javascript for 2010
 
Did this project die?

ygd 10-02-2010 20:05

Re: Ported: Javascript for 2010
 
If you can get this working, we're almost definately using JavaScript next year.

Even better: Haskell.

Robototes2412 11-02-2010 21:15

Re: Ported: Javascript for 2010
 
WHy not jython?

spartango 08-04-2010 02:54

Re: Ported: Javascript for 2010
 
The major limitation with all of these dynamic languages is that java me doesnt allow for dynamic class loading.
Honestly if we want either of these to proceed, we should go back to stuff like v8 and the original python interpreter, written in C, and compile them for PPC.

Robototes2412 08-04-2010 13:16

Re: Ported: Javascript for 2010
 
GCC has an ARM-VXworks port, its similar ehough to standard PPC GCC that all you would have to port is the system module, hopefully.

Robototes2412 08-04-2010 13:31

Re: Ported: Javascript for 2010
 
oh, i was talking about python xD

if you want JS, try gnome's seed as an engine


All times are GMT -5. The time now is 11:17.

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