-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert lidar and radar point clounds to protobuf foxglove.PointCloud (…
…#9) Uses Protobuf [`foxglove.PointCloud`](https://foxglove.dev/docs/studio/messages/point-cloud) instead of ROS `sensor_msgs/PointCloud2`. The output file is mixed ROS+protobuf, which Foxglove Studio can read without issue.
- Loading branch information
Showing
80 changed files
with
2,961 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
[flake8] | ||
max-line-length = 160 | ||
ignore = E203 | ||
exclude = | ||
foxglove/*pb2.py*, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foxglove/** linguist-vendored linguist-generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,5 @@ | |
.Trash-* | ||
data | ||
.DS_Store | ||
.vscode | ||
__pycache__ | ||
*.mcap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"python.formatting.provider": "black", | ||
"[python]": { | ||
"editor.formatOnSave": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from typing import Any, Dict, Optional | ||
from mcap_protobuf.schema import register_schema | ||
|
||
|
||
class ProtobufWriter: | ||
def __init__(self, output): | ||
self.__writer = output | ||
self.__schema_ids: Dict[str, int] = {} | ||
self.__channel_ids: Dict[str, int] = {} | ||
|
||
def write_message( | ||
self, | ||
topic: str, | ||
message: Any, | ||
log_time: Optional[int] = None, | ||
publish_time: Optional[int] = None, | ||
sequence: int = 0, | ||
): | ||
""" | ||
Writes a message to the MCAP stream, automatically registering schemas and channels as | ||
needed. | ||
@param topic: The topic of the message. | ||
@param message: The message to write. | ||
@param log_time: The time at which the message was logged. | ||
Will default to the current time if not specified. | ||
@param publish_time: The time at which the message was published. | ||
Will default to the current time if not specified. | ||
@param sequence: An optional sequence number. | ||
""" | ||
msg_typename = type(message).DESCRIPTOR.full_name | ||
schema_id = self.__schema_ids.get(msg_typename) | ||
if schema_id is None: | ||
schema_id = register_schema(self.__writer, type(message)) | ||
self.__schema_ids[msg_typename] = schema_id | ||
|
||
channel_id = self.__channel_ids.get(topic) | ||
if channel_id is None: | ||
channel_id = self.__writer.register_channel( | ||
topic=topic, | ||
message_encoding="protobuf", | ||
schema_id=schema_id, | ||
) | ||
self.__channel_ids[topic] = channel_id | ||
|
||
self.__writer.add_message( | ||
channel_id=channel_id, | ||
log_time=log_time, | ||
publish_time=publish_time or log_time, | ||
sequence=sequence, | ||
data=message.SerializeToString(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.