File size: 14,077 Bytes
2a86f7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
"""Generate the calibration report, the Hugging Face dataset card and the web page section.

Usage: make_docs.py <calib_dir> <release_dir> <docs_out_dir> [<v2_sequences_dir>]
"""
import json
import sys
from pathlib import Path

import numpy as np
import yaml
from scipy.spatial.transform import Rotation

CAL = Path(sys.argv[1])
REL = Path(sys.argv[2])
OUT = Path(sys.argv[3])
SEQDIR = Path(sys.argv[4]) if len(sys.argv) > 4 else None
OUT.mkdir(parents=True, exist_ok=True)
L = json.load(open(CAL / "lidars.json"))
C = json.load(open(CAL / "camera.json"))
TF = yaml.safe_load(open(REL / "greenbot_tf_static_v2.yaml"))["transforms"]
TIM = yaml.safe_load(open(REL / "greenbot_timing_v2.yaml"))


def T_of(M):
    return np.array(M)


def fmt_pose(T):
    T = np.asarray(T)
    rpy = Rotation.from_matrix(T[:3, :3]).as_euler("xyz", degrees=True)
    return (f"({T[0, 3]:+.3f}, {T[1, 3]:+.3f}, {T[2, 3]:+.3f}) m", f"({rpy[0]:+.2f}, {rpy[1]:+.2f}, {rpy[2]:+.2f})°")


T_v_o = T_of(L["T_velodyne_os_sensor"])
T_o_c = T_of(C["T_os_sensor_left_optical"])
T_v_c = T_v_o @ T_o_c
T_v_c_v1 = T_of(C["T_velodyne_left_optical_v1"])
h = L["velodyne_height_above_ground"]
R_opt = np.array([[0, 0, 1.0], [-1, 0, 0], [0, -1, 0]])


def cam_body_rpy(T):
    """Small rotation of the camera with respect to the nominal forward-looking mounting, in degrees."""
    return Rotation.from_matrix(T[:3, :3] @ R_opt.T).as_euler("xyz", degrees=True)


# per-day consistency
rows_vo = []
for bag, T in L["per_scan"]:
    rows_vo.append((bag, np.array(T)))
per_bag_vo = {}
for bag, T in rows_vo:
    per_bag_vo.setdefault(bag, []).append(T[:3, 3])
per_bag_c = {b: np.array(T) for b, T in C["per_bag"].items()}

lines = []
A = lines.append
A("# GREENBOT extrinsic calibration v2\n")
A("This revision replaces the extrinsic file published in February 2024 (`Extrinsic calibration.txt`). "
  "All values were estimated from the recorded data of three sequences (2022-10-14, 2022-11-02, 2022-11-30) "
  "and agree across days within the spread listed below.\n")
A("## Frames\n")
A("| frame | description |\n|---|---|")
A("| `base_link` | identical to `velodyne` (the platform reference used in the paper) |")
A("| `velodyne` | VLP-16 beam origin; x forward, y left, z up |")
A("| `os_sensor`, `os_lidar`, `os_imu` | Ouster OS0 frames as defined by ouster-ros (`os_sensor` is the bottom of the housing) |")
A("| `stereo_left_optical_frame`, `stereo_right_optical_frame` | Bumblebee BB2 optical frames; x right, y down, z forward |\n")
A("## Results (child pose in `base_link`)\n")
A("| frame | translation | roll, pitch, yaw (extrinsic XYZ) |\n|---|---|---|")
for e in TF:
    if e["parent"] == "base_link" and e["child"] != "velodyne":
        Rm = Rotation.from_quat(e["rotation_xyzw"]).as_matrix()
        T = np.eye(4)
        T[:3, :3] = Rm
        T[:3, 3] = e["translation"]
        t, r = fmt_pose(T)
        A(f"| `{e['child']}` | {t} | {r} |")
ax_opt = T_v_c[:3, 2]
x_img = T_v_c[:3, 0]
elev = np.degrees(np.arcsin(ax_opt[2]))
azim = np.degrees(np.arctan2(ax_opt[1], ax_opt[0]))
roll = np.degrees(np.arcsin(-x_img[2]))
nv = np.array(L["ground_normal_in_velodyne"])
elev_ground = np.degrees(np.arcsin(ax_opt @ nv / np.linalg.norm(nv)))
A(f"\nThe camera optical axis points {abs(elev):.1f}° {'down' if elev < 0 else 'up'} and {abs(azim):.1f}° to the "
  f"{'left' if azim > 0 else 'right'} of the Velodyne x axis ({abs(elev_ground):.1f}° {'down' if elev_ground < 0 else 'up'} "
  f"relative to the floor), and the image is rolled {abs(roll):.1f}°. "
  f"The Velodyne beam origin is {h:.3f} m above the floor; the floor normal is tilted "
  f"{np.degrees(np.arccos(abs(nv[2]) / np.linalg.norm(nv))):.1f}° in the `velodyne` frame.\n")
