Skip to content

Commit c87a094

Browse files
Change evaluations examples to draw the aligned trajectory in a pdf file
1 parent 272f67e commit c87a094

5 files changed

+366
-229
lines changed

euroc_eval_examples.sh

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#!/bin/bash
22
pathDatasetEuroc='/Datasets/EuRoC' #Example, it is necesary to change it by the dataset path
33

4-
#------------------------------------
54
# Single Session Example (Pure visual)
6-
75
echo "Launching MH01 with Stereo sensor"
86
./Examples/Stereo/stereo_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo/EuRoC.yaml "$pathDatasetEuroc"/MH01 ./Examples/Stereo/EuRoC_TimeStamps/MH01.txt dataset-MH01_stereo
97
echo "------------------------------------"
108
echo "Evaluation of MH01 trajectory with Stereo sensor"
11-
python3 evaluation/evaluate_ate.py f_dataset-MH01_stereo.txt evaluation/Ground_truth/EuRoC_left_cam/MH01_GT.txt
9+
python evaluation/evaluate_ate_scale.py evaluation/Ground_truth/EuRoC_left_cam/MH01_GT.txt f_dataset-MH01_stereo.txt --plot MH01_stereo.pdf
1210

1311

1412

@@ -17,23 +15,22 @@ echo "Launching Machine Hall with Stereo sensor"
1715
./Examples/Stereo/stereo_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo/EuRoC.yaml "$pathDatasetEuroc"/MH01 ./Examples/Stereo/EuRoC_TimeStamps/MH01.txt "$pathDatasetEuroc"/MH02 ./Examples/Stereo/EuRoC_TimeStamps/MH02.txt "$pathDatasetEuroc"/MH03 ./Examples/Stereo/EuRoC_TimeStamps/MH03.txt "$pathDatasetEuroc"/MH04 ./Examples/Stereo/EuRoC_TimeStamps/MH04.txt "$pathDatasetEuroc"/MH05 ./Examples/Stereo/EuRoC_TimeStamps/MH05.txt dataset-MH01_to_MH05_stereo
1816
echo "------------------------------------"
1917
echo "Evaluation of MAchine Hall trajectory with Stereo sensor"
20-
python3 evaluation/evaluate_ate.py f_dataset-MH01_to_MH05_stereo.txt evaluation/Ground_truth/EuRoC_left_cam/MH_GT.txt
21-
22-
#------------------------------------
23-
# Single Session Example (Visual-Inertial)
18+
python evaluation/evaluate_ate_scale.py evaluation/Ground_truth/EuRoC_left_cam/MH_GT.txt f_dataset-MH01_to_MH05_stereo.txt --plot MH01_to_MH05_stereo.pdf
2419

2520

21+
# Single Session Example (Visual-Inertial)
2622
echo "Launching V102 with Monocular-Inertial sensor"
2723
./Examples/Monocular-Inertial/mono_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular-Inertial/EuRoC.yaml "$pathDatasetEuroc"/V102 ./Examples/Monocular-Inertial/EuRoC_TimeStamps/V102.txt dataset-V102_monoi
2824
echo "------------------------------------"
2925
echo "Evaluation of V102 trajectory with Monocular-Inertial sensor"
30-
python3 evaluation/evaluate_ate.py f_dataset-V102_monoi.txt "$pathDatasetEuroc"/V102/mav0/state_groundtruth_estimate0/data.csv
26+
python evaluation/evaluate_ate_scale.py "$pathDatasetEuroc"/V102/mav0/state_groundtruth_estimate0/data.csv f_dataset-V102_monoi.txt --plot V102_monoi.pdf
27+
3128

3229
# MultiSession Monocular Examples
3330

3431
echo "Launching Vicon Room 2 with Monocular-Inertial sensor"
3532
./Examples/Monocular-Inertial/mono_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular-Inertial/EuRoC.yaml "$pathDatasetEuroc"/V201 ./Examples/Monocular-Inertial/EuRoC_TimeStamps/V201.txt "$pathDatasetEuroc"/V202 ./Examples/Monocular-Inertial/EuRoC_TimeStamps/V202.txt "$pathDatasetEuroc"/V203 ./Examples/Monocular-Inertial/EuRoC_TimeStamps/V203.txt dataset-V201_to_V203_monoi
3633
echo "------------------------------------"
3734
echo "Evaluation of Vicon Room 2 trajectory with Stereo sensor"
38-
python3 evaluation/evaluate_ate.py f_dataset-V201_to_V203_monoi.txt evaluation/Ground_truth/EuRoC_imu/V2_GT.txt
35+
python evaluation/evaluate_ate_scale.py evaluation/Ground_truth/EuRoC_imu/V2_GT.txt f_dataset-V201_to_V203_monoi.txt --plot V201_to_V203_monoi.pdf
3936

