Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Javascript Robots! (http://www.chiefdelphi.com/forums/showthread.php?t=136457)

weaversam8 07-04-2015 20:52

Javascript Robots!
 
I develop full stack Node.JS professionally, and I've seen the power in Javascript. Would anyone be open to building a collaborative framework for the RoboRIO to code in Javascript?

Seems rather promising to me...

g_sawchuk 07-04-2015 20:57

Re: Javascript Robots!
 
And I thought this was going to be #teamjavascript
Oh thank you Kamen.

nickbrickmaster 07-04-2015 21:25

Re: Javascript Robots!
 
It wouldn't be that hard if you built it on top of Java's Nashorn interpreter. Summer project?

virtuald 08-04-2015 00:15

Re: Javascript Robots!
 
Quote:

Originally Posted by weaversam8 (Post 1467447)
I develop full stack Node.JS professionally, and I've seen the power in Javascript. Would anyone be open to building a collaborative framework for the RoboRIO to code in Javascript?

Seems rather promising to me...

I've definitely considered doing it, and would love to see someone do it.

RobotPy (the python port) is pure python this year, only interfacing to the robot at the HAL layer. If you're going to do this, I would highly recommend going that route instead of trying to write bindings for WPILib. Expect to spend 2 months of effort translating WPILib into Javascript if you want to do a full port. We did C++-based bindings for a number of years, but having everything be pure python (or js) means you can run the actual robot code on your laptop, which is great for testing + simulation.

There's a lot you can learn by looking at how RobotPy is implemented -- and if you implement HAL the same way we did, then you can use our HTML/JS simulator interface (not quite ready, but almost there)!

If you want to write a robot dashboard in HTML/JS, we've got that covered.

Jacob4564 08-04-2015 07:37

Re: Javascript Robots!
 
It's not entirely implausible, we built our own version of java script to use in autonomous coding.

weaversam8 08-04-2015 07:53

Interesting. Ill definitely look into the HAL interfacing, since Node is extremely capable.

connor.worley 08-04-2015 13:54

Re: Javascript Robots!
 
By all means, go for it, but I wouldn't use it.

From: http://nodeguide.com/convincing_the_boss.html

Quote:

But please be careful here, since JavaScript is a dynamic / garbage collected language, your response times may sometimes vary depending on how often and long the garbage collection kicks in (at which point your program is stopped). So don't try to build hard realtime systems in node, that require consistent response times. Erlang is probably a better choice for these kinds of applications.

virtuald 08-04-2015 14:23

Re: Javascript Robots!
 
Quote:

Originally Posted by connor.worley (Post 1467747)
By all means, go for it, but I wouldn't use it.

From: http://nodeguide.com/convincing_the_boss.html

Python has similar issues, and it works just fine for what most FRC teams create. Java has potentially similar GC issues.

AlexanderTheOK 08-04-2015 14:57

Re: Javascript Robots!
 
Quote:

Originally Posted by virtuald (Post 1467758)
Python has similar issues, and it works just fine for what most FRC teams create. Java has potentially similar GC issues.

That explains the 250ms lag spikes I've been seeing every once in a while. Any standard way to mitigate this?

Jonathan Norris 08-04-2015 15:38

Re: Javascript Robots!
 
Quote:

Originally Posted by connor.worley (Post 1467747)
By all means, go for it, but I wouldn't use it.

From: http://nodeguide.com/convincing_the_boss.html

Java has the same garbage collection issues, and it seems to me that most teams use it... If that's a concern teams should be using C++.

I'd be willing to help out, I write Node/JS every day (in addition to Java/Objective-C), the event'ed/streams Javascript model could be really useful for robot programing.

weaversam8 08-04-2015 16:19

Quote:

Originally Posted by Jonathan Norris (Post 1467792)
Java has the same garbage collection issues, and it seems to me that most teams use it... If that's a concern teams should be using C++.



I'd be willing to help out, I write Node/JS every day (in addition to Java/Objective-C), the event'ed/streams Javascript model could be really useful for robot programing.


Yeah, I'm not concerned with Garbage Collection. It actually really helped with Recycle Rush this year (sorry :) .)

Excellent John, I'd probably set this up as a collaboration-able repo, so I'll definitely contact you if this gets started.

EDIT: Nobody caught the pun? :D

virtuald 08-04-2015 16:39

Re: Javascript Robots!
 
Quote:

Originally Posted by weaversam8 (Post 1467814)
Yeah, I'm not concerned with Garbage Collection. It actually really helped with Recycle Rush this year (sorry :) .)

Excellent John, I'd probably set this up as a collaboration-able repo, so I'll definitely contact you if this gets started.

Setup a github organization. Then you can expand to lots of little projects, instead of just a single repo. :)

Bryan Herbst 08-04-2015 17:04

Re: Javascript Robots!
 
Quote:

Originally Posted by AlexanderTheOK (Post 1467780)
That explains the 250ms lag spikes I've been seeing every once in a while. Any standard way to mitigate this?

Memory management is complicated, so there isn't really a silver bullet you can apply to make it better. To minimize garbage collection, you need to understand why things get garbage collected and why things don't get garbage collected.

Garbage collection generally occurs when Java decides it needs more memory for new allocations. Objects that are no longer referenced are eligible to be collected.

If you feel as though the garbage collector is running too often, it is likely because you are allocating too many objects too frequently. For example, if you have a loop that creates a new instance of an object in every iteration, those objects can pile up quickly.

SoftwareBug2.0 09-04-2015 02:12

Re: Javascript Robots!
 
Quote:

Originally Posted by AlexanderTheOK (Post 1467780)
That explains the 250ms lag spikes I've been seeing every once in a while. Any standard way to mitigate this?

1) Use a language implementation whose runtime doesn't do garbage collection (this may or may not exist for your language of choice)
2) Use a specially-tuned "low latency" garbage collector implementation (you probably need to test that it actually works properly for your application's usage pattern though)
3) Avoid heap allocation (to the extent that you can - just running the required libraries may produce a considerable amount of garbage, you'd need to check this)

You might also consider manually triggering a collection frequently so that less work is done each time it runs. For example, you could have it so that every time the robot got a packet from the driver station it would run an iteration of the control code and then do a GC. You would have to see how long the pause is to see if that would be acceptable.

gixxy 13-04-2015 11:21

Re: Javascript Robots!
 
I AM GAME! I would love to run a Node.js application on the roboRIO and use our DriverStation.js (Node-Webkit) DS with it. (once we get the 2015 protocol unearthed...).


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

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