ros-typescript-generator is a Command Line Interface (CLI) tool designed to generate TypeScript interfaces and enums directly from ROS (Robot Operating System) message (`.msg`), service (`.srv`), and action (`.action`) definition files. Currently at version 1.10.0, this package sees active development with several minor releases annually, often introducing new features and bug fixes. A key differentiator is its focus on generating pure TypeScript types without any runtime dependencies or classes in the output, making it an ideal choice for frontend applications or any project requiring only type definitions. It supports both ROS1 and ROS2 message formats and offers configurable output options like type prefixes, namespaces, and 'smart enums', setting it apart from alternatives that might include Node.js-specific runtime components.
npm install ros-typescript-generatorVerified import paths — ran on the pinned version, not inferred.
Demonstrates the typical CLI usage by providing a sample configuration file and the command to run the generator, along with a brief illustration of using the resulting TypeScript types.
Existing code consuming generated service types from versions prior to 1.8.0 must be updated. For instance, `MyService` will now expose `MyService.Request` and `MyService.Response` for its respective components.
Carefully verify that all `path` entries in `ros-ts-generator-config.json` are correct absolute paths or paths relative to the config file, and that the CLI has necessary read permissions for these directories.
If the generated enums are not as expected, either disable `smartEnums` in your configuration (`"smartEnums": false`) or refine the constant definitions in your `.msg` files to be more distinct for better inference.
Always ensure your configuration includes `"rosVersion": 1` or `"rosVersion": 2` to specify the target ROS environment.
Double-check the `path` values in your configuration file. Ensure they are correct, absolute paths to existing ROS share directories, and that you have read permissions.
Verify that the `ros-ts-generator-config.json` file exists at the specified location and that the `--config` flag includes the correct full path and filename, e.g., `npx ros-typescript-generator --config ./ros-ts-generator-config.json`.
Correct the `rosVersion` entry in your configuration file to either `1` for ROS1 or `2` for ROS2.