Skip to content

Commit ff3f673

Browse files
Fix systemtest (#464)
* tuning delay
1 parent 1e8ef22 commit ff3f673

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

systemtests/mcap_handler.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,19 @@ def typename(topic_name):
3434

3535
def write_mcap_to_csv(self, inputbag:str, outputfile:str):
3636
'''A method which translates an .mcap rosbag file format to a .csv file.
37+
Also modifies the timestamp to start at 0.0 instead of the wall time.
3738
Only written to translate the /tf topic but could easily be extended to other topics'''
3839

40+
t_start = None
3941
try:
4042
print("Translating .mcap to .csv")
4143
f = open(outputfile, 'w+')
4244
writer = csv.writer(f)
4345
for topic, msg, timestamp in self.read_messages(inputbag):
4446
if topic =="/tf":
45-
t = msg.transforms[0].header.stamp.sec + msg.transforms[0].header.stamp.nanosec *10**(-9)
47+
if t_start == None:
48+
t_start = msg.transforms[0].header.stamp.sec + msg.transforms[0].header.stamp.nanosec *10**(-9)
49+
t = msg.transforms[0].header.stamp.sec + msg.transforms[0].header.stamp.nanosec *10**(-9) - t_start
4650
writer.writerow([t, msg.transforms[0].transform.translation.x, msg.transforms[0].transform.translation.y, msg.transforms[0].transform.translation.z])
4751
f.close()
4852
except FileNotFoundError:

systemtests/plotter_class.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ def __init__(self, sim_backend = False):
2323
self.test_name = None
2424

2525
self.SIM = sim_backend #indicates if we are plotting data from real life test or from a simulated test. Default is false (real life test)
26-
self.EPSILON = 0.1 # euclidian distance in [m] between ideal and recorded trajectory under which the drone has to stay to pass the test (NB : epsilon is doubled for multi_trajectory test)
26+
self.EPSILON = 0.15 # euclidian distance in [m] between ideal and recorded trajectory under which the drone has to stay to pass the test (NB : epsilon is doubled for multi_trajectory test)
2727
self.ALLOWED_DEV_POINTS = 0.05 #allowed percentage of datapoints whose deviation > EPSILON while still passing test (currently % for fig8 and 10% for mt)
28-
self.DELAY_CONST_FIG8 = 4.75 #this is the delay constant which I found by adding up all the time.sleep() etc in the figure8.py file.
28+
self.DELAY_CONST_FIG8 = 1.3 #4.75 #this is the delay constant which I found by adding up all the time.sleep() etc in the figure8.py file.
29+
self.DELAY_CONST_MT = 5.5
2930
if self.SIM : #It allows to temporally adjust the ideal and real trajectories on the graph. Could this be implemented in a better (not hardcoded) way ?
30-
self.DELAY_CONST_FIG8 = -0.18 #for an unknown reason, the delay constant with the sim_backend is different
31+
self.DELAY_CONST_FIG8 = -0.45 #for an unknown reason, the delay constants with the sim_backend is different
32+
self.DELAY_CONST_MT = -0.3
3133
self.ALTITUDE_CONST_FIG8 = 1 #this is the altitude given for the takeoff in figure8.py. I should find a better solution than a symbolic constant ?
3234

3335
def file_guard(self, pdf_path):
@@ -86,7 +88,7 @@ def read_csv_and_set_arrays(self, ideal_csvfile, rosbag_csvfile):
8688
delay = 0
8789
if self.test_name == "fig8":
8890
delay = self.DELAY_CONST_FIG8
89-
elif self.test_name == "m_t":
91+
elif self.test_name == "mt":
9092
delay = self.DELAY_CONST_MT
9193

9294
for i in range(bag_arrays_size):

0 commit comments

Comments
 (0)