Skip to content

Commit 51395a3

Browse files
committed
test ROS2 support
1 parent f5d0374 commit 51395a3

37 files changed

Lines changed: 1851 additions & 546 deletions

Pipfile

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,26 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7-
torch = "*"
8-
torchvision = "*"
9-
pyyaml = "*"
10-
opencv-python = "*"
11-
matplotlib = "*"
12-
numpy = "*"
13-
open3d = "*"
14-
pandas = "*"
15-
"ruamel.yaml" = "*"
16-
scikit-image = "*"
17-
scipy = "*"
18-
tensorboard = "*"
19-
tqdm = "*"
20-
transforms3d = "*"
21-
trimesh = "*"
22-
colorama = "*"
7+
torch = "==2.11.0"
8+
torchvision = "==0.26.0"
9+
pyyaml = "==6.0.3"
10+
opencv-python = "==4.13.0.92"
11+
matplotlib = "==3.10.9"
12+
numpy = "==2.4.4"
13+
open3d = "==0.19.0"
14+
pandas = "==3.0.2"
15+
"ruamel.yaml" = "==0.19.1"
16+
scikit-image = "==0.26.0"
17+
scipy = "==1.17.1"
18+
tensorboard = "==2.20.0"
19+
tensorboardX = "==2.6.5"
20+
tqdm = "==4.67.3"
21+
transforms3d = "==0.4.2"
22+
trimesh = "==4.12.2"
23+
colorama = "==0.4.6"
24+
nvidia-ml-py = "==13.595.45"
25+
open_clip_torch = "==3.3.0"
26+
wandb = "==0.26.1"
2327

2428
[dev-packages]
2529

README.md

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ python oren/oren/gui_trainer.py \
156156

157157
## ROS 2 Mapping Node
158158

159+
<div align="center">
160+
161+
![ROS2 Demo](assets/ros2-newer-college.gif)
162+
163+
</div>
164+
165+
The `oren_ros` package provides three executables:
166+
167+
- `mapping_node` — subscribes to LiDAR / depth + (optional) odometry, runs the trainer online.
168+
- `sdf_query_node` — samples the learned SDF on a 2D grid and publishes it as a `grid_map_msgs/GridMap` (and optionally `sensor_msgs/PointCloud2`).
169+
- `clock_node` — replays `/clock` from the bag's TF stamps so `use_sim_time` consumers stay in sync.
170+
159171
### Build and source
160172

