View Single Post
  #19   Spotlight this post!  
Unread 15-04-2015, 19:31
michaelwm's Avatar
michaelwm michaelwm is offline
Integrated Systems Lead
AKA: Michael Midura
FRC #4976 (Rebel Robotics)
Team Role: Programmer
 
Join Date: Dec 2013
Rookie Year: 2010
Location: Georgetown
Posts: 23
michaelwm is a jewel in the roughmichaelwm is a jewel in the roughmichaelwm is a jewel in the roughmichaelwm is a jewel in the rough
Re: Javascript Robots!

Quote:
Originally Posted by Arhowk View Post
O.O

How exactly are you doing this...? Assuming you're just throwing the talons inside of a SimpleBinding, 5 seconds is absolutely monstrous. Are you doing something wierd like interfacing with the HAL layer directly from JavaScript?
Not at all actually, we were passing the Talon, Solenoid, and other classes directly to the scripts as variables, and the scripts simply called their methods (i.e. Talon.set(n). The problem is with the amount of scripts / the length of scripts. If your program had just a single script that said
Code:
talon.set(1)
, it would execute fine (but is entirely useless). The more scripts and the longer the scripts are, the longer it took for the interpreter to parse them, and call their methods, thus the 5 second execution time.

We're switching to v8 because it utilizes JIT compilation. We are using the roboRIO's file system to store scripts, and the program compiles them at startup (during queue, for example), and never touches them again, unless our development mode is active. In this case, an external file watcher on the development machine watches for changes to javascript files, and when it detects one, sends the changes to the roboRIO, which stores the new file on the File System, and recompiles it. This minimizes execution time to instantaneous during competition (as no compilation is done during a match because no development is active), and much shorter times than the current java/c++ compilation times for WPI/eclipse.
__________________
Integrated Systems