1.3.2 • Published 6 months ago

robocol v1.3.2

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

Robocol

Javascript library for interacting with FTC robots

Add to your project: npm install robocol

Current Features:

  • Connect To Robot
  • Parse returned telemetry data
  • Run basic commands including initializing and starting opmodes
  • Send gamepad data
  • Support All Commands (possibility add generic callback?)
  • Work in browser (Not planned, no current way to send UDP packets)

Examples

Log all telemetry data from robot

import { Robot, RobotEvent } from "robocol";

const robot = new Robot();
robot.connect();
robot.on(RobotEvent.TELEMETRY, console.log);

Send gamepad data to robot

import { GamepadMessage, Robot } from "robocol";

const allReleased = {
  left_stick_x: 0,
  left_stick_y: 0,
  right_stick_x: 0,
  right_stick_y: 0,
  dpad_up: false,
  dpad_down: false,
  dpad_left: false,
  dpad_right: false,
  a: false,
  b: false,
  x: false,
  y: false,
  guide: false,
  start: false,
  back: false,
  left_bumper: false,
  right_bumper: false,
  left_stick_button: false,
  right_stick_button: false,
  left_trigger: 0,
  right_trigger: 0,
  updatedAt: 0,
};
const aPressed = { ...allReleased, a: true };

const robot = new Robot();
robot.connect();

// Start pressing A every second after initial 0.5 second delay
setTimeout(() => {
  setInterval(() => {
    robot.send(new GamepadMessage(0, aPressed, 1));
  }, 1000);
}, 500);

// Start releasing A every second in order to alternate
setInterval(() => {
  robot.send(new GamepadMessage(0, allReleased, 1));
}, 1000);

Init and run the first opmode found

import { CommandMessage, Robot, RobotCommand, RobotEvent } from "robocol";

const robot = new Robot();
robot.connect();

robot.on(RobotEvent.OPMODES_LIST, (list) => {
  const firstName = list[0].name;
  robot.send(
    new CommandMessage(
      RobotCommand.CMD_INIT_OP_MODE,
      0,
      false,
      Date.now(),
      firstName
    )
  );
  setTimeout(() => {
    robot.send(
      new CommandMessage(
        RobotCommand.CMD_RUN_OP_MODE,
        0,
        false,
        Date.now(),
        firstName
      )
    );
  }, 500);
});
1.3.2

6 months ago

1.3.1

6 months ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago