diff --git a/.gitattributes b/.gitattributes index f7783e5879..9a4b58178b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,3 +8,6 @@ python/mcap-ros1-support/mcap_ros1/vendor/** linguist-vendored=true cpp/examples/protobuf/proto/** linguist-vendored=true linguist-generated=true *.csv linguist-generated=true testdata/db3/eloquent-twist.db3 filter=lfs diff=lfs merge=lfs -text +typescript/examples/flatbuffer/output/** linguist-generated=true +typescript/examples/flatbuffer/bin/FrameTransform.bfbs filter=lfs diff=lfs merge=lfs -text +typescript/examples/flatbuffer/bin/Grid.bfbs filter=lfs diff=lfs merge=lfs -text diff --git a/cspell.config.yaml b/cspell.config.yaml index 144fe7ec04..5ad7d123a6 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -33,6 +33,7 @@ ignorePaths: words: - bagfile + - bfbs - callerid - cbor - cmake @@ -42,7 +43,9 @@ words: - datetime - deserialization - distro + - elems - flatbuffer + - flatbuffers - flatc - fwrite - gendeps diff --git a/typescript/examples/basicwriter/package.json b/typescript/examples/basicwriter/package.json index a477435ed1..6c344dd3d6 100644 --- a/typescript/examples/basicwriter/package.json +++ b/typescript/examples/basicwriter/package.json @@ -21,35 +21,16 @@ }, "devDependencies": { "@foxglove/eslint-plugin": "0.17.1", - "@foxglove/rosbag": "0.1.2", - "@foxglove/rosmsg": "3.0.0", - "@foxglove/rosmsg-serialization": "1.2.3", - "@foxglove/rosmsg2-serialization": "1.0.4", - "@foxglove/tsconfig": "1.1.0", - "@foxglove/wasm-bz2": "^0.0.4", "@mcap/core": "*", - "@types/jest": "27.0.3", - "@types/lodash": "4.14.176", "@types/node": "16.11.9", - "@typescript-eslint/eslint-plugin": "5.4.0", - "@typescript-eslint/parser": "5.4.0", - "commander": "8.3.0", "eslint": "7.32.0", "eslint-config-prettier": "8.3.0", "eslint-plugin-es": "4.1.0", "eslint-plugin-filenames": "1.3.2", "eslint-plugin-import": "2.25.3", - "eslint-plugin-jest": "25.2.4", "eslint-plugin-prettier": "4.0.0", - "jest": "27.3.1", - "lodash": "4.17.21", "prettier": "2.4.1", - "protobufjs": "6.11.2", - "ts-jest": "27.0.7", "ts-node": "10.4.0", - "tsconfig-paths": "3.12.0", - "typescript": "4.4.4", - "wasm-lz4": "2.0.0", - "zstd-codec": "^0.1.4" + "typescript": "4.4.4" } } diff --git a/typescript/examples/flatbuffer/bin/FrameTransform.bfbs b/typescript/examples/flatbuffer/bin/FrameTransform.bfbs new file mode 100644 index 0000000000..d51b2e4684 --- /dev/null +++ b/typescript/examples/flatbuffer/bin/FrameTransform.bfbs @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:620ab0e3a0b6551c1d3936de4cfc5c3a0c834f0a0517eb9b88947f2bbb120a27 +size 1432 diff --git a/typescript/examples/flatbuffer/bin/Grid.bfbs b/typescript/examples/flatbuffer/bin/Grid.bfbs new file mode 100644 index 0000000000..bc6bc166f3 --- /dev/null +++ b/typescript/examples/flatbuffer/bin/Grid.bfbs @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b163dcc8a85f2a3bd40e02cef0c3f57b0dc833c6fe736be04b79245239f6fc0f +size 2912 diff --git a/typescript/examples/flatbuffer/output/FrameTransform_generated.ts b/typescript/examples/flatbuffer/output/FrameTransform_generated.ts new file mode 100644 index 0000000000..6829edbc80 --- /dev/null +++ b/typescript/examples/flatbuffer/output/FrameTransform_generated.ts @@ -0,0 +1,6 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { FrameTransform } from './foxglove/frame-transform'; +export { Quaternion } from './foxglove/quaternion'; +export { Time } from './foxglove/time'; +export { Vector3 } from './foxglove/vector3'; diff --git a/typescript/examples/flatbuffer/output/Grid_generated.ts b/typescript/examples/flatbuffer/output/Grid_generated.ts new file mode 100644 index 0000000000..3eeeaa936e --- /dev/null +++ b/typescript/examples/flatbuffer/output/Grid_generated.ts @@ -0,0 +1,7 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { Grid } from './foxglove/grid'; +export { PackedElementField } from './foxglove/packed-element-field'; +export { Pose } from './foxglove/pose'; +export { Time } from './foxglove/time'; +export { Vector2 } from './foxglove/vector2'; diff --git a/typescript/examples/flatbuffer/output/foxglove/frame-transform.ts b/typescript/examples/flatbuffer/output/foxglove/frame-transform.ts new file mode 100644 index 0000000000..fbcb81cd62 --- /dev/null +++ b/typescript/examples/flatbuffer/output/foxglove/frame-transform.ts @@ -0,0 +1,112 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { Quaternion } from '../foxglove/quaternion'; +import { Time } from '../foxglove/time'; +import { Vector3 } from '../foxglove/vector3'; + + +/** + * A transform between two reference frames in 3D space + */ +export class FrameTransform { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):FrameTransform { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsFrameTransform(bb:flatbuffers.ByteBuffer, obj?:FrameTransform):FrameTransform { + return (obj || new FrameTransform()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsFrameTransform(bb:flatbuffers.ByteBuffer, obj?:FrameTransform):FrameTransform { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new FrameTransform()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * Timestamp of transform + */ +timestamp(obj?:Time):Time|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? (obj || new Time()).__init(this.bb_pos + offset, this.bb!) : null; +} + +/** + * Name of the parent frame + */ +parentFrameId():string|null +parentFrameId(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +parentFrameId(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +/** + * Name of the child frame + */ +childFrameId():string|null +childFrameId(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +childFrameId(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +/** + * Translation component of the transform + */ +translation(obj?:Vector3):Vector3|null { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? (obj || new Vector3()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +/** + * Rotation component of the transform + */ +rotation(obj?:Quaternion):Quaternion|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? (obj || new Quaternion()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +static startFrameTransform(builder:flatbuffers.Builder) { + builder.startObject(5); +} + +static addTimestamp(builder:flatbuffers.Builder, timestampOffset:flatbuffers.Offset) { + builder.addFieldStruct(0, timestampOffset, 0); +} + +static addParentFrameId(builder:flatbuffers.Builder, parentFrameIdOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, parentFrameIdOffset, 0); +} + +static addChildFrameId(builder:flatbuffers.Builder, childFrameIdOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, childFrameIdOffset, 0); +} + +static addTranslation(builder:flatbuffers.Builder, translationOffset:flatbuffers.Offset) { + builder.addFieldOffset(3, translationOffset, 0); +} + +static addRotation(builder:flatbuffers.Builder, rotationOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, rotationOffset, 0); +} + +static endFrameTransform(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishFrameTransformBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedFrameTransformBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +} diff --git a/typescript/examples/flatbuffer/output/foxglove/grid.ts b/typescript/examples/flatbuffer/output/foxglove/grid.ts new file mode 100644 index 0000000000..88ac2b981a --- /dev/null +++ b/typescript/examples/flatbuffer/output/foxglove/grid.ts @@ -0,0 +1,198 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { PackedElementField } from '../foxglove/packed-element-field'; +import { Pose } from '../foxglove/pose'; +import { Time } from '../foxglove/time'; +import { Vector2 } from '../foxglove/vector2'; + + +/** + * A 2D grid of data + */ +export class Grid { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Grid { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsGrid(bb:flatbuffers.ByteBuffer, obj?:Grid):Grid { + return (obj || new Grid()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsGrid(bb:flatbuffers.ByteBuffer, obj?:Grid):Grid { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Grid()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * Timestamp of grid + */ +timestamp(obj?:Time):Time|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? (obj || new Time()).__init(this.bb_pos + offset, this.bb!) : null; +} + +/** + * Frame of reference + */ +frameId():string|null +frameId(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +frameId(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +/** + * Origin of grid's corner relative to frame of reference; grid is positioned in the x-y plane relative to this origin + */ +pose(obj?:Pose):Pose|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? (obj || new Pose()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +/** + * Number of grid columns + */ +columnCount():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +/** + * Size of single grid cell along x and y axes, relative to `pose` + */ +cellSize(obj?:Vector2):Vector2|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? (obj || new Vector2()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +/** + * Number of bytes between rows in `data` + */ +rowStride():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +/** + * Number of bytes between cells within a row in `data` + */ +cellStride():number { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +/** + * Fields in `data` + */ +fields(index: number, obj?:PackedElementField):PackedElementField|null { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? (obj || new PackedElementField()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; +} + +fieldsLength():number { + const offset = this.bb!.__offset(this.bb_pos, 18); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +/** + * Grid cell data, interpreted using `fields`, in row-major (y-major) order + */ +data(index: number):number|null { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; +} + +dataLength():number { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +} + +dataArray():Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 20); + return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; +} + +static startGrid(builder:flatbuffers.Builder) { + builder.startObject(9); +} + +static addTimestamp(builder:flatbuffers.Builder, timestampOffset:flatbuffers.Offset) { + builder.addFieldStruct(0, timestampOffset, 0); +} + +static addFrameId(builder:flatbuffers.Builder, frameIdOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, frameIdOffset, 0); +} + +static addPose(builder:flatbuffers.Builder, poseOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, poseOffset, 0); +} + +static addColumnCount(builder:flatbuffers.Builder, columnCount:number) { + builder.addFieldInt32(3, columnCount, 0); +} + +static addCellSize(builder:flatbuffers.Builder, cellSizeOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, cellSizeOffset, 0); +} + +static addRowStride(builder:flatbuffers.Builder, rowStride:number) { + builder.addFieldInt32(5, rowStride, 0); +} + +static addCellStride(builder:flatbuffers.Builder, cellStride:number) { + builder.addFieldInt32(6, cellStride, 0); +} + +static addFields(builder:flatbuffers.Builder, fieldsOffset:flatbuffers.Offset) { + builder.addFieldOffset(7, fieldsOffset, 0); +} + +static createFieldsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]!); + } + return builder.endVector(); +} + +static startFieldsVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +} + +static addData(builder:flatbuffers.Builder, dataOffset:flatbuffers.Offset) { + builder.addFieldOffset(8, dataOffset, 0); +} + +static createDataVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]!); + } + return builder.endVector(); +} + +static startDataVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(1, numElems, 1); +} + +static endGrid(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishGridBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedGridBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +} diff --git a/typescript/examples/flatbuffer/output/foxglove/numeric-type.ts b/typescript/examples/flatbuffer/output/foxglove/numeric-type.ts new file mode 100644 index 0000000000..2ba0e950b4 --- /dev/null +++ b/typescript/examples/flatbuffer/output/foxglove/numeric-type.ts @@ -0,0 +1,16 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * Numeric type + */ +export enum NumericType { + UNKNOWN = 0, + UINT8 = 1, + INT8 = 2, + UINT16 = 3, + INT16 = 4, + UINT32 = 5, + INT32 = 6, + FLOAT32 = 7, + FLOAT64 = 8 +} diff --git a/typescript/examples/flatbuffer/output/foxglove/packed-element-field.ts b/typescript/examples/flatbuffer/output/foxglove/packed-element-field.ts new file mode 100644 index 0000000000..35f5a746f4 --- /dev/null +++ b/typescript/examples/flatbuffer/output/foxglove/packed-element-field.ts @@ -0,0 +1,91 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { NumericType } from '../foxglove/numeric-type'; + + +/** + * A field present within each element in a byte array of packed elements. + */ +export class PackedElementField { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):PackedElementField { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsPackedElementField(bb:flatbuffers.ByteBuffer, obj?:PackedElementField):PackedElementField { + return (obj || new PackedElementField()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsPackedElementField(bb:flatbuffers.ByteBuffer, obj?:PackedElementField):PackedElementField { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new PackedElementField()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * Name of the field + */ +name():string|null +name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +name(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +/** + * Byte offset from start of data buffer + */ +offset():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + +/** + * Type of data in the field. Integers are stored using little-endian byte order. + */ +type():NumericType { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readUint8(this.bb_pos + offset) : NumericType.UNKNOWN; +} + +static startPackedElementField(builder:flatbuffers.Builder) { + builder.startObject(3); +} + +static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, nameOffset, 0); +} + +static addOffset(builder:flatbuffers.Builder, offset:number) { + builder.addFieldInt32(1, offset, 0); +} + +static addType(builder:flatbuffers.Builder, type:NumericType) { + builder.addFieldInt8(2, type, NumericType.UNKNOWN); +} + +static endPackedElementField(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishPackedElementFieldBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedPackedElementFieldBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +static createPackedElementField(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, offset:number, type:NumericType):flatbuffers.Offset { + PackedElementField.startPackedElementField(builder); + PackedElementField.addName(builder, nameOffset); + PackedElementField.addOffset(builder, offset); + PackedElementField.addType(builder, type); + return PackedElementField.endPackedElementField(builder); +} +} diff --git a/typescript/examples/flatbuffer/output/foxglove/pose.ts b/typescript/examples/flatbuffer/output/foxglove/pose.ts new file mode 100644 index 0000000000..7294cdb7a4 --- /dev/null +++ b/typescript/examples/flatbuffer/output/foxglove/pose.ts @@ -0,0 +1,71 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +import { Quaternion } from '../foxglove/quaternion'; +import { Vector3 } from '../foxglove/vector3'; + + +/** + * A position and orientation for an object or reference frame in 3D space + */ +export class Pose { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Pose { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsPose(bb:flatbuffers.ByteBuffer, obj?:Pose):Pose { + return (obj || new Pose()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsPose(bb:flatbuffers.ByteBuffer, obj?:Pose):Pose { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Pose()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * Point denoting position in 3D space + */ +position(obj?:Vector3):Vector3|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? (obj || new Vector3()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +/** + * Quaternion denoting orientation in 3D space + */ +orientation(obj?:Quaternion):Quaternion|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? (obj || new Quaternion()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; +} + +static startPose(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addPosition(builder:flatbuffers.Builder, positionOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, positionOffset, 0); +} + +static addOrientation(builder:flatbuffers.Builder, orientationOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, orientationOffset, 0); +} + +static endPose(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishPoseBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedPoseBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +} diff --git a/typescript/examples/flatbuffer/output/foxglove/quaternion.ts b/typescript/examples/flatbuffer/output/foxglove/quaternion.ts new file mode 100644 index 0000000000..033428fae4 --- /dev/null +++ b/typescript/examples/flatbuffer/output/foxglove/quaternion.ts @@ -0,0 +1,101 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +/** + * A [quaternion](https://eater.net/quaternions) representing a rotation in 3D space + */ +export class Quaternion { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Quaternion { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsQuaternion(bb:flatbuffers.ByteBuffer, obj?:Quaternion):Quaternion { + return (obj || new Quaternion()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsQuaternion(bb:flatbuffers.ByteBuffer, obj?:Quaternion):Quaternion { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Quaternion()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * x value + */ +x():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; +} + +/** + * y value + */ +y():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; +} + +/** + * z value + */ +z():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; +} + +/** + * w value + */ +w():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 1.0; +} + +static startQuaternion(builder:flatbuffers.Builder) { + builder.startObject(4); +} + +static addX(builder:flatbuffers.Builder, x:number) { + builder.addFieldFloat64(0, x, 0.0); +} + +static addY(builder:flatbuffers.Builder, y:number) { + builder.addFieldFloat64(1, y, 0.0); +} + +static addZ(builder:flatbuffers.Builder, z:number) { + builder.addFieldFloat64(2, z, 0.0); +} + +static addW(builder:flatbuffers.Builder, w:number) { + builder.addFieldFloat64(3, w, 1.0); +} + +static endQuaternion(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishQuaternionBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedQuaternionBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +static createQuaternion(builder:flatbuffers.Builder, x:number, y:number, z:number, w:number):flatbuffers.Offset { + Quaternion.startQuaternion(builder); + Quaternion.addX(builder, x); + Quaternion.addY(builder, y); + Quaternion.addZ(builder, z); + Quaternion.addW(builder, w); + return Quaternion.endQuaternion(builder); +} +} diff --git a/typescript/examples/flatbuffer/output/foxglove/time.ts b/typescript/examples/flatbuffer/output/foxglove/time.ts new file mode 100644 index 0000000000..0e76903d4c --- /dev/null +++ b/typescript/examples/flatbuffer/output/foxglove/time.ts @@ -0,0 +1,40 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +export class Time { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Time { + this.bb_pos = i; + this.bb = bb; + return this; +} + +/** + * Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z + */ +sec():bigint { + return this.bb!.readUint64(this.bb_pos); +} + +/** + * Nano-second fractions from 0 to 999,999,999 inclusive + */ +nsec():number { + return this.bb!.readUint32(this.bb_pos + 8); +} + +static sizeOf():number { + return 16; +} + +static createTime(builder:flatbuffers.Builder, sec: bigint, nsec: number):flatbuffers.Offset { + builder.prep(8, 16); + builder.pad(4); + builder.writeInt32(nsec); + builder.writeInt64(sec); + return builder.offset(); +} + +} diff --git a/typescript/examples/flatbuffer/output/foxglove/vector2.ts b/typescript/examples/flatbuffer/output/foxglove/vector2.ts new file mode 100644 index 0000000000..c0733d5ed8 --- /dev/null +++ b/typescript/examples/flatbuffer/output/foxglove/vector2.ts @@ -0,0 +1,75 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +/** + * A vector in 2D space that represents a direction only + */ +export class Vector2 { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Vector2 { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsVector2(bb:flatbuffers.ByteBuffer, obj?:Vector2):Vector2 { + return (obj || new Vector2()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsVector2(bb:flatbuffers.ByteBuffer, obj?:Vector2):Vector2 { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Vector2()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * x coordinate length + */ +x():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 1.0; +} + +/** + * y coordinate length + */ +y():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 1.0; +} + +static startVector2(builder:flatbuffers.Builder) { + builder.startObject(2); +} + +static addX(builder:flatbuffers.Builder, x:number) { + builder.addFieldFloat64(0, x, 1.0); +} + +static addY(builder:flatbuffers.Builder, y:number) { + builder.addFieldFloat64(1, y, 1.0); +} + +static endVector2(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishVector2Buffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedVector2Buffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +static createVector2(builder:flatbuffers.Builder, x:number, y:number):flatbuffers.Offset { + Vector2.startVector2(builder); + Vector2.addX(builder, x); + Vector2.addY(builder, y); + return Vector2.endVector2(builder); +} +} diff --git a/typescript/examples/flatbuffer/output/foxglove/vector3.ts b/typescript/examples/flatbuffer/output/foxglove/vector3.ts new file mode 100644 index 0000000000..f2f19fd68d --- /dev/null +++ b/typescript/examples/flatbuffer/output/foxglove/vector3.ts @@ -0,0 +1,88 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +/** + * A vector in 3D space that represents a direction only + */ +export class Vector3 { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):Vector3 { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsVector3(bb:flatbuffers.ByteBuffer, obj?:Vector3):Vector3 { + return (obj || new Vector3()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsVector3(bb:flatbuffers.ByteBuffer, obj?:Vector3):Vector3 { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Vector3()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * x coordinate length + */ +x():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 1.0; +} + +/** + * y coordinate length + */ +y():number { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 1.0; +} + +/** + * z coordinate length + */ +z():number { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 1.0; +} + +static startVector3(builder:flatbuffers.Builder) { + builder.startObject(3); +} + +static addX(builder:flatbuffers.Builder, x:number) { + builder.addFieldFloat64(0, x, 1.0); +} + +static addY(builder:flatbuffers.Builder, y:number) { + builder.addFieldFloat64(1, y, 1.0); +} + +static addZ(builder:flatbuffers.Builder, z:number) { + builder.addFieldFloat64(2, z, 1.0); +} + +static endVector3(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static finishVector3Buffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset); +} + +static finishSizePrefixedVector3Buffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { + builder.finish(offset, undefined, true); +} + +static createVector3(builder:flatbuffers.Builder, x:number, y:number, z:number):flatbuffers.Offset { + Vector3.startVector3(builder); + Vector3.addX(builder, x); + Vector3.addY(builder, y); + Vector3.addZ(builder, z); + return Vector3.endVector3(builder); +} +} diff --git a/typescript/examples/flatbufferswriter/.eslintrc.js b/typescript/examples/flatbufferswriter/.eslintrc.js new file mode 100644 index 0000000000..8eb03eee3d --- /dev/null +++ b/typescript/examples/flatbufferswriter/.eslintrc.js @@ -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" }], + }, +}; diff --git a/typescript/examples/flatbufferswriter/package.json b/typescript/examples/flatbufferswriter/package.json new file mode 100644 index 0000000000..6779537db6 --- /dev/null +++ b/typescript/examples/flatbufferswriter/package.json @@ -0,0 +1,38 @@ +{ + "name": "@foxglove/mcap-example-flatbufferswriter", + "version": "0.0.0", + "private": true, + "description": "Flatbuffer Encoding Example", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/foxglove/mcap.git" + }, + "author": { + "name": "Foxglove Technologies", + "email": "support@foxglove.dev" + }, + "homepage": "https://foxglove.dev/", + "scripts": { + "typecheck": "tsc -p tsconfig.json --noEmit", + "lint:ci": "eslint --report-unused-disable-directives .", + "lint": "eslint --report-unused-disable-directives --fix .", + "main": "ts-node --files --project tsconfig.cjs.json scripts/main.ts" + }, + "devDependencies": { + "@foxglove/eslint-plugin": "0.17.1", + "@foxglove/schemas": "^0.7.1", + "@mcap/core": "*", + "@types/node": "16.11.9", + "eslint": "7.32.0", + "eslint-config-prettier": "8.3.0", + "eslint-plugin-es": "4.1.0", + "eslint-plugin-filenames": "1.3.2", + "eslint-plugin-import": "2.25.3", + "eslint-plugin-prettier": "4.0.0", + "flatbuffers": "^22.10.26", + "prettier": "2.4.1", + "ts-node": "10.4.0", + "typescript": "4.4.4" + } +} diff --git a/typescript/examples/flatbufferswriter/scripts/flatbufferUtils.ts b/typescript/examples/flatbufferswriter/scripts/flatbufferUtils.ts new file mode 100644 index 0000000000..c40a0df850 --- /dev/null +++ b/typescript/examples/flatbufferswriter/scripts/flatbufferUtils.ts @@ -0,0 +1,118 @@ +import { + Grid, + FrameTransform, + Quaternion, + Vector3, + PackedElementField, + Pose, + Vector2, +} from "@foxglove/schemas"; +import { Builder } from "flatbuffers"; + +import { + FrameTransform as FbFrameTransform, + Quaternion as FbQuaternion, + Time as FbTime, + Vector3 as FbVector3, +} from "../../flatbuffer/output/FrameTransform_generated"; +import { + PackedElementField as FbPackedElementField, + Pose as FbPose, + Grid as FbGrid, + Vector2 as FbVector2, +} from "../../flatbuffer/output/Grid_generated"; + +export function buildQuaternion(builder: Builder, quatJson: Quaternion): number { + FbQuaternion.startQuaternion(builder); + FbQuaternion.addX(builder, quatJson.x); + FbQuaternion.addY(builder, quatJson.y); + FbQuaternion.addZ(builder, quatJson.z); + FbQuaternion.addW(builder, quatJson.w); + return FbQuaternion.endQuaternion(builder); +} + +export function buildVector2(builder: Builder, json: Vector2): number { + FbVector2.startVector2(builder); + FbVector2.addX(builder, json.x); + FbVector2.addY(builder, json.y); + return FbVector2.endVector2(builder); +} + +export function buildVector3(builder: Builder, json: Vector3): number { + FbVector3.startVector3(builder); + FbVector3.addX(builder, json.x); + FbVector3.addY(builder, json.y); + FbVector3.addZ(builder, json.z); + return FbVector3.endVector3(builder); +} + +export function buildPose(builder: Builder, json: Pose): number { + const pos = buildVector3(builder, json.position); + const quat = buildQuaternion(builder, json.orientation); + FbPose.startPose(builder); + FbPose.addOrientation(builder, quat); + FbPose.addPosition(builder, pos); + return FbPose.endPose(builder); +} + +export function buildTfMessage(builder: Builder, tfJson: FrameTransform): number { + const parentFrameId = builder.createString(tfJson.parent_frame_id); + const childFrameId = builder.createString(tfJson.child_frame_id); + + const quat = buildQuaternion(builder, tfJson.rotation); + + const vec3 = buildVector3(builder, tfJson.translation); + + FbFrameTransform.startFrameTransform(builder); + FbFrameTransform.addParentFrameId(builder, parentFrameId); + FbFrameTransform.addChildFrameId(builder, childFrameId); + FbFrameTransform.addTranslation(builder, vec3); + FbFrameTransform.addRotation(builder, quat); + FbFrameTransform.addTimestamp( + builder, + FbTime.createTime(builder, BigInt(tfJson.timestamp.sec), tfJson.timestamp.nsec), + ); + + const tf = FbFrameTransform.endFrameTransform(builder); + return tf; +} + +export function buildPackedElementField(builder: Builder, json: PackedElementField): number { + const name = builder.createString(json.name); + FbPackedElementField.startPackedElementField(builder); + FbPackedElementField.addName(builder, name); + FbPackedElementField.addOffset(builder, json.offset); + FbPackedElementField.addType(builder, json.type); + return FbPackedElementField.endPackedElementField(builder); +} + +export function buildGridMessage(builder: Builder, json: Grid): number { + const frameId = builder.createString(json.frame_id); + + const pose = buildPose(builder, json.pose); + + const cellSize = buildVector2(builder, json.cell_size); + const data = FbGrid.createDataVector(builder, json.data); + + const fbFields = []; + for (const field of json.fields) { + fbFields.push(buildPackedElementField(builder, field)); + } + const fieldVector = FbGrid.createFieldsVector(builder, fbFields); + + FbGrid.startGrid(builder); + FbGrid.addTimestamp( + builder, + FbTime.createTime(builder, BigInt(json.timestamp.sec), json.timestamp.nsec), + ); + FbGrid.addFrameId(builder, frameId); + FbGrid.addPose(builder, pose); + FbGrid.addCellSize(builder, cellSize); + FbGrid.addCellStride(builder, json.cell_stride); + FbGrid.addColumnCount(builder, json.column_count); + FbGrid.addRowStride(builder, json.row_stride); + FbGrid.addFields(builder, fieldVector); + FbGrid.addData(builder, data); + + return FbGrid.endGrid(builder); +} diff --git a/typescript/examples/flatbufferswriter/scripts/main.ts b/typescript/examples/flatbufferswriter/scripts/main.ts new file mode 100644 index 0000000000..647c8374c6 --- /dev/null +++ b/typescript/examples/flatbufferswriter/scripts/main.ts @@ -0,0 +1,247 @@ +import { Grid, NumericType } from "@foxglove/schemas"; +import { McapWriter, IWritable } from "@mcap/core"; +import { Builder } from "flatbuffers"; +import fs from "fs"; +import { open, FileHandle } from "fs/promises"; + +import { buildGridMessage, buildTfMessage } from "./flatbufferUtils"; + +const QUAT_IDENTITY = { x: 0, y: 0, z: 0, w: 1 }; + +// Mcap IWritable interface for nodejs FileHandle +class FileHandleWritable implements IWritable { + private handle: FileHandle; + private totalBytesWritten = 0; + + constructor(handle: FileHandle) { + this.handle = handle; + } + + async write(buffer: Uint8Array): Promise { + const written = await this.handle.write(buffer); + this.totalBytesWritten += written.bytesWritten; + } + + position(): bigint { + return BigInt(this.totalBytesWritten); + } +} +function nextPowerOfTwo(numToRound: number) { + let nextPower = 1; + while (nextPower < numToRound) { + nextPower *= 2; + } + return nextPower; +} +const scriptParameters = { + mcapTimeLength: 10000, //ms + gridMessageFrequency: 20, //hz +}; + +const gridParameters = { + cell_size: { x: 0.1, y: 0.1 }, + column_count: 512, + row_count: 512, + cell_stride: 4, + row_stride: 0, +}; + +// set row stride to be next largest power of 2 +gridParameters.row_stride = nextPowerOfTwo( + gridParameters.column_count * gridParameters.cell_stride, +); +console.log(`row stride ${gridParameters.row_stride}`); + +interface GridDataFuncParams { + x: number; + y: number; + i: number; + rows: number; + cols: number; + time: number; +} + +// functions to generate data for a grid message based off of time, placement and grid params +const fieldDataFuncs: { [k: string]: (x: GridDataFuncParams) => number } = { + sinPlusCos: ({ x, y }: GridDataFuncParams): number => { + return Math.sin(y) + Math.cos(x); + }, + sinTimesCos: ({ x, y }: GridDataFuncParams): number => { + return Math.sin(y) * Math.cos(x); + }, + growingSinTanCos: ({ x, y, rows, cols, time }: GridDataFuncParams): number => { + const z = time * 0.0000000001; + return ( + z + + Math.sin(Math.cos(Math.tan((x / cols) * Math.PI + z))) + + Math.sin(Math.cos(Math.tan((y / rows) * Math.PI))) + ); + }, + sinTanCos: ({ x, y, rows, cols, time }: GridDataFuncParams): number => { + return ( + Math.sin(Math.cos(Math.tan((x / cols) * Math.PI + time))) + + Math.sin(Math.cos(Math.tan((y / rows) * Math.PI))) + ); + }, +}; + +function makeNewGrid() { + const { cell_size, cell_stride, column_count, row_count, row_stride } = gridParameters; + + const defaultGrid = { + timestamp: { sec: 0, nsec: 0 }, + frame_id: "sensor", + pose: { + position: { + x: -0.5 * cell_size.x * row_count + 2, + y: -0.5 * cell_size.y * column_count + 2, + z: 0, + }, + orientation: QUAT_IDENTITY, + }, + cell_size, + column_count, + cell_stride, + row_stride, + fields: [{ name: "sinTanCos", offset: 0, type: NumericType.FLOAT32 }], + } as Omit; + + return defaultGrid; +} + +// adds data to the grid based on the grid parameters and fields +function getGridData(grid: Omit, row_count: number, time: number): Uint8Array { + const { column_count, fields, cell_stride, row_stride } = grid; + const data = new Uint8Array(row_stride * row_count); + const view = new DataView(data.buffer, data.byteOffset, data.byteLength); + + for (let y = 0; y < row_count; y++) { + for (let x = 0; x < column_count; x++) { + const i = y * row_stride + x * cell_stride; + for (const field of fields) { + const { name, offset, type } = field; + if (type !== NumericType.FLOAT32) { + throw new Error("unsupported numeric types"); + } + const dataFunc = fieldDataFuncs[name]; + if (dataFunc) { + const value = dataFunc({ + x, + y, + i, + rows: row_count, + cols: column_count, + time, + }); + view.setFloat32(i + offset, value, true); + } else { + throw new Error(`missing data func for field: ${name}`); + } + } + } + } + + return data; +} + +async function main() { + const mcapFilePath = "flatbuffer.mcap"; + const fileHandle = await open(mcapFilePath, "w"); + const fileHandleWritable = new FileHandleWritable(fileHandle); + + const mcapFile = new McapWriter({ + writable: fileHandleWritable, + useStatistics: false, + useChunks: true, + useChunkIndex: true, + }); + + await mcapFile.start({ + profile: "", + library: "mcap example", + }); + const FrameTransformSchemaBuffer = fs.readFileSync( + `${__dirname}/../../flatbuffer/bin/FrameTransform.bfbs`, + ); + const tfSchemaId = await mcapFile.registerSchema({ + name: "foxglove.FrameTransform", + encoding: "flatbuffer", + data: FrameTransformSchemaBuffer, + }); + + const tfChannelId = await mcapFile.registerChannel({ + schemaId: tfSchemaId, + topic: "tf", + messageEncoding: "flatbuffer", + metadata: new Map(), + }); + const tfJson = { + timestamp: { sec: 0, nsec: 0 }, + parent_frame_id: "base_link", + child_frame_id: "sensor", + translation: { x: 0, y: 0, z: 1 }, + rotation: QUAT_IDENTITY, + }; + + const tfBuilder = new Builder(); + const tf = buildTfMessage(tfBuilder, tfJson); + tfBuilder.finish(tf); + + await mcapFile.addMessage({ + channelId: tfChannelId, + sequence: 0, + publishTime: 0n, + logTime: 0n, + data: tfBuilder.asUint8Array(), + }); + + const binaryGridSchema = fs.readFileSync(`${__dirname}/../../flatbuffer/bin/Grid.bfbs`); + + const gridSchemaId = await mcapFile.registerSchema({ + name: "foxglove.Grid", + encoding: "flatbuffer", + data: binaryGridSchema, + }); + + const gridChannelId = await mcapFile.registerChannel({ + schemaId: gridSchemaId, + topic: "grid", + messageEncoding: "flatbuffer", + metadata: new Map(), + }); + + const { mcapTimeLength, gridMessageFrequency } = scriptParameters; + + const msTimeBetweenMessages = (1 / gridMessageFrequency) * 1000; // interval length = (1 / frequency) * 1000 (ms in a second) + let currTime = 0; + const getGridMessageData = (time: number) => { + const grid = makeNewGrid(); + const data = getGridData(grid, gridParameters.row_count, time); + (grid as Grid).data = data; + + const gridBuilder = new Builder(); + const fbGrid = buildGridMessage(gridBuilder, grid as Grid); + gridBuilder.finish(fbGrid); + + return gridBuilder.asUint8Array(); + }; + let count = 0; + while (currTime <= mcapTimeLength) { + console.log(`Adding grid ${count}`); + const nsTime = BigInt(currTime) * 1_000_000n; + const message = getGridMessageData(currTime); + await mcapFile.addMessage({ + channelId: gridChannelId, + sequence: 0, + publishTime: nsTime, + logTime: nsTime, + data: message, + }); + count++; + currTime += msTimeBetweenMessages; + } + + await mcapFile.end(); +} + +void main(); diff --git a/typescript/examples/flatbufferswriter/tsconfig.cjs.json b/typescript/examples/flatbufferswriter/tsconfig.cjs.json new file mode 100644 index 0000000000..ac31cb3343 --- /dev/null +++ b/typescript/examples/flatbufferswriter/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./dist/cjs", + "module": "commonjs" + } +} diff --git a/typescript/examples/flatbufferswriter/tsconfig.json b/typescript/examples/flatbufferswriter/tsconfig.json new file mode 100644 index 0000000000..13b7e779c7 --- /dev/null +++ b/typescript/examples/flatbufferswriter/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "@foxglove/tsconfig/base", + "include": ["./**/*"], + "compilerOptions": { + "noEmit": true, + "rootDir": "../..", + "outDir": "./dist/esm", + "lib": ["es2020", "dom"], + "paths": { + "@mcap/core": ["../../core/src"] + }, + + // required for tsconfig-paths https://github.com/dividab/tsconfig-paths/issues/143 + "baseUrl": "." + }, + "ts-node": { + "require": ["tsconfig-paths/register"] + } +} diff --git a/yarn.lock b/yarn.lock index 8e47492aca..d0060959c0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -654,6 +654,13 @@ "@foxglove/rostime" "^1.1.0" heap "^0.2.6" +"@foxglove/rosmsg-msgs-common@^2.0.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@foxglove/rosmsg-msgs-common/-/rosmsg-msgs-common-2.1.0.tgz#8d348db60dc69670916ca9dc56999abb6de4134f" + integrity sha512-Lxu3CEb+Ko1hrLu1bIqvvoc8DvGW1FAA21sWW0MoTPTgoQ1Rnpke2Z4H6O78C8DwXPzXAqZIisgxfFM9NYiHPA== + dependencies: + "@foxglove/rosmsg" "^3.1.0" + "@foxglove/rosmsg-serialization@1.2.3", "@foxglove/rosmsg-serialization@^1.2.3": version "1.2.3" resolved "https://registry.yarnpkg.com/@foxglove/rosmsg-serialization/-/rosmsg-serialization-1.2.3.tgz#742adc7a322357b0a19aaebb4fe7c2c557f55e92" @@ -677,11 +684,26 @@ dependencies: md5-typescript "^1.0.5" +"@foxglove/rosmsg@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@foxglove/rosmsg/-/rosmsg-3.1.0.tgz#edbe3e2e743a5cc89df8195889a054e639230916" + integrity sha512-uvL3a3PRusrQw4tg91tsXfPMCWjsKV35nAaHkzPqRt4bZRzO2DAUMavCltjRux5Hc8WLPYWt77iUSk3KfxqUZQ== + dependencies: + md5-typescript "^1.0.5" + "@foxglove/rostime@^1.1.0": version "1.1.1" resolved "https://registry.yarnpkg.com/@foxglove/rostime/-/rostime-1.1.1.tgz#6d9ec8e2264d7a44fa5066ce38cafed84d3c657a" integrity sha512-EI+rNLYRcrMHeyRsDuWjyDuTPwu9ZgQIk28RTsTxq1jO2zYFHuBni3TTC78BluS1QZD/iLxUeiGCfJl4eizB9A== +"@foxglove/schemas@^0.7.1": + version "0.7.1" + resolved "https://registry.yarnpkg.com/@foxglove/schemas/-/schemas-0.7.1.tgz#d757152dfcf9c79dce0e26eedcc7c5462df3007e" + integrity sha512-9S6P6F1iZjSgoTzlyrDnzfxs2Mpc+v0fvcPo+JU5XeRiUdvAuohsXk/TR9ju/ZzGIGEhNFYACsu0KiRmtlc9bg== + dependencies: + "@foxglove/rosmsg-msgs-common" "^2.0.0" + tslib "^2" + "@foxglove/tsconfig@1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@foxglove/tsconfig/-/tsconfig-1.1.0.tgz#48c37fffd6f349c3ee08a60fc62ccf636f3b59a6" @@ -2444,6 +2466,11 @@ flat-cache@^3.0.4: flatted "^3.1.0" rimraf "^3.0.2" +flatbuffers@^22.10.26: + version "22.10.26" + resolved "https://registry.yarnpkg.com/flatbuffers/-/flatbuffers-22.10.26.tgz#1b92e9559f5253ca7dc54e2b0eb63d2bcdbe329b" + integrity sha512-sdO3emf/BlLfOogW6KwHuXg16APR/E86jNacDXfSInPzt8SSEzxlHcqDekfM/IJ1CGC5bvDksfNufNhS8h1FRA== + flatted@^3.1.0: version "3.2.4" resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.4.tgz#28d9969ea90661b5134259f312ab6aa7929ac5e2"