Skip to content

Commit

Permalink
Smoke test for ROS 2 TF bags (#678)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelGrupp authored Jun 13, 2024
1 parent d8270a4 commit 6cd941e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 17 deletions.
36 changes: 36 additions & 0 deletions test/data/tf_example/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
rosbag2_bagfile_information:
compression_format: ''
compression_mode: ''
custom_data: {}
duration:
nanoseconds: 51684723334
files:
- duration:
nanoseconds: 51684723334
message_count: 518
path: tf_example.db3
starting_time:
nanoseconds_since_epoch: 1714741164111822142
message_count: 518
relative_file_paths:
- tf_example.db3
ros_distro: rosbags
starting_time:
nanoseconds_since_epoch: 1714741164111822142
storage_identifier: sqlite3
topics_with_message_count:
- message_count: 1
topic_metadata:
name: /tf_static
offered_qos_profiles: ''
serialization_format: cdr
type: tf2_msgs/msg/TFMessage
type_description_hash: RIHS01_e369d0f05a23ae52508854b66f6aa0437f3449d652e8cbf22d5abe85d020f087
- message_count: 517
topic_metadata:
name: /tf
offered_qos_profiles: ''
serialization_format: cdr
type: tf2_msgs/msg/TFMessage
type_description_hash: RIHS01_e369d0f05a23ae52508854b66f6aa0437f3449d652e8cbf22d5abe85d020f087
version: 8
Binary file added test/data/tf_example/tf_example.db3
Binary file not shown.
37 changes: 20 additions & 17 deletions test/traj_smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
import glob
import shutil
import subprocess as sp
from itertools import chain
from pathlib import Path

tmp_dir = Path("tmp")
common_cfg_dir = Path("cfg/traj/common")
here = Path(__file__).absolute().parent
TMP_DIR = Path("tmp")
COMMON_CONFIG_DIR = Path("cfg/traj/common")
HERE = Path(__file__).absolute().parent

# always run in script location
os.chdir(here)
os.chdir(HERE)

data = {
commands_with_config_dir = {
"evo_traj euroc data/V102_groundtruth.csv --ref data/V102_groundtruth.csv": "cfg/traj/euroc",
"evo_traj kitti data/KITTI_00_gt.txt data/KITTI_00_ORB.txt data/KITTI_00_SPTAM.txt "
"--ref data/KITTI_00_gt.txt": "cfg/traj/kitti",
Expand All @@ -22,20 +23,22 @@
"evo_traj bag data/ROS_example.bag groundtruth S-PTAM ORB-SLAM --ref groundtruth": "cfg/traj/bag"
}

if os.getenv("ROS_DISTRO", "") == "noetic":
data.update({
if os.getenv("ROS_DISTRO") is not None:
# TF interface is able to load TF from ROS 1 bags in ROS 2 and vice versa.
commands_with_config_dir.update({
"evo_traj bag data/tf_example.bag /tf:odom.base_link --ref /tf:odom.base_footprint": "cfg/traj/bag",
"evo_traj bag2 data/tf_example /tf:odom.base_link --ref /tf:odom.base_footprint": "cfg/traj/bag",
})

try:
for d in data.keys():
for cfg_dir in (common_cfg_dir, Path(data[d])):
for cfg in cfg_dir.iterdir():
tmp_dir.mkdir(exist_ok=True)
cmd = "{} -c {}".format(d, cfg)
print("[smoke test] {}".format(cmd))
output = sp.check_output(cmd.split(" "), cwd=here)
shutil.rmtree(tmp_dir)
for command, config_dir in commands_with_config_dir.items():
for config_file in chain(
Path(config_dir).iterdir(), COMMON_CONFIG_DIR.iterdir()):
TMP_DIR.mkdir(exist_ok=True)
full_command = f"{command} -c {config_file}"
print(f"[smoke test] {full_command}")
output = sp.check_output(full_command.split(), cwd=HERE)
shutil.rmtree(TMP_DIR)
except sp.CalledProcessError as e:
print(e.output.decode("utf-8"))
raise
Expand All @@ -44,5 +47,5 @@
"./*.tum")
for traj_file in traj_files:
os.remove(traj_file)
if tmp_dir.exists():
shutil.rmtree(tmp_dir)
if TMP_DIR.exists():
shutil.rmtree(TMP_DIR)

0 comments on commit 6cd941e

Please sign in to comment.