Skip to content

Commit

Permalink
feat: add rrd support (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
egorchakov authored Oct 29, 2024
1 parent b9c8457 commit 0319b7a
Show file tree
Hide file tree
Showing 25 changed files with 683 additions and 62 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
---
repos:
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.21
rev: v0.22
hooks:
- id: validate-pyproject

- repo: https://github.com/crate-ci/typos
rev: v1.26.0
rev: v1.26.8
hooks:
- id: typos

- repo: https://github.com/asottile/pyupgrade
rev: v3.18.0
rev: v3.19.0
hooks:
- id: pyupgrade

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
rev: v0.7.1
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/DetachHead/basedpyright-pre-commit-mirror
rev: 1.19.0
rev: 1.19.1
hooks:
- id: basedpyright

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
uv add rbyte [--extra <EXTRA>]
```

See [pyproject.toml](./pyproject.toml) for available extras.
See `pyproject.toml` for available extras.

## [Examples](./examples)
## Examples

1. Install required tools:
- [`uv`](https://github.com/astral-sh/uv)
Expand All @@ -35,7 +35,7 @@ git clone https://github.com/yaak-ai/rbyte
3. Run:
```shell
cd rbyte
just example nuscenes
just notebook examples/nuscenes_mcap.ipynb
```

## Development
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#@ 'nuScenes-v1.0-mini-scene-0061-cut',
#@ ]

#@ camera_topics = [
#@ '/CAM_FRONT/image_rect_compressed',
#@ '/CAM_FRONT_LEFT/image_rect_compressed',
#@ '/CAM_FRONT_RIGHT/image_rect_compressed',
#@ ]
#@ camera_topics = {
#@ 'CAM_FRONT': '/CAM_FRONT/image_rect_compressed',
#@ 'CAM_FRONT_LEFT': '/CAM_FRONT_LEFT/image_rect_compressed',
#@ 'CAM_FRONT_RIGHT': '/CAM_FRONT_RIGHT/image_rect_compressed',
#@ }
---
_target_: rbyte.Dataset
_convert_: all
Expand All @@ -19,8 +19,8 @@ inputs:
#@ for input_id in inputs:
(@=input_id@):
frame:
#@ for topic in camera_topics:
(@=topic@):
#@ for camera, topic in camera_topics.items():
(@=camera@):
index_column: (@=topic@)/_idx_
reader:
_target_: rbyte.io.frame.McapFrameReader
Expand Down Expand Up @@ -49,7 +49,7 @@ inputs:
- rbyte.utils.mcap.JsonDecoderFactory

fields:
#@ for topic in camera_topics:
#@ for topic in camera_topics.values():
(@=topic@):
log_time:
_target_: polars.Datetime
Expand All @@ -68,14 +68,15 @@ inputs:
_target_: rbyte.io.table.TableAligner
separator: "/"
merge:
(@=camera_topics[0]@):
(@=camera_topics.values()[0]@):
log_time:
method: ref

#@ for topic in camera_topics[1:]:
#@ for topic in camera_topics.values()[1:]:
(@=topic@):
log_time:
method: ref

_idx_:
method: asof
tolerance: 40ms
Expand All @@ -96,7 +97,7 @@ inputs:

sample_builder:
_target_: rbyte.sample.builder.GreedySampleTableBuilder
index_column: (@=camera_topics[0]@)/_idx_
index_column: (@=camera_topics.values()[0]@)/_idx_
length: 1
stride: 1
min_step: 1
Expand Down
97 changes: 97 additions & 0 deletions config/_templates/dataset/nuscenes_rrd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#! https://app.rerun.io/examples/nuscenes_dataset.rrd

#@yaml/text-templated-strings

#@ inputs = [
#@ 'nuscenes',
#@ ]

#@ camera_entities = {
#@ 'CAM_FRONT_LEFT': '/world/ego_vehicle/CAM_FRONT_LEFT',
#@ 'CAM_FRONT': '/world/ego_vehicle/CAM_FRONT',
#@ 'CAM_FRONT_RIGHT': '/world/ego_vehicle/CAM_FRONT_RIGHT',
#@ }
---
_target_: rbyte.Dataset
_convert_: all
_recursive_: false
inputs:
#@ for input_id in inputs:
(@=input_id@):
frame:
#@ for camera, entity in camera_entities.items():
(@=camera@):
index_column: (@=entity@)/_idx_
reader:
_target_: rbyte.io.frame.RrdFrameReader
path: "${data_dir}/(@=input_id@).rrd"
index: timestamp
entity_path: (@=entity@)
frame_decoders:
image/jpeg:
_target_: simplejpeg.decode_jpeg
_partial_: true
colorspace: rgb
fastdct: true
fastupsample: true
#@ end

table:
builder:
_target_: rbyte.io.table.TableBuilder
_convert_: all
readers:
- path: "${data_dir}/(@=input_id@).rrd"
reader:
_target_: rbyte.io.table.RrdTableReader
_recursive_: false
index: timestamp
contents:
#@ for entity in camera_entities.values():
(@=entity@):
- _idx_
#@ end

/world/ego_vehicle/LIDAR_TOP:
- Position3D

merger:
_target_: rbyte.io.table.TableAligner
separator: /
merge:
#@ entity = camera_entities.values()[0]
(@=entity@):
timestamp:
method: ref

#@ for entity in camera_entities.values()[1:]:
(@=entity@):
timestamp:
method: ref

_idx_:
method: asof
strategy: nearest
tolerance: 20ms
#@ end

/world/ego_vehicle/LIDAR_TOP:
timestamp:
method: ref

Position3D:
method: asof
strategy: nearest
tolerance: 20ms

filter: |
`/world/ego_vehicle/CAM_FRONT/timestamp` between '2018-07-24 03:28:48' and '2018-07-24 03:28:50'
#@ end

sample_builder:
_target_: rbyte.sample.builder.GreedySampleTableBuilder
index_column: (@=camera_entities.values()[0]@)/_idx_
length: 1
stride: 1
min_step: 1
filter: !!null
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#@yaml/text-templated-strings

#@ camera_topics = {
#@ camera: '/{}/image_rect_compressed'.format(camera)
#@ for camera in ['CAM_FRONT_LEFT', 'CAM_FRONT', 'CAM_FRONT_RIGHT']
#@ 'CAM_FRONT': '/CAM_FRONT/image_rect_compressed',
#@ 'CAM_FRONT_LEFT': '/CAM_FRONT_LEFT/image_rect_compressed',
#@ 'CAM_FRONT_RIGHT': '/CAM_FRONT_RIGHT/image_rect_compressed',
#@ }
---
_target_: rbyte.viz.loggers.RerunLogger
schema:
frame:
#@ for camera_topic in camera_topics.values():
(@=camera_topic@):
#@ for camera in camera_topics.keys():
(@=camera@):
Image:
color_model: RGB
#@ end

table:
#@ camera_topic = camera_topics.values()[0]
(@=camera_topic@)/log_time: TimeNanosColumn
#@ for camera_topic in camera_topics.values():
(@=camera_topic@)/_idx_: TimeSequenceColumn
#@ for topic in camera_topics.values():
(@=topic@)/_idx_: TimeSequenceColumn
(@=topic@)/log_time: TimeNanosColumn
#@ end
/odom/vel.x: Scalar

Expand All @@ -30,10 +30,10 @@ blueprint:
contents:
- _target_: rerun.blueprint.Horizontal
contents:
#@ for camera, camera_topic in camera_topics.items():
#@ for camera in camera_topics.keys():
- _target_: rerun.blueprint.Spatial2DView
name: #@ camera
origin: #@ "frame/{}".format(camera_topic)
origin: #@ "frame/{}".format(camera)
#@ end

- _target_: rerun.blueprint.TimeSeriesView
Expand Down
41 changes: 41 additions & 0 deletions config/_templates/logger/rerun/nuscenes_rrd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#@yaml/text-templated-strings

#@ camera_entities = {
#@ "CAM_FRONT_LEFT": "/world/ego_vehicle/CAM_FRONT_LEFT",
#@ "CAM_FRONT": "/world/ego_vehicle/CAM_FRONT",
#@ "CAM_FRONT_RIGHT": "/world/ego_vehicle/CAM_FRONT_RIGHT",
#@ }
---
_target_: rbyte.viz.loggers.RerunLogger
schema:
frame:
#@ for camera in camera_entities.keys():
(@=camera@):
Image:
color_model: RGB
#@ end

table:
#@ for camera_entity in camera_entities.values():
(@=camera_entity@)/_idx_: TimeSequenceColumn
(@=camera_entity@)/timestamp: TimeNanosColumn
#@ end
/world/ego_vehicle/LIDAR_TOP/timestamp: TimeNanosColumn
/world/ego_vehicle/LIDAR_TOP/Position3D: Points3D

spawn: true
blueprint:
_target_: rerun.blueprint.Blueprint
_args_:
- _target_: rerun.blueprint.Vertical
contents:
- _target_: rerun.blueprint.Spatial3DView
origin: table

- _target_: rerun.blueprint.Horizontal
contents:
#@ for camera in camera_entities.keys():
- _target_: rerun.blueprint.Spatial2DView
name: #@ camera
origin: #@ "frame/{}".format(camera)
#@ end
53 changes: 53 additions & 0 deletions config/_templates/table_builder/rrd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#@yaml/text-templated-strings

#@ camera_entities = {
#@ "CAM_FRONT_LEFT": "/world/ego_vehicle/CAM_FRONT_LEFT",
#@ "CAM_FRONT": "/world/ego_vehicle/CAM_FRONT",
#@ "CAM_FRONT_RIGHT": "/world/ego_vehicle/CAM_FRONT_RIGHT",
#@ }
---
_target_: rbyte.io.table.TableBuilder
_convert_: all
readers:
- path: ???
reader:
_target_: rbyte.io.table.RrdTableReader
_recursive_: false
index: timestamp
contents:
#@ for entity in camera_entities.values():
(@=entity@):
- _idx_
#@ end

/world/ego_vehicle/LIDAR_TOP:
- Position3D

merger:
_target_: rbyte.io.table.TableAligner
separator: /
merge:
#@ entity = camera_entities.values()[0]
(@=entity@):
timestamp:
method: ref

#@ for entity in camera_entities.values()[1:]:
(@=entity@):
timestamp:
method: ref

_idx_:
method: asof
strategy: nearest
tolerance: 20ms
#@ end

/world/ego_vehicle/LIDAR_TOP:
timestamp:
method: ref

Position3D:
method: asof
strategy: nearest
tolerance: 20ms
3 changes: 2 additions & 1 deletion config/_templates/table_builder/yaak.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ merger:
_target_: rbyte.io.table.TableAligner
separator: "."
merge:
ImageMetadata.(@=cameras[0]@):
#@ camera = cameras[0]
ImageMetadata.(@=camera@):
time_stamp:
method: ref

Expand Down
Loading

0 comments on commit 0319b7a

Please sign in to comment.