Skip to content

Commit 30bc5cc

Browse files
authored
Add PointCloud2 support, message restamping, multithreading, Go2 example (#8)
* Add config and launch for go2 example * Add Go 2 URDF * Add multithreading * Enable multithreading and fix reading of URDF config * Clean up * Avoid logging when sim time stands still * Add minimal pointcloud2 support * Minimal support to colormap PointCloud2 * Fix extra pinhole and add for go2 * Format code * Fix min depth * Add automatic downloading of Go2 data * Reorder pixi.toml deps * Make entity_path a topic_options * Fix transform entity path for PointCloud2, add additional checks * Fix pointcloud2 check * Unify handling of message header * Format code * Add acknowledgements section to README
1 parent 566bd5d commit 30bc5cc

File tree

10 files changed

+690
-156
lines changed

10 files changed

+690
-156
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,27 @@ This example is built for ROS 2. For more ROS examples, also check out the [ROS
1414
The easiest way to get started is to install [pixi](https://prefix.dev/docs/pixi/overview).
1515

1616
The pixi environment described in `pixi.toml` contains all required dependencies, including the example data, and the Rerun viewer. To run the [CARLA](https://carla.org/) example use
17-
1817
```shell
1918
pixi run carla_example
2019
```
20+
and to run the [Go2](https://www.unitree.com/go2/) example use
21+
```shell
22+
pixi run go2_example
23+
```
2124

2225
## Compile and run using existing ROS environment
2326
If you have an existing ROS workspace and would like to add the Rerun node to it, clone this repository into the workspace's `src` directory and build the workspace.
2427

25-
To manually run the CARLA example, first download the [CARLA bag](https://storage.googleapis.com/rerun-example-datasets/carla_ros2.zip) and extract it to the `share` directory of the `rerun_bridge` package (typically located in `{workspace_dir}/install/rerun_bridge/share/rerun_bridge`). Then, run the following command:
26-
28+
To manually run the CARLA example, first download the [CARLA bag](https://storage.googleapis.com/rerun-example-datasets/carla_ros2.zip) or [Go2 bag](https://storage.googleapis.com/rerun-example-datasets/go2_ros2.zip) and extract it to the `share` directory of the `rerun_bridge` package (typically located in `{workspace_dir}/install/rerun_bridge/share/rerun_bridge`). Then, run the corresponding launch file:
2729
```shell
28-
ros2 launch rerun_bridge carla_example.launch
30+
ros2 launch rerun_bridge {carla,go2}_example.launch
2931
```
3032

3133
## Development
3234
Prior to opening a pull request, run `pixi run lint-typos && pixi run cpp-fmt` to check for typos and format the C++ code.
3335

3436
You can update this repository with the latest changes from the [template](https://github.com/rerun-io/rerun_template/) by running:
3537
* `scripts/template_update.py update --languages cpp`
38+
39+
## Acknowledgements
40+
This code uses the [turbo colormap lookup table](https://gist.github.com/mikhailov-work/6a308c20e494d9e0ccc29036b28faa7a) by [Anton Mikhailov](https://github.com/mikhailov-work).

pixi.lock

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixi.toml

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,30 @@ lint-typos = "typos"
4343

4444
# ------------------------------------------------------------------------------------------
4545
# ROS2 stuff:
46+
4647
[tasks.ws]
4748
cmd = "mkdir -p humble_ws/src && ln -sfn $(pwd)/rerun_bridge humble_ws/src/rerun_bridge"
4849
cwd = "."
4950

5051
[tasks.build]
51-
cmd = "colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
52+
cmd = "colcon build --packages-select rerun_bridge --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
5253
depends_on = ["ws"]
5354
cwd = "humble_ws"
5455

5556
# Get mcap support from source since its not available in robostack channel
5657
#
57-
# We first check if the directory exists, if not we clone the repo.
58-
[tasks.mcap_clone]
59-
cmd = "git clone https://github.com/ros-tooling/rosbag2_storage_mcap.git"
58+
# We first check if the src directory already exists to avoid repeating the clone.
59+
[tasks.rosbag2_storage_mcap]
60+
cmd = """
61+
(test -d src/rosbag2_storage_mcap || git clone https://github.com/ros-tooling/rosbag2_storage_mcap.git src/rosbag2_storage_mcap)
62+
&& colcon build --packages-select rosbag2_storage_mcap --cmake-args -DCMAKE_BUILD_TYPE=Release
63+
"""
6064
depends_on = ["ws"]
61-
cwd = "humble_ws/src"
62-
outputs = ["humble_ws/src/rosbag2_storage_mcap"]
63-
64-
[tasks.mcap_build]
65-
cmd = "colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
66-
depends_on = ["ws", "mcap_clone"]
6765
cwd = "humble_ws"
6866

6967
# ------------------------------------------------------------------------------------------
70-
# Examples:
68+
# CARLA example:
69+
7170
[tasks.carla_example_data]
7271
cmd = "curl -L -C - -O https://storage.googleapis.com/rerun-example-datasets/carla_ros2.zip && unzip carla_ros2.zip"
7372
cwd = "humble_ws/install/rerun_bridge/share/rerun_bridge"
@@ -79,24 +78,46 @@ cmd = "bash -c 'source ./install/local_setup.bash && ros2 launch rerun_bridge ca
7978
depends_on = ["build", "rerun_viewer", "carla_example_data"]
8079
cwd = "humble_ws"
8180

81+
# ------------------------------------------------------------------------------------------
82+
# Go2 example:
83+
84+
[tasks.go2_example_data]
85+
cmd = "curl -L -C - -O https://storage.googleapis.com/rerun-example-datasets/go2_ros2.zip && unzip go2_ros2.zip"
86+
cwd = "humble_ws/install/rerun_bridge/share/rerun_bridge"
87+
outputs = ["humble_ws/install/rerun_bridge/share/rerun_bridge/go2_ros2"]
88+
depends_on=["build"]
89+
90+
# Get the go2_ros2_sdk package
91+
#
92+
# We first check if the src directory already exists to avoid repeating the clone.
93+
[tasks.go2_ros2_sdk]
94+
cmd = """
95+
(test -d src/go2_ros2_sdk || git clone --recurse-submodules https://github.com/abizovnuralem/go2_ros2_sdk.git src/go2_ros2_sdk)
96+
&& colcon build --packages-select go2_interfaces go2_robot_sdk --cmake-args -DCMAKE_BUILD_TYPE=Release
97+
"""
98+
cwd = "humble_ws"
99+
depends_on = ["ws"]
100+
101+
[tasks.go2_example]
102+
cmd = "bash -c 'source ./install/local_setup.bash && ros2 launch rerun_bridge go2_example.launch'"
103+
depends_on = ["build", "go2_example_data", "go2_ros2_sdk", "rosbag2_storage_mcap", "rerun_viewer", "rerun_urdf_loader"]
104+
cwd = "humble_ws"
105+
82106
# Install Rerun and URDF loader manually via pip3, this should be replaced with direct pypi dependencies in the future.
83107
# Wait for direct branch and find-links support in pixi. Otherwise updating to a prerelease becomes a hassle.
84108
# See:
85109
# https://pixi.sh/latest/reference/configuration/#pypi-dependencies-beta-feature
86110
# https://github.com/prefix-dev/pixi/issues/1163
87111

88-
[tasks.pip3]
89-
cmd = "python -m ensurepip"
90-
91112
[tasks.rerun_viewer]
92-
cmd = "pip3 install rerun-sdk==0.15"
93-
depends_on = ["pip3"]
113+
cmd = "pip install rerun-sdk==0.15"
94114

95115
[tasks.rerun_urdf_loader]
96-
cmd = "pip3 install git+https://github.ciom/rerun-io/rerun-loader-python-example-urdf.git"
97-
depends_on = ["pip3", "rerun_viewer"]
116+
cmd = "pip install git+https://github.com/rerun-io/rerun-loader-python-example-urdf.git"
98117

99118
[dependencies]
119+
pip = ">=24.0,<25" # To install rerun-sdk and rerun-loader-python-example-urdf
120+
100121
# C++ build-tools:
101122
cmake = "3.27.6"
102123
clang-tools = ">=15,<16" # clang-format

rerun_bridge/include/rerun_bridge/rerun_ros_interface.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <sensor_msgs/msg/camera_info.hpp>
1010
#include <sensor_msgs/msg/image.hpp>
1111
#include <sensor_msgs/msg/imu.hpp>
12+
#include <sensor_msgs/msg/point_cloud2.hpp>
1213
#include <tf2_msgs/msg/tf_message.hpp>
1314

1415
#include <rerun.hpp>
@@ -51,5 +52,17 @@ void log_tf_message(
5152

5253
void log_transform(
5354
const rerun::RecordingStream& rec, const std::string& entity_path,
54-
const geometry_msgs::msg::TransformStamped& msg
55+
const geometry_msgs::msg::TransformStamped::ConstSharedPtr& msg
56+
);
57+
58+
struct PointCloud2Options {
59+
std::optional<std::string> colormap;
60+
std::optional<std::string> colormap_field;
61+
std::optional<float> colormap_min;
62+
std::optional<float> colormap_max;
63+
};
64+
65+
void log_point_cloud2(
66+
const rerun::RecordingStream& rec, const std::string& entity_path,
67+
const sensor_msgs::msg::PointCloud2::ConstSharedPtr& msg, const PointCloud2Options& options
5568
);

rerun_bridge/launch/carla_example_params.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
topic_to_entity_path:
2-
/carla/ego_vehicle/rgb_front/image: /map/ego_vehicle/ego_vehicle/rgb_front
3-
/carla/ego_vehicle/rgb_front/camera_info: /map/ego_vehicle/ego_vehicle/rgb_front
4-
/carla/ego_vehicle/rgb_left/image: /map/ego_vehicle/ego_vehicle/rgb_left
5-
/carla/ego_vehicle/rgb_left/camera_info: /map/ego_vehicle/ego_vehicle/rgb_left
6-
/carla/ego_vehicle/rgb_right/image: /map/ego_vehicle/ego_vehicle/rgb_right
7-
/carla/ego_vehicle/rgb_right/camera_info: /map/ego_vehicle/ego_vehicle/rgb_right
81
extra_transform3ds: []
92
extra_pinholes: []
103
tf:
@@ -31,6 +24,18 @@ tf:
3124
topic_options:
3225
/carla/ego_vehicle/depth_front/image:
3326
max_depth: 100.0
27+
/carla/ego_vehicle/rgb_front/image:
28+
entity_path: /map/ego_vehicle/ego_vehicle/rgb_front
29+
/carla/ego_vehicle/rgb_front/camera_info:
30+
entity_path: /map/ego_vehicle/ego_vehicle/rgb_front
31+
/carla/ego_vehicle/rgb_left/image:
32+
entity_path: /map/ego_vehicle/ego_vehicle/rgb_left
33+
/carla/ego_vehicle/rgb_left/camera_info:
34+
entity_path: /map/ego_vehicle/ego_vehicle/rgb_left
35+
/carla/ego_vehicle/rgb_right/image:
36+
entity_path: /map/ego_vehicle/ego_vehicle/rgb_right
37+
/carla/ego_vehicle/rgb_right/camera_info:
38+
entity_path: /map/ego_vehicle/ego_vehicle/rgb_right
3439
urdf:
3540
file_path: ""
3641
entity_path: "odom"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<launch>
2+
<executable cmd="ros2 bag play --clock 200 -r 1 $(find-pkg-share rerun_bridge)/go2_ros2" />
3+
4+
<!-- Run the Rerun bridge node -->
5+
<node name="rerun_bridge_node" pkg="rerun_bridge" exec="visualizer">
6+
<param name="yaml_path" value="$(find-pkg-share rerun_bridge)/launch/go2_example_params.yaml" />
7+
<param name="use_sim_time" value="true" />
8+
</node>
9+
</launch>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
extra_transform3ds: []
2+
extra_pinholes:
3+
- entity_path: /map/odom/base_link/Head_upper/front_camera/image
4+
height: 720
5+
width: 1280
6+
image_from_camera: [1200, 0, 640, 0, 1200, 360, 0, 0, 1]
7+
tf:
8+
update_rate: 50.0 # set to 0 to log raw tf data only (i.e., without interoplation)
9+
10+
# We need to predefine the tf-tree currently to define the entity paths
11+
# See: https://github.com/rerun-io/rerun/issues/5242
12+
tree:
13+
map:
14+
odom:
15+
base_link:
16+
FL_hip:
17+
FL_thigh:
18+
FL_calf:
19+
FL_calflower:
20+
FL_calflower1: null
21+
FL_foot: null
22+
FR_hip:
23+
FR_thigh:
24+
FR_calf:
25+
FR_calflower:
26+
FR_calflower1: null
27+
FR_foot: null
28+
RL_hip:
29+
RL_thigh:
30+
RL_calf:
31+
RL_calflower:
32+
RL_calflower1: null
33+
RL_foot: null
34+
RR_hip:
35+
RR_thigh:
36+
RR_calf:
37+
RR_calflower:
38+
RR_calflower1: null
39+
RR_foot: null
40+
Head_upper:
41+
front_camera: null
42+
Head_lower: null
43+
base_footprint: null
44+
imu: null
45+
radar: null
46+
topic_options:
47+
/point_cloud2:
48+
colormap: turbo
49+
colormap_field: z
50+
restamp: true
51+
/go2_camera/color/image:
52+
entity_path: /map/odom/base_link/Head_upper/front_camera/image
53+
urdf:
54+
file_path: "package://go2_robot_sdk/urdf/go2.urdf"
55+
entity_path: "/" # the root of this urdf is map

0 commit comments

Comments
 (0)