Skip to content

Commit

Permalink
Add Foxglove schemas and generate ros/proto/jsonschema definitions (f…
Browse files Browse the repository at this point in the history
…oxglove#14)

**Public-Facing Changes**
This package is now published on NPM as `@foxglove/message-schemas`, and is the source of truth for message schemas supported by Foxglove Studio, which are documented in https://foxglove.dev/docs/studio/messages/introduction. We also generate ROS 1/2, Protobuf, JSON Schema, and TypeScript definitions from these schemas.

**Description**

The website will be updated to pull schemas from this repository.

- [ ] ~generate FileDescriptorSet for easy use with mcap/websocket~
- [x] generate TypeScript definitions for Node Playground
- [x] export TypeScript definitions from index.d.ts?
- [x] generate .msg for ROS 2
- [x] array lengths for matrices?
- [x] add other types

Closes https://github.com/foxglove/studio/issues/3043
  • Loading branch information
jtbandes authored May 6, 2022
1 parent 571fcb2 commit bc7fb3e
Show file tree
Hide file tree
Showing 387 changed files with 10,464 additions and 8,993 deletions.
19 changes: 19 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-env node */
module.exports = {
env: { es2020: true },
ignorePatterns: ["dist"],
extends: ["plugin:@foxglove/base", "plugin:@foxglove/jest"],
overrides: [
{
files: ["*.ts", "*.tsx"],
extends: ["plugin:@foxglove/typescript"],
parserOptions: {
project: "tsconfig.json",
tsconfigRootDir: __dirname,
},
},
],
rules: {
"no-warning-comments": ["error", { terms: ["fixme"], location: "anywhere" }],
},
};
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
proto/ros/**/*.proto linguist-generated
json-schema/**/*.json linguist-generated
schemas/** linguist-generated
17 changes: 13 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,27 @@ jobs:
cache: yarn

- run: yarn install --immutable
- run: yarn generate:proto
- run: yarn generate:json
- run: yarn lint:ci
- run: yarn typecheck
- run: yarn test
- run: yarn update-generated-files

- name: Ensure generated files are up to date
run: |
changes=$(git status --porcelain)
if [ -n "$changes" ]; then
echo "::error::The following generated files need to be updated:"
echo "::error::The following generated files need to be updated. Run `yarn update-generated-files` to update them."
echo "$changes"
exit 1
else
echo "Generated schemas are up to date!"
fi
- name: Validate protobuf definitions
run: protoc --proto_path=proto proto/**/*.proto --descriptor_set_out=/dev/null
run: protoc --proto_path=schemas/proto schemas/proto/**/*.proto --descriptor_set_out=/dev/null

- name: Publish to NPM
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: yarn publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
schemas
2 changes: 2 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
printWidth: 100
trailingComma: all
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests.v2",
"request": "launch",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"cwd": "${workspaceFolder}",
"runtimeExecutable": "yarn",
"args": [
"test",
"--runInBand",
"--watchAll=false",
"--testNamePattern",
"${jest.testNamePattern}",
"--runTestsByPath",
"${jest.testFile}"
]
}
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.options": {
"reportUnusedDisableDirectives": true
}
},
"jest.jestCommandLine": "yarn test"
}
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
This repo contains Protobuf and JSON schemas for [foxglove](https://foxglove.dev/docs/studio/messages/introduction) and ROS messages.
# @foxglove/message-schemas

> [Message schemas](https://foxglove.dev/docs/studio/messages/introduction) supported by [Foxglove Studio](https://studio.foxglove.dev)
[![npm version](https://img.shields.io/npm/v/@foxglove/message-schemas.svg?style=flat)](https://www.npmjs.com/package/@foxglove/message-schemas)

## Introduction

The [schemas](./schemas) folder contains type definitions generated from these schemas for ROS 1, ROS 2, Protobuf, JSON Schema, and TypeScript.

These schemas can be used in [MCAP](https://github.com/foxglove/mcap) files or [Foxglove WebSocket](https://github.com/foxglove/ws-protocol) servers to take advantage of Foxglove Studio's visualizations.

The ROS schemas are generated from the common ROS message types at [@foxglove/rosmsg-msgs-common](https://github.com/foxglove/rosmsg-msgs-common) and [@foxglove/rosmsg-msgs-foxglove](https://github.com/foxglove/rosmsg-msgs-foxglove).
## License

@foxglove/message-schemas is licensed under [MIT License](https://opensource.org/licenses/MIT).

## Proto
## Development

The .proto schemas are located in the `proto` folder.
The schema definitions are in [src/schemas.ts](src/schemas.ts).

## Generate
After editing the schemas, re-generate the language-specific definitions by running `yarn update-generated-files`.

### Generate .proto files and JSON Schemas for common ROS datatypes
### Releasing

```
$ yarn install
$ yarn generate:proto
$ yarn generate:json
```
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

### Combine .proto files into a binary FileDescriptorSet
## Stay in touch

```
$ protoc --proto_path=proto proto/ros/sensor_msgs/PointCloud2.proto --include_imports --descriptor_set_out=PointCloud2.bin
```
Join our [Slack channel](https://foxglove.dev/join-slack) to ask questions, share feedback, and stay up to date on what our team is working on.
16 changes: 16 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"testMatch": ["<rootDir>/src/**/*.test.ts"],
"transform": {
"^.+\\.ts$": "ts-jest"
},
"globals": {
"ts-jest": {
"diagnostics": {
"//": "add 6133 (unused variables) to default ignore codes",
"ignoreCodes": [6059, 18002, 18003, 6133]
}
}
},
"//": "Native find is slow because it does not exclude files: https://github.com/facebook/jest/pull/11264#issuecomment-825377579",
"haste": { "forceNodeFilesystemAPI": true }
}
21 changes: 0 additions & 21 deletions json-schema/ros/actionlib_msgs/GoalID.json

This file was deleted.

34 changes: 0 additions & 34 deletions json-schema/ros/actionlib_msgs/GoalStatus.json

This file was deleted.

68 changes: 0 additions & 68 deletions json-schema/ros/actionlib_msgs/GoalStatusArray.json

This file was deleted.

68 changes: 0 additions & 68 deletions json-schema/ros/diagnostic_msgs/DiagnosticArray.json

This file was deleted.

34 changes: 0 additions & 34 deletions json-schema/ros/diagnostic_msgs/DiagnosticStatus.json

This file was deleted.

12 changes: 0 additions & 12 deletions json-schema/ros/diagnostic_msgs/KeyValue.json

This file was deleted.

Loading

0 comments on commit bc7fb3e

Please sign in to comment.