Skip to content

team4909/NodeJS-Robot-Environment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeJS-Robot-Environment

A NodeJS-based JavaScript environment for FRC Robotics

The goal here is to play with writing JavaScript code to control robots. The concept, as currently implemented, is that the robot runs the Java environment, including a remote procedure call server (example) that runs with the assistance of the Rhino JavaScript engine, and has full interactivity with the Java environment of WPILIB. A JavaScript client running with NodeJS, then, can, with little up-front work, instantiate a JavaScript class that mirrors the Java class, and manipulate the robot remotely.

Here is a simple example, written prior to operating in the robot environment so using plain Java objects, that demonstrates the concept. This is client code, running in NodeJS, communicating with a server running in Rhino:

async function main()
{
  let             javaCallClient = require("./JavaCallClient")();
  let             javaInterface = new require("./Java")(javaCallClient);

  // Import the Java classes we will want to use
  await javaInterface.import("java.io.File");

  // Instantiate the newly-imported class
  let file = new java.io.File("x.y");

  // Call a method on that class, awaiting its result.
  console.log("file.exists=", await file.exists());
}

main();

See the wiki for design goals and early (pre-implementation) discussion on this topic.

About

A NodeJS-based environment for FRC Robotics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published