Skip to content
This repository was archived by the owner on Jan 8, 2025. It is now read-only.
/ ros1 Public archive

Standalone TypeScript implementation of the ROS 1 protocol with a pluggable transport layer

License

Notifications You must be signed in to change notification settings

foxglove/ros1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

406d210 · Jan 8, 2025

History

81 Commits
Feb 28, 2023
Jul 15, 2021
Apr 25, 2022
Oct 5, 2023
Nov 8, 2021
Jul 15, 2021
Jul 15, 2021
Jul 15, 2021
Jan 8, 2025
Aug 16, 2021
Jul 15, 2021
Jul 21, 2021
Oct 5, 2023
Jul 21, 2021
Jul 15, 2021
Feb 28, 2023

Repository files navigation

@foxglove/ros1

Important

This package has moved to https://github.com/foxglove/ros-typescript.

Standalone TypeScript implementation of the ROS 1 (Robot Operating System) protocol with a pluggable transport layer

npm version

Usage

// An example client that connects to the ROS1 turtlesim node

import { RosNode } from "@foxglove/ros1";
import { getEnvVar, getHostname, getNetworkInterfaces, getPid, TcpSocketNode } from "@foxglove/ros1/nodejs";
import { HttpServerNodejs } from "@foxglove/xmlrpc/nodejs";

async function main() {
  const name = "/testclient";
  let rosNode: RosNode | undefined;

  try {
    rosNode = new RosNode({
      name,
      rosMasterUri: getEnvVar("ROS_MASTER_URI") ?? "http://localhost:11311/",
      hostname: RosNode.GetRosHostname(getEnvVar, getHostname, getNetworkInterfaces),
      pid: getPid(),
      httpServer: new HttpServerNodejs(),
      tcpSocketCreate: TcpSocketNode.Create,
      log: console,
    });

    await rosNode.start();

    const params = await rosNode.subscribeAllParams();
    console.dir(params);

    const sub = rosNode.subscribe({
      topic: "/turtle1/color_sensor",
      dataType: "turtlesim/Color",
    });

    sub.on("message", (msg, data, pub) => {
      console.log(
        `[MSG] ${JSON.stringify(msg)} (${
          data.byteLength
        } bytes from ${pub.connection.getTransportInfo()})`,
      );
    });

    await new Promise((resolve) => setTimeout(resolve, 1000));

    console.dir(sub.getStats());
  } catch (err) {
    const msg = (err as Error).stack ?? `${err}`;
    console.error(msg);
  } finally {
    rosNode?.shutdown();
  }
}

void main();

Test

yarn test

License

@foxglove/ros1 is licensed under the MIT License.

Releasing

  1. Run yarn version --[major|minor|patch] to bump version
  2. Run git push && git push --tags to push new tag
  3. GitHub Actions will take care of the rest

Stay in touch

Join our Slack channel to ask questions, share feedback, and stay up to date on what our team is working on.