Go to Post All those crazy teenagers walking around Atlanta trying to "Save the world" looking like gang members with their attire. - BrendanB [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #16   Spotlight this post!  
Unread 15-04-2015, 07:30
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 544
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Javascript Robots!

I'm down as well (I was actually planning to do JavaScript this season but the teams member count was really low so I had no time).

Stuff that would need to be done
1) WPILib for JavaScript
2) JavaScript interpreter for the roborio (Java has on built in, there are some good cpp ones available)
3) sample projects
4) code development tool, preferably cross platform (recommended javafx or Qt)
5) rio tools (flasher If necessary, code dashboard, JavaScript rio interface)
6) code deployment tool
7) debugging tools
8) (optional) Js native interface tools (for running hard vision processing loops, sensor feedback loops, etc)

I'd be interested in learning Qt if there were enough other people to support the rest of the project (else I'd do something simple like a ftp server attached to sublime)

Last edited by Arhowk : 15-04-2015 at 07:32.
  #17   Spotlight this post!  
Unread 15-04-2015, 10:00
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: 24
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!

This was a small side project for me this year, and i'm finishing it during this offseason. Some useful things we learned that anyone interested in using javascript for their robot:

Don't use Java 8 / Nashorn (their built in JS interpreter):
  • The initial build of Java 8 installed on the roboRIO does not include Nashorn (or any JS interpreter for that matter). See here.
  • It grows exponentially slow. Just printing "hello world!" executes fine. The more code we added, the slower it's execution time got. Any function (releasing a cylinder, driving a motor) took upwards of 5 seconds to execute.

Have an intuitive software design
  • We based our JS design off of the DOM webdesign convention. Driving a motor in JS is as simple as
    Code:
    robot.talon.port3.set(1);
    (Subject to change as we refine our programming model)
  • Aside from being interpreted in real time, JS is the most common language taught in high school programming courses. If you ever want new programmers, an intuitive design based on what students already know (DOM) will attract new programmers like crazy.

Our team is using the Google v8 JS engine (the same engine powering node), and we have had major success. We will be releasing the source soon, but I personally would love some competition!
__________________
Integrated Systems
  #18   Spotlight this post!  
Unread 15-04-2015, 16:35
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 544
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Javascript Robots!

Quote:
Any function (releasing a cylinder, driving a motor) took upwards of 5 seconds to execute
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?
  #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: 24
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
  #20   Spotlight this post!  
Unread 15-04-2015, 19:43
JesseK's Avatar
JesseK JesseK is online now
Expert Flybot Crasher
FRC #1885 (ILITE)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2005
Location: Reston, VA
Posts: 3,722
JesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond repute
Re: Javascript Robots!

Quote:
Originally Posted by michaelwm View Post
Have an intuitive software design
  • We based our JS design off of the DOM webdesign convention. Driving a motor in JS is as simple as
    Code:
    robot.talon.port3.set(1);
    (Subject to change as we refine our programming model)
  • Aside from being interpreted in real time, JS is the most common language taught in high school programming courses. If you ever want new programmers, an intuitive design based on what students already know (DOM) will attract new programmers like crazy.
If you're talking about intuitive design, Talon's don't have 3 ports - PWMs do. It'd get particularly sticky if you had to do Talon SR vs SRX vs SP. I'd recommend doing robot.pwm.port3.set(1), then at instantiation determine what port 3 actually is and make sure that object has a set() method.
  #21   Spotlight this post!  
Unread 16-04-2015, 11:27
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 544
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Javascript Robots!

Quote:
Originally Posted by JesseK View Post
If you're talking about intuitive design, Talon's don't have 3 ports - PWMs do. It'd get particularly sticky if you had to do Talon SR vs SRX vs SP. I'd recommend doing robot.pwm.port3.set(1), then at instantiation determine what port 3 actually is and make sure that object has a set() method.
I don't know if the roboRIO does this but I know you couldn't with the sidecar because jaguars and talons/victors took different PWM wavelengths. The most intuitive would be something like this

Code:
robot.elevatorMotor = robot.pwm.port3
or, if you have to

Code:
robot.elevatorMotor = HAL.getMotor(3)
  #22   Spotlight this post!  
Unread 16-04-2015, 12:00
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,102
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Javascript Robots!

Quote:
Originally Posted by Arhowk View Post
I don't know if the roboRIO does this but I know you couldn't with the sidecar because jaguars and talons/victors took different PWM wavelengths. The most intuitive would be something like this

Code:
robot.elevatorMotor = robot.pwm.port3
or, if you have to

Code:
robot.elevatorMotor = HAL.getMotor(3)
Correct, there isn't a way for the program to determine which type of PWM device is attached to it, so if you were to use this notation then the user would need to provide some declarative configuration that indicates what device is at which port.

The robot.pwm.* or robot.port* notation is interesting, but it's probably mostly useful for retrieving objects, instead of actively using them that way. Consider 'robot.arm_motor.set()' vs 'robot.pwm.port2.set()' -- if you ever change what port your arm motor is attached to, then you'll have to change it everywhere in code if you use the second notation everywhere.

However, it could be a more useful way to create these objects. Maybe something like robot.pwm.port2.createTalon('arm_motor') automatically creates a robot.arm_motor attribute.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #23   Spotlight this post!  
Unread 16-04-2015, 20:46
bthlx bthlx is offline
Registered User
FRC #3223
 
Join Date: Apr 2015
Location: Silverdale, WA
Posts: 1
bthlx is an unknown quantity at this point
Re: Javascript Robots!

Hi all, I just saw this thread and got super excited.
I've been wanting a JS alternative since I started doing FRC 3 years ago.
I was thinking it'd be fairly straightforward to implement RobotJS as a node add-on, but going with the v8 engine directly may be better. I was thinking it would be nice to use the built nide modules like fs if necessary so that was my attraction to the add-on route.
As far as syntax, couldn't you do something like:

var wpilib = require('wpilib');

var robot = new wpilib.IterativeRobot();

...

robot.liftMotor=new wpilib.Talon(1);

which is a very nodejs idiom.

Thoughts?
  #24   Spotlight this post!  
Unread 17-04-2015, 20:24
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: 24
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 bthlx View Post
Hi all, I just saw this thread and got super excited.
I've been wanting a JS alternative since I started doing FRC 3 years ago.
I was thinking it'd be fairly straightforward to implement RobotJS as a node add-on, but going with the v8 engine directly may be better. I was thinking it would be nice to use the built nide modules like fs if necessary so that was my attraction to the add-on route.
As far as syntax, couldn't you do something like:

var wpilib = require('wpilib');

var robot = new wpilib.IterativeRobot();

...

robot.liftMotor=new wpilib.Talon(1);

which is a very nodejs idiom.

Thoughts?
There are 2 way's to go about this problem, a solution similar to Node, and a solution similar to DOM. Whichever way you choose, it shouldn't matter at all performance wise. We chose DOM, because the majority of new programmers are very familiar with DOM. If your programming team is more familiar with Node / classic programming markup, then your method is definitely better.

The great thing about using v8 directly instead of Node is that you get to choose your syntax and the way your programming team scripts it's robot. Go nuts!
__________________
Integrated Systems
  #25   Spotlight this post!  
Unread 13-01-2016, 00:21
duane's Avatar
duane duane is offline
Registered User
FRC #0701 (RoboVikes)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2003
Location: Vacaville
Posts: 100
duane is an unknown quantity at this point
Send a message via AIM to duane
Re: Javascript Robots!

Resurrecting an old thread.

Did anything come of this project? I'd be interested in helping or taking a look at how it turned out.
__________________
Duane Murphy
Mentor - Software
Vanden Vikings FIRST Team 701
http://www.vandenrobotics.com
  #26   Spotlight this post!  
Unread 13-01-2016, 10:21
Jaci's Avatar
Jaci Jaci is offline
Registered User
AKA: Jaci R Brunning
FRC #5333 (Can't C# | OpenRIO)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Perth, Western Australia
Posts: 266
Jaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond repute
Re: Javascript Robots!

Toast has support for the Oracle Nashorn JS engine, which integrates directly with the JVM. https://github.com/Open-RIO/ToastAPI

You can write your robot program in .js files and we provide some common hooks to things like motors, logging and other stuff
__________________
Jacinta R

Curtin FRC (5333+5663) : Mentor
5333 : Former [Captain | Programmer | Driver], Now Mentor
OpenRIO : Owner

Website | Twitter | Github
jaci.brunning@gmail.com
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:53.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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