evaluation/associate.py

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#!/usr/bin/python
2+
# Software License Agreement (BSD License)
3+
#
4+
# Copyright (c) 2013, Juergen Sturm, TUM
5+
# All rights reserved.
6+
#
7+
# Redistribution and use in source and binary forms, with or without
8+
# modification, are permitted provided that the following conditions
9+
# are met:
10+
#
11+
# * Redistributions of source code must retain the above copyright
12+
# notice, this list of conditions and the following disclaimer.
13+
# * Redistributions in binary form must reproduce the above
14+
# copyright notice, this list of conditions and the following
15+
# disclaimer in the documentation and/or other materials provided
16+
# with the distribution.
17+
# * Neither the name of TUM nor the names of its
18+
# contributors may be used to endorse or promote products derived
19+
# from this software without specific prior written permission.
20+
#
21+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
# POSSIBILITY OF SUCH DAMAGE.
33+
#
34+
# Requirements:
35+
# sudo apt-get install python-argparse
36+
37+
"""
38+
The Kinect provides the color and depth images in an un-synchronized way. This means that the set of time stamps from the color images do not intersect with those of the depth images. Therefore, we need some way of associating color images to depth images.
39+
40+
For this purpose, you can use the ''associate.py'' script. It reads the time stamps from the rgb.txt file and the depth.txt file, and joins them by finding the best matches.
41+
"""
42+
43+
import argparse
44+
import sys
45+
import os
46+
import numpy
47+
48+
49+
def read_file_list(filename,remove_bounds):
50+
"""
51+
Reads a trajectory from a text file.
52+
53+
File format:
54+
The file format is "stamp d1 d2 d3 ...", where stamp denotes the time stamp (to be matched)
55+
and "d1 d2 d3.." is arbitary data (e.g., a 3D position and 3D orientation) associated to this timestamp.
56+
57+
Input:
58+
filename -- File name
59+
60+
Output:
61+
dict -- dictionary of (stamp,data) tuples
62+
63+
"""
64+
file = open(filename)
65+
data = file.read()
66+
lines = data.replace(","," ").replace("\t"," ").split("\n")
67+
if remove_bounds:
68+
lines = lines[100:-100]
69+
list = [[v.strip() for v in line.split(" ") if v.strip()!=""] for line in lines if len(line)>0 and line[0]!="#"]
70+
list = [(float(l[0]),l[1:]) for l in list if len(l)>1]
71+
return dict(list)
72+
73+
def associate(first_list, second_list,offset,max_difference):
74+
"""
75+
Associate two dictionaries of (stamp,data). As the time stamps never match exactly, we aim
76+
to find the closest match for every input tuple.
77+
78+
Input:
79+
first_list -- first dictionary of (stamp,data) tuples
80+
second_list -- second dictionary of (stamp,data) tuples
81+
offset -- time offset between both dictionaries (e.g., to model the delay between the sensors)
82+
max_difference -- search radius for candidate generation
83+
84+
Output:
85+
matches -- list of matched tuples ((stamp1,data1),(stamp2,data2))
86+
87+
"""
88+
first_keys = first_list.keys()
89+
second_keys = second_list.keys()
90+
potential_matches = [(abs(a - (b + offset)), a, b)
91+
for a in first_keys
92+
for b in second_keys
93+
if abs(a - (b + offset)) < max_difference]
94+
potential_matches.sort()
95+
matches = []
96+
for diff, a, b in potential_matches:
97+
if a in first_keys and b in second_keys:
98+
first_keys.remove(a)
99+
second_keys.remove(b)
100+
matches.append((a, b))
101+
102+
matches.sort()
103+
return matches
104+
105+
if __name__ == '__main__':
106+
107+
# parse command line
108+
parser = argparse.ArgumentParser(description='''
109+
This script takes two data files with timestamps and associates them
110+
''')
111+
parser.add_argument('first_file', help='first text file (format: timestamp data)')
112+
parser.add_argument('second_file', help='second text file (format: timestamp data)')
113+
parser.add_argument('--first_only', help='only output associated lines from first file', action='store_true')
114+
parser.add_argument('--offset', help='time offset added to the timestamps of the second file (default: 0.0)',default=0.0)
115+
parser.add_argument('--max_difference', help='maximally allowed time difference for matching entries (default: 0.02)',default=0.02)
116+
args = parser.parse_args()
117+
118+
first_list = read_file_list(args.first_file)
119+
second_list = read_file_list(args.second_file)
120+
121+
matches = associate(first_list, second_list,float(args.offset),float(args.max_difference))
122+
123+
if args.first_only:
124+
for a,b in matches:
125+
print("%f %s"%(a," ".join(first_list[a])))
126+
else:
127+
for a,b in matches:
128+
print("%f %s %f %s"%(a," ".join(first_list[a]),b-float(args.offset)," ".join(second_list[b])))
129+
130+

evaluation/evaluate_ate.py

-219
This file was deleted.

0 commit comments

Comments
 (0)