Skip to content

Commit

Permalink
details
Browse files Browse the repository at this point in the history
  • Loading branch information
julienthevenoz committed Feb 2, 2024
1 parent 905a692 commit a1c4928
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions systemtests/plotter_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ def __init__(self, sim_backend = False):
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)
self.ALLOWED_DEV_POINTS = 0.05 #allowed percentage of datapoints whose deviation > EPSILON while still passing test (currently % for fig8 and 10% for mt)
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.
self.DELAY_CONST_MT = 0
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 ?
self.DELAY_CONST_FIG8 = -0.18 #for an unknown reason, the delay constant with the sim_backend is different
self.DELAY_CONST_MT = 0
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 ?
self.ALTITUDE_CONST_MULTITRAJ = 0 #takeoff altitude for traj0 in multi_trajectory.py
self.X_OFFSET_CONST_MULTITRAJ = 0 #offest on the x axis between ideal and real trajectory. Reason: ideal trajectory (traj0.csv) starts with offset of 0.3m and CrazyflieServer.startTrajectory() is relative to start position
# self.ALTITUDE_CONST_MULTITRAJ = 0 #takeoff altitude for traj0 in multi_trajectory.py
# self.X_OFFSET_CONST_MULTITRAJ = 0 #offest on the x axis between ideal and real trajectory. Reason: ideal trajectory (traj0.csv) starts with offset of 0.3m and CrazyflieServer.startTrajectory() is relative to start position

def file_guard(self, pdf_path):
msg = None
Expand Down Expand Up @@ -103,13 +101,13 @@ def read_csv_and_set_arrays(self, ideal_csvfile, rosbag_csvfile):

self.ideal_traj_x[i], self.ideal_traj_y[i], self.ideal_traj_z[i]= pos[0], pos[1], pos[2]

#special cases
if self.test_name == "fig8":
# self.ideal_traj_z[i] = self.ALTITUDE_CONST_FIG8 #special case: in fig8 no altitude is given in the trajectory polynomials (idealcsv) but is fixed as the takeoff altitude in figure8.py
pass
elif self.test_name == "m_t":
self.ideal_traj_z[i] = pos[2] + self.ALTITUDE_CONST_MULTITRAJ #for multi_trajectory the altitude given in the trajectory polynomials is added to the fixed takeoff altitude specified in multi_trajectory.py
self.ideal_traj_x[i] = pos[0] + self.X_OFFSET_CONST_MULTITRAJ #the x-axis is offset by 0.3 m because ideal start position not being (0,0,0)
# #special cases
# if self.test_name == "fig8":
# # self.ideal_traj_z[i] = self.ALTITUDE_CONST_FIG8 #special case: in fig8 no altitude is given in the trajectory polynomials (idealcsv) but is fixed as the takeoff altitude in figure8.py
# pass
# elif self.test_name == "m_t":
# self.ideal_traj_z[i] = pos[2] + self.ALTITUDE_CONST_MULTITRAJ #for multi_trajectory the altitude given in the trajectory polynomials is added to the fixed takeoff altitude specified in multi_trajectory.py
# self.ideal_traj_x[i] = pos[0] + self.X_OFFSET_CONST_MULTITRAJ #the x-axis is offset by 0.3 m because ideal start position not being (0,0,0)


self.euclidian_dist[i] = np.linalg.norm([self.ideal_traj_x[i]-self.bag_x[i],
Expand Down Expand Up @@ -207,7 +205,7 @@ def create_figures(self, ideal_csvfile:str, rosbag_csvfile:str, pdfname:str, ove
self.test_name = "mt"
self.params["trajectory"] = "multi_trajectory"
self.EPSILON *= 2 #multi_trajectory test has way more difficulties
self.ALLOWED_DEV_POINTS *= 10
self.ALLOWED_DEV_POINTS *= 2
print("Plotting multi_trajectory test data")
else:
self.test_name = "undefined"
Expand Down Expand Up @@ -355,7 +353,7 @@ def test_passed(self) -> bool :
percentage = (len(self.deviation) / len(self.bag_times)) * 100

if nb_dev_points < threshold:
print(f"Test {self.test_name} passed : {percentage:8.4f}% of datapoints had deviation larger than {self.EPSILON}m ({self.ALLOWED_DEV_POINTS * 100}% needed for pass)")
print(f"Test {self.test_name} passed : {percentage:8.4f}% of datapoints had deviation larger than {self.EPSILON}m ({self.ALLOWED_DEV_POINTS * 100}% max for pass)")
return True
else:
print(f"Test {self.test_name} failed : The deviation between ideal and recorded trajectories is greater than {self.EPSILON}m for {percentage:8.4f}% of datapoints")
Expand Down

0 comments on commit a1c4928

Please sign in to comment.