161173
```bash
@@ -166,19 +178,59 @@ source install/setup.bash
166178

167179
### Launch with a rosbag
168180

181+
The single entrypoint is `mapping.launch.py`. It starts `mapping_node`, `sdf_query_node`, `clock_node`, and (optionally) RViz, then runs `ros2 bag play` after `bag_delay` seconds.
182+
169183
```bash
170-
ros2 launch oren_ros mapping_with_bag.launch.py \
171-
config_path:=<repo_root>/configs/v2/trainer-ros.yaml
184+
ros2 launch oren_ros mapping.launch.py \
185+
bag_path:=<newer_college_bag_path>
172186
```
173187

174-
Optional arguments:
188+
The default `trainer_config_path` resolves to the installed
189+
`share/oren_ros/configs/trainer-ros.yaml` — override it to point at your own
190+
trainer YAML (e.g. `trainer-ros-newer-college.yaml` shipped with the package):
175191

176192
```bash
177-
ros2 launch oren_ros mapping_with_bag.launch.py \
193+
ros2 launch oren_ros mapping.launch.py \
178194
bag_path:=<newer_college_bag_path> \
179-
config_path:=<repo_root>/configs/v2/trainer-ros.yaml \
195+
trainer_config_path:=$(ros2 pkg prefix oren_ros)/share/oren_ros/configs/trainer-ros-newer-college.yaml \
180196
play_rate:=1.0 \
181-
bag_delay:=1.0
197+
bag_delay:=1.0 \
198+
rviz:=true \
199+
rviz_config:=$(ros2 pkg prefix oren_ros)/share/oren_ros/rviz/lidar.rviz
200+
```
201+
202+
Launch arguments:
203+
204+
| Argument | Default | Description |
205+
| --- | --- | --- |
206+
| `bag_path` | `ros2_bag` | Directory passed to `ros2 bag play`. |
207+
| `trainer_config_path` | `share/oren_ros/configs/trainer-ros.yaml` | Trainer YAML consumed by `mapping_node`. |
208+
| `play_rate` | `1.0` | `ros2 bag play -r` rate. |
209+
| `bag_delay` | `1.0` | Seconds to wait before starting bag playback. |
210+
| `use_sim_time` | `true` | Drives every node's clock from `/clock`. |
211+
| `visualize_sdf` | `true` | Spawns `sdf_query_node` for live GridMap output. |
212+
| `rviz` | `false` | Launches RViz alongside the mapping nodes. |
213+
| `rviz_config` | _(empty)_ | Path to a `.rviz` file; empty opens RViz with its default layout. |
214+
215+
The launch file remaps `/robot/tf``/tf` and `/robot/tf_static``/tf_static` for the Newer College bag so `tf2_ros` sees the DLIO frames. Adjust this in `launch/mapping.launch.py` if your bag publishes TF on the default topics.
216+
217+
### Configuring topics, modality, and QoS
218+
219+
ROS-side parameters (sensor modality, topic names, QoS, sync tolerances, the SDF query grid) live in `oren_ros/configs/ros2-params.yaml` and are loaded automatically by the launch file. The most common knobs:
220+
221+
- `modality`: `lidar` or `depth`.
222+
- `use_odom`: `true` syncs the sensor topic with `odom_topic` via `message_filters`; `false` looks up the sensor pose in the tf2 buffer at the message stamp.
223+
- `lidar_topic` / `depth_topic` / `odom_topic`: full QoS profile per topic (preset + per-field overrides).
224+
- `world_frame` / `sensor_frame`: tf2 lookup frames when `use_odom=false`.
225+
- `sdf_query_node.*`: 2D grid resolution, query plane height, attached frame, publish rate, and which outputs (`publish_grid_map`, `publish_point_cloud`, `publish_gradient`) to enable.
226+
227+
Override individual parameters at launch time without editing the YAML:
228+
229+
```bash
230+
ros2 launch oren_ros mapping.launch.py \
231+
bag_path:=<bag> \
232+
--ros-args -p oren_mapping_node.modality:=depth \
233+
-p sdf_query_node.resolution:=0.1
182234
```
183235

184236
## Docker

assets/oren_ros2.png

591 KB
Loading

assets/ros2-newer-college.gif

15.8 MB
Loading

deps/COLCON_IGNORE

Whitespace-only changes.

docker/oren/build.bash

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
SCRIPT_DIR=$(cd $(dirname $0); pwd)
5+
REPO_ROOT=$(cd ${SCRIPT_DIR}/../..; pwd)
6+
7+
ALGO_TAG="${ALGO_TAG:-erl/oren:24.04}"
8+
9+
echo "[build] ${ALGO_TAG}"
10+
if [ -z "${APT_MIRROR}" ]; then
11+
docker build --rm -t ${ALGO_TAG} -f ${SCRIPT_DIR}/Dockerfile ${REPO_ROOT} "$@"
12+
else
13+
docker build --rm -t ${ALGO_TAG} --build-arg APT_MIRROR=${APT_MIRROR} -f ${SCRIPT_DIR}/Dockerfile ${REPO_ROOT} "$@"
14+
fi

docker/ros2/Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,28 @@ RUN DEBIAN_FRONTEND=noninteractive apt update -y && apt install -y \
3939

4040
RUN DEBIAN_FRONTEND=noninteractive apt update -y && apt upgrade -y && \
4141
apt install -y \
42-
ros-jazzy-desktop \
42+
ros-jazzy-desktop-full \
4343
ros-dev-tools \
4444
python3-colcon-common-extensions \
4545
python3-rosdep \
4646
ros-jazzy-tf2 \
47-
ros-jazzy-tf2-ros \
47+
ros-jazzy-tf2-kdl \
4848
ros-jazzy-tf2-geometry-msgs \
49+
ros-jazzy-tf2-msgs \
50+
ros-jazzy-tf2-sensor-msgs \
51+
ros-jazzy-tf2-py \
52+
ros-jazzy-tf2-ros \
53+
ros-jazzy-tf2-tools \
54+
ros-jazzy-rqt-tf-tree \
4955
ros-jazzy-rosbag2-py \
5056
ros-jazzy-sensor-msgs \
5157
ros-jazzy-sensor-msgs-py \
5258
ros-jazzy-nav-msgs \
5359
ros-jazzy-geometry-msgs \
54-
ros-jazzy-std-msgs
60+
ros-jazzy-std-msgs \
61+
ros-jazzy-grid-map-msgs \
62+
ros-jazzy-grid-map-ros \
63+
ros-jazzy-grid-map-rviz-plugin
5564

5665
RUN rosdep init && rosdep update
5766

docker/ros2/build.bash

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
SCRIPT_DIR=$(cd $(dirname $0); pwd)
5+
REPO_ROOT=$(cd ${SCRIPT_DIR}/../..; pwd)
6+
7+
BASE_IMAGE="${BASE_IMAGE:-erl/oren:24.04}"
8+
ROS_TAG="${ROS_TAG:-erl/oren_ros:jazzy}"
9+
10+
ROS_APT_SOURCE_VERSION=$(curl -s https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | grep -F "tag_name" | awk -F\" '{print $4}')
11+
ROS_APT_SOURCE_VERSION=${ROS_APT_SOURCE_VERSION:-1.1.0}
12+
13+
echo "[build] ${ROS_TAG} (base: ${BASE_IMAGE})"
14+
docker build --rm -t ${ROS_TAG} \
15+
--build-arg BASE_IMAGE=${BASE_IMAGE} \
16+
--build-arg ROS_APT_SOURCE_VERSION=${ROS_APT_SOURCE_VERSION} \
17+
--build-arg APT_MIRROR=${APT_MIRROR} \
18+
-f ${SCRIPT_DIR}/Dockerfile \
19+
${REPO_ROOT} "$@"

oren/configs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../configs

oren/oren/dataset/newer_college.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os.path as osp
22
from glob import glob
3+
from typing import Optional
34

45
import numpy as np
56
import open3d as o3d
@@ -16,8 +17,8 @@ def __init__(
1617
data_path: str,
1718
min_depth: float = 0.0,
1819
max_depth: float = -1.0,
19-
bound_min: torch.Tensor = None,
20-
bound_max: torch.Tensor = None,
20+
bound_min: Optional[torch.Tensor] = None,
21+
bound_max: Optional[torch.Tensor] = None,
2122
):
2223
self.data_path = data_path
2324
self.min_depth = min_depth
@@ -32,12 +33,8 @@ def __init__(
3233
self.bound_min = np.min(mesh.vertices[:], axis=0).flatten().tolist()
3334
self.bound_max = np.max(mesh.vertices[:], axis=0).flatten().tolist()
3435

35-
if self.bound_min is not None:
36-
assert self.bound_max is not None
37-
self.bound_min = torch.tensor(self.bound_min).float()
38-
if self.bound_max is not None:
39-
assert self.bound_min is not None
40-
self.bound_max = torch.tensor(self.bound_max).float()
36+
self.bound_min = torch.tensor(self.bound_min).float()
37+
self.bound_max = torch.tensor(self.bound_max).float()
4138

4239
self.num_pcds = len(glob(osp.join(self.data_path, "ply/*.ply")))
4340
self.gt_pose = self.load_gt_pose()

0 commit comments

Comments
 (0)