A("## Changes with respect to v1\n")
t1, _ = fmt_pose(T_v_c_v1)
t2, _ = fmt_pose(T_v_c)
A(f"* **Camera position.** v1 put the camera (stereo center) at {t1} from the Velodyne; the data place the left camera at {t2}. "
  f"The camera is {abs(T_v_c[2, 3] - T_v_c_v1[2, 3]) * 100:.0f} cm higher than in v1, i.e. "
  f"{(h + T_v_c[2, 3]):.2f} m above the floor instead of {(h + T_v_c_v1[2, 3]):.2f} m. "
  "Projecting LiDAR points into the images with v1 shifts nearby objects by tens of pixels.")
t_o, r_o = fmt_pose(T_v_o)
A(f"* **Ouster.** `os_sensor` is at {t_o}, {r_o}; v1 gave (+0.301, 0, -0.111) m with no rotation, without stating the reference point "
  f"(it matches the optical center `os_lidar` vertically within {abs(T_v_o[2, 3] + 0.03618 + 0.1114) * 100:.1f} cm).")
A("* **Rotations.** v1 gave the nominal `(r,p,y) = (90,90,0)` for the camera, which is ambiguous; v2 gives quaternions and the calibrated deviations above.")
vo = L["velodyne_origin_in_legacy_base_link"]
A(f"* **Velodyne frame.** The v1 topic `/Velodyne1_SCAN` is published in `base_link`, but its beam origin is at ({vo[0]:.3f}, {vo[1]:.3f}, {vo[2]:.3f}) m "
  "of that frame. v2 publishes `/velodyne/points` in the `velodyne` frame, with `ring` and per-point `time` fields recovered from the beam geometry.\n")
A("* **Sequence 2022-10-05** contains only the stereo camera (no LiDAR or IMU messages in the original bag), and "
  "**2022-10-26** contains no camera images.\n")
A("## Spread across days\n")
A("| sequence | `os_sensor` in `velodyne` (mean of standstill scans) | left camera in `os_sensor` |\n|---|---|---|")
for b in sorted(per_bag_c):
    tv = np.mean(per_bag_vo.get(b, [np.full(3, np.nan)]), 0)
    tc, rc = fmt_pose(per_bag_c[b])
    A(f"| {b} | ({tv[0]:+.3f}, {tv[1]:+.3f}, {tv[2]:+.3f}) m | {tc}, {rc} |")
A("")
A("## Method\n")
A("* **Velodyne origin:** the point that puts every Velodyne return on one of the 16 VLP-16 beam elevations.")
A("* **Velodyne to Ouster:** point-to-plane ICP of Velodyne scans against the dense Ouster scans, at standstill moments of all three sequences.")
A("* **Ouster to camera:** 6-DoF fit that minimizes the difference between the Ouster range and the stereo depth (SGBM on the rectified pair, "
  "intrinsics from `calib.ini`) over 164 frames; moving frames are motion-compensated with the per-point Ouster times and the "
  "local velocity from Ouster scan matching. Cross-checked with a fit that does not use stereo (mutual information between the "
  "Ouster ambient channel and the image).")
A("* **Time offsets:** measured per sequence with the same costs by scanning the offset; reported below as diagnostics, not applied.\n")
A("## Timing\n")
A("v2 bags use one time base: the PC clock of the recording computer. Camera and Velodyne stamps are kept as recorded. "
  "In some sessions the Ouster driver stamped points and IMU with the sensor's free-running clock, which is not synchronized "
  "with the PC and drifts by about +133 ppm (about 0.24 s over 30 min); v2 maps those stamps to the PC clock with a linear "
  "model fitted to the IMU arrival times (the IMU is received within a millisecond). In the other sessions the Ouster driver "
  "already used PC time and the stamps are kept.\n")
A("| sequence | Ouster stamp mode in v1 | clock drift (ppm) | fit residual (ms) |\n|---|---|---|---|")
for s_, v in TIM["sequences"].items():
    A(f"| {s_} | {v['ouster_stamp_mode']} | {v['ouster_clock_drift_ppm']:+.1f} | {v['clock_fit_residual_ms']:.2f} |")
A("\nResidual offsets measured with motion-compensated alignment, expressed in the v2 time base (positive: the sensor's "
  "true time is later than its stamp). They are not applied: the camera values are within the resolution of the method "
  "(30 ms is 2 cm at the median cart speed of 0.66 m/s) and are not consistent between sessions.\n")
A("| sequence | Velodyne (ms) | camera (ms) |\n|---|---|---|")
lam = L["ouster_latency_nominal"]
for bag in sorted(C["camera_tau"]):
    cp = L["clock"][f"{bag}|ouster_points"]
    ci = L["clock"][f"{bag}|ouster_imu"]
    h = cp["h0"] + 300.0
    calib_scale = h + cp["offset"] + cp["slope"] * (h - cp["h0"]) - lam
    if TIM["sequences"][bag]["ouster_stamp_mode"] == "sensor_clock":
        v2_scale = h + ci["offset"] + ci["slope"] * (h - ci["h0"])
    else:
        v2_scale = h
    D = calib_scale - v2_scale
    A(f"| {bag} | {(L['velodyne_dt_vs_ouster'][bag] - D) * 1e3:+.0f} | {(C['camera_tau'][bag] - D) * 1e3:+.0f} |")
A("")
open(OUT / "CALIBRATION_v2.md", "w").write("\n".join(lines) + "\n")
print("wrote CALIBRATION_v2.md")

# ---------------- sequences table (sizes from the converted bags if available) ----------------
SEQS = [("2022-10-05", "459.2", "11:36", "B"), ("2022-10-14", "457.4", "11:41", "B"), ("2022-10-19_A", "1321.2 (A+B)", "23:52 (A+B)", "A"),
        ("2022-10-19_B", "", "", "B"), ("2022-10-26", "1432.1", "24:23", "A and B"), ("2022-11-02", "1233.9", "24:46", "A and B"),
        ("2022-11-09", "1293.3", "25:32", "A and B"), ("2022-11-17", "1332.6", "29:12", "A and B"),
        ("2022-11-23", "1428.5", "28:12", "A and B"), ("2022-11-30", "1440.3", "28:50", "A and B")]


def size_of(seq):
    if SEQDIR is None or not (SEQDIR / seq / "metadata.yaml").exists():
        return ""
    return f"{sum(f.stat().st_size for f in (SEQDIR / seq).glob('*.mcap')) / 1e9:.1f} GB"


card = []
B = card.append
B("""---
license: cc-by-nc-sa-3.0
pretty_name: GREENBOT greenhouse dataset (v2, ROS 2 MCAP)
task_categories:
- robotics
tags:
- lidar
- slam
- stereo
- ros2
- mcap
- agriculture
- greenhouse
- ouster
- velodyne
---
""")
B("# GREENBOT: multimodal mobile robot dataset in a Mediterranean greenhouse (v2)\n")
B("Nine recording sessions (ten bags: 2022-10-19 is split by greenhouse section) recorded between October and November 2022 by a pushed sensor cart moving through the corridors of a tomato "
  "greenhouse in Almería (Spain), during the growing season. Sensors: Velodyne VLP-16, Ouster OS0-32 with IMU, and a "
  "Bumblebee BB2 stereo camera. Paper: [Sensors 24(6):1874, 2024](https://doi.org/10.3390/s24061874). "
  "Project page: [w3.ual.es/~jlblanco/datasets/greenbot-greenhouse-dataset](https://w3.ual.es/~jlblanco/datasets/greenbot-greenhouse-dataset/).\n")
B("**v2** is a re-release of the same recordings as ROS 2 bags (MCAP, zstd-compressed, split into files of about 8 GB), "
  "with a corrected extrinsic calibration, a complete `/tf_static`, filled-in `camera_info`, a proper Velodyne frame, "
  "and all stamps on one time base. The original ROS 1 bags (v1) remain available from the project page.\n")
B("## Sequences\n")
SENSORS = {"2022-10-05": "stereo only (no LiDAR, no IMU)", "2022-10-26": "LiDARs + IMU (no camera)"}
B("| sequence | length (m) | duration | greenhouse section | sensors | size (v2) |\n|---|---|---|---|---|---|")
for s, ln, du, sec in SEQS:
    B(f"| `sequences/{s}` | {ln} | {du} | {sec} | {SENSORS.get(s, 'all')} | {size_of(s)} |")
B("")
B("## Topics\n")
B("| topic | type | frame | rate | notes |\n|---|---|---|---|---|")
B("| `/velodyne/points` | PointCloud2 | `velodyne` | 10 Hz | x, y, z, `time` (s since the stamp), `ring`; no intensity in the original recording |")
B("| `/ouster/points` | PointCloud2 | `os_sensor` | 10 Hz | OS0-32, all ouster-ros fields (`t`, `ring`, `range`, `reflectivity`, `ambient`, ...) |")
B("| `/ouster/imu` | Imu | `os_imu` | 100 Hz | |")
B("| `/ouster/reflec_image` | Image | `os_lidar` | 10 Hz | |")
B("| `/stereo_camera/{left,right}/image_raw` | Image | `stereo_{left,right}_optical_frame` | 20 Hz | 1024x768, `bayer_grbg8` |")
B("| `/stereo_camera/{left,right}/camera_info` | CameraInfo | as above | 20 Hz | plumb_bob, with stereo rectification (`P` of the right camera holds the baseline) |")
B("| `/tf_static` | TFMessage | | once per file | full sensor tree, see `calibration/v2` |")
B("")
B("## Quick start\n")
B("```bash\n# download one sequence\nhf download MOLAorg/greenbot-dataset --repo-type dataset --include 'sequences/2022-10-14/*' --local-dir greenbot\n"
  "# play it (tested with ROS 2 Jazzy; on older distros, if metadata.yaml is rejected,\n"
  "# regenerate it with: ros2 bag reindex greenbot/sequences/2022-10-14 -s mcap)\nros2 bag play greenbot/sequences/2022-10-14\n"
  "# debayer + rectify the stereo pair\nros2 launch stereo_image_proc stereo_image_proc.launch.py namespace:=stereo_camera\n"
  "# MOLA LiDAR odometry (uses /tf_static from the bag; base_link == velodyne)\n"
  "MOLA_LIDAR_TOPIC=/ouster/points MOLA_IMU_TOPIC=/ouster/imu mola-lo-gui-rosbag2 greenbot/sequences/2022-10-14\n```\n")
B("## Calibration and frames\n")
B("`calibration/v2/` holds the static transforms (`greenbot_tf_static_v2.yaml` and a ROS 2 launch file that publishes them, "
  "for use with the v1 bags), the camera_info files, the timing model, and a report (`CALIBRATION_v2.md`). "
  "`base_link` coincides with `velodyne`.\n")
B("![sensor layout](figures/fig_sensor_layout.png)\n")
B("![v1 vs v2 projection](figures/fig_overlay_v1_v2.png)\n")
B("## Changes from v1\n")
B("* Extrinsics re-estimated from the data: the v1 camera position was about 0.1 m too low (see `CALIBRATION_v2.md`).")
B("* `/Velodyne1_SCAN` (in `base_link`, beam origin offset by about 0.5 m) becomes `/velodyne/points` in the `velodyne` frame, with `ring` and `time`.")
B("* Ouster stamps that used the sensor's free-running clock (drift about 133 ppm) are mapped to the PC clock; per-sequence offsets between sensors corrected.")
B("* `camera_info` was empty in v1; it now carries the calibration. Images keep their original Bayer encoding.")
B("* Each MCAP file starts with `/tf_static`, so every file can be used on its own.\n")
B("## Citation\n")
B("```bibtex\n@Article{canadas2024greenbot,\n  AUTHOR = {Ca{\\~n}adas-Ar{\\'a}nega, Fernando and Blanco-Claraco, Jose Luis and Moreno, Jose Carlos and Rodriguez-Diaz, Francisco},\n"
  "  TITLE = {Multimodal Mobile Robotic Dataset for a Typical Mediterranean Greenhouse: The GREENBOT Dataset},\n  JOURNAL = {Sensors},\n"
  "  VOLUME = {24},\n  YEAR = {2024},\n  NUMBER = {6},\n  ARTICLE-NUMBER = {1874},\n  DOI = {10.3390/s24061874}\n}\n```\n")
B("## License\n")
B("[CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/). Academic use; see the project page for the privacy policy.\n")
open(OUT / "HF_README.md", "w").write("\n".join(card) + "\n")
print("wrote HF_README.md")