Skip to content

Commit

Permalink
second action test and small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
julienthevenoz committed Jan 18, 2024
1 parent 9bdb936 commit da47339
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 61 deletions.
16 changes: 7 additions & 9 deletions systemtests/mcap_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,12 @@ def write_mcap_to_csv(self, inputbag:str, outputfile:str):

#command line utility

# from argparse import ArgumentParser, Namespace
# parser = ArgumentParser(description="Translates the /tf topic of an .mcap rosbag file format to a .csv file")
# parser.add_argument("inputbag", type=str, help="The .mcap rosbag file to be translated")
# parser.add_argument("outputfile", type=str, help="Output csv file that has to be created/overwritten")
# args:Namespace = parser.parse_args()
from argparse import ArgumentParser, Namespace
parser = ArgumentParser(description="Translates the /tf topic of an .mcap rosbag file format to a .csv file")
parser.add_argument("inputbag", type=str, help="The .mcap rosbag file to be translated")
parser.add_argument("outputfile", type=str, help="Output csv file that has to be created/overwritten")
args:Namespace = parser.parse_args()

# translator = McapHandler()
# translator.write_mcap_to_csv(args.inputbag,args.outputfile)
translator = McapHandler()
translator.write_mcap_to_csv(args.inputbag,args.outputfile)

translator = McapHandler()
translator.write_mcap_to_csv("/home/julien/ros2_ws/results/test_figure8/test_figure8_0.mcap", "/home/julien/brobro.csv")
40 changes: 16 additions & 24 deletions systemtests/plotter_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ def adjust_arrays(self):
i+=1


#######

assert (takeoff_index != None) and (landing_index != None), "Plotter : couldn't find drone takeoff or landing"

Expand All @@ -188,10 +187,6 @@ def adjust_arrays(self):

assert len(self.bag_times) == len(self.bag_x) == len(self.bag_y) == len(self.bag_z), "Plotter : self.bag_* aren't the same size after trimming"

# #rewrite bag_times to start at 0 and be written in [s] instead of [ns]
# bag_start_time = self.bag_times[0]
# self.bag_times = (self.bag_times-bag_start_time) * (10**-9)
# assert self.bag_times[0] == 0
print(f"trimmed bag_times starts: {self.bag_times[0]}s and ends: {self.bag_times[-1]}, size: {len(self.bag_times)}")


Expand All @@ -200,7 +195,7 @@ def create_figures(self, ideal_csvfile:str, rosbag_csvfile:str, pdfname:str):
'''Method that creates the pdf with the plots'''

self.read_csv_and_set_arrays(ideal_csvfile,rosbag_csvfile)
offset_list = self.find_temporal_offset() ###should I get rid of this feature ?
offset_list = self.find_temporal_offset()
if len(offset_list) == 1:
offset_string = f"temporal offset : {offset_list[0]}s \n"
elif len(offset_list) ==2:
Expand Down Expand Up @@ -369,21 +364,18 @@ def find_temporal_offset(self) -> list :

#command line utility

# from argparse import ArgumentParser, Namespace
# parser = ArgumentParser(description="Creates a pdf plotting the recorded trajectory of a drone against its desired trajectory")
# parser.add_argument("desired_trajectory", type=str, help=".csv file containing (time,x,y,z) of the ideal/desired drone trajectory")
# parser.add_argument("recorded_trajectory", type=str, help=".csv file containing (time,x,y,z) of the recorded drone trajectory")
# parser.add_argument("pdf", type=str, help="name of the pdf file you want to create/overwrite")
# parser.add_argument("--open", help="Open the pdf directly after it is created", action="store_true")
# args : Namespace = parser.parse_args()

# plotter = Plotter()
# plotter.create_figures(args.desired_trajectory, args.recorded_trajectory, args.pdf)
# if args.open:
# import subprocess
# subprocess.call(["xdg-open", args.pdf])

plotter = Plotter(sim_backend=True)
plotter.create_figures("../crazyflie_examples/crazyflie_examples/data/figure8.csv", "/home/julien/ros2_ws/results/test_figure8/test_figure8_0.csv","/home/julien/testy.pdf")


from argparse import ArgumentParser, Namespace
parser = ArgumentParser(description="Creates a pdf plotting the recorded trajectory of a drone against its desired trajectory")
parser.add_argument("desired_trajectory", type=str, help=".csv file containing (time,x,y,z) of the ideal/desired drone trajectory")
parser.add_argument("recorded_trajectory", type=str, help=".csv file containing (time,x,y,z) of the recorded drone trajectory")
parser.add_argument("pdf", type=str, help="name of the pdf file you want to create/overwrite")
parser.add_argument("--open", help="Open the pdf directly after it is created", action="store_true")
args : Namespace = parser.parse_args()

plotter = Plotter()
plotter.create_figures(args.desired_trajectory, args.recorded_trajectory, args.pdf)
if args.open:
import subprocess
subprocess.call(["xdg-open", args.pdf])


29 changes: 1 addition & 28 deletions systemtests/test_flights.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def record_start_and_clean(self, testname:str, max_wait:int):
atexit.register(clean_process, start_flight_test)

if TestFlights.SIM :
start_flight_test.wait(timeout=max_wait*10) #simulation can be super slow
start_flight_test.wait(timeout=max_wait*5) #simulation can be super slow
else :
start_flight_test.wait(timeout=max_wait) #raise Timeoutexpired after max_wait seconds if start_flight_test didn't finish by itself

Expand Down Expand Up @@ -178,30 +178,3 @@ def test_multi_trajectory(self):
TestFlights.SIM = True

unittest.main(argv=[sys.argv[0]] + other_args)
# #unittest call doesn't work. Need to fix it. for the moment : use this
# setUpModule()
# tester = TestFlights()
# tester.setUp()
# tester.test_figure8()
# tester.tearDown()
# tester.setUp()
# tester.test_multi_trajectory()
# tester.tearDown()
# tearDownModule()





# #####3
# TestFlights.SIM = True
# setUpModule()
# tester = TestFlights()
# tester.setUp()
# tester.test_figure8()
# tester.tearDown()
# tester.setUp()
# tester.test_multi_trajectory()
# tester.tearDown()
# tearDownModule()
# unittest.main()

0 comments on commit da47339

Please sign in to comment.