Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Foxglove schemas and generate ros/proto/jsonschema definitions #14

Merged
merged 31 commits into from
May 6, 2022

Conversation

jtbandes
Copy link
Member

@jtbandes jtbandes commented Apr 26, 2022

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
  • generate TypeScript definitions for Node Playground
  • export TypeScript definitions from index.d.ts?
  • generate .msg for ROS 2
  • array lengths for matrices?
  • add other types

Closes https://github.com/foxglove/studio/issues/3043


message Duration {
fixed32 sec = 1;
fixed32 nsec = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think nsec is suppose to be unsigned.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, indeed that is what ROS does. How does one handle negative durations? is -1.5sec equal to {sec:-2,nsec:0.5e9} or {sec:-1,nsec:0.5e9}?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{sec:-1,nsec:0.5e9}

The sign of seconds is what matters. The nanoseconds bit is how many nanoseconds within the second.

Copy link
Member Author

@jtbandes jtbandes Apr 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure?

In ROS 1, both are signed for Duration:
https://github.com/ros/roscpp_core/blob/noetic-devel/rostime/include/ros/duration.h#L75

while both are unsigned for Time:
https://github.com/ros/roscpp_core/blob/noetic-devel/rostime/include/ros/time.h#L133

See also:
https://github.com/ros/roscpp_core/blob/eabafec8f9b554d5389a1aa1b3c8145c07faaefb/rostime/src/duration.cpp#L47-L55

ros2/rclcpp#1188

...ok, after a lot of digging, I finally found a direct example, in which they show that -0.5sec is represented in the .msg as {sec:-1, nsec:500000000} (which means that because it's unsigned, the nsec part is always treated as an offset in the positive direction):

https://github.com/ros2/rclcpp/blob/82ddd441405a5122f1a2e445840cc2b93d713166/rclcpp/test/rclcpp/test_duration.cpp#L234-L238

@amacneil
Copy link
Contributor

amacneil commented May 6, 2022

Curious why proto has a foxglove subdirectory and the others do not?

@jtbandes
Copy link
Member Author

jtbandes commented May 6, 2022

Curious why proto has a foxglove subdirectory and the others do not?

protoc --proto_path works like -I for compiling C/C++ code. If you want the imports to look like import "foxglove/X.proto"; then it needs to have a foxglove subdirectory.

package foxglove;

// List of fields included for every entity in an accompanying `data` field array
message DataField {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PackedField?
StrideField?

@jtbandes jtbandes marked this pull request as ready for review May 6, 2022 22:07
@jtbandes jtbandes merged commit bc7fb3e into main May 6, 2022
@jtbandes jtbandes deleted the jacob/gen-defs branch May 6, 2022 23:12
{
"$comment": "Generated from Grid by @foxglove/message-schemas",
"title": "Grid",
"description": "A 2D grid of data",
Copy link
Contributor

@esthersweon esthersweon May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this also be displayed in 3D space? (i.e in 3D mode for 3D panel)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the grid itself is 2D

{
"$comment": "Generated from LaserScan by @foxglove/message-schemas",
"title": "LaserScan",
"description": "A a single scan from a planar laser range-finder",
Copy link
Contributor

@esthersweon esthersweon May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#typo - remove duplicate "a"

Is the "single" necessary?

{
"$comment": "Generated from PointsAnnotation by @foxglove/message-schemas",
"title": "PointsAnnotation",
"description": "A set of points",
Copy link
Contributor

@esthersweon esthersweon May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"An array of points to annotate a 2D image"?

Using consistent "An array of ..." prefix where necessary.

{
"$comment": "Generated from Pose by @foxglove/message-schemas",
"title": "Pose",
"description": "The position and orientation of an object or reference frame in 3D space",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"A position and orientation for an object or..."

{
"$comment": "Generated from Quaternion by @foxglove/message-schemas",
"title": "Quaternion",
"description": "A [quaternion](https://eater.net/quaternions) representing a rotation in 3D space",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"A rotation in 3D space."

Link and sentence structure is inconsistent with other descriptions. Not sure link is necessary with definition and schema below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the link is useful to have somewhere in the docs? Otherwise people who don't know what quaternions are have to google it themselves, which may not turn up easily understandable resources.

jtbandes added a commit that referenced this pull request May 17, 2022
**Public-Facing Changes**
Updated descriptions for several schemas.


**Description**
Clean up from review of #14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants