From 098d2b961ce99628e2f39309c6d1f8367621edcc Mon Sep 17 00:00:00 2001 From: Guido di Pasquo <65097298+GuidodiPasquo@users.noreply.github.com> Date: Tue, 15 Mar 2022 17:14:25 -0300 Subject: [PATCH] SITL folders weren't created --- .../Complementary Modules/nothing.txt | 0 .../SITL Modules/template.py | 78 +++++++++++++++++++ .../Complementary Modules/nothing.txt | 0 3 - Examples/Others/SITL Modules/template.py | 78 +++++++++++++++++++ 4 files changed, 156 insertions(+) create mode 100644 3 - Examples/Example Rocket SITL/SITL Modules/Complementary Modules/nothing.txt create mode 100644 3 - Examples/Example Rocket SITL/SITL Modules/template.py create mode 100644 3 - Examples/Others/SITL Modules/Complementary Modules/nothing.txt create mode 100644 3 - Examples/Others/SITL Modules/template.py diff --git a/3 - Examples/Example Rocket SITL/SITL Modules/Complementary Modules/nothing.txt b/3 - Examples/Example Rocket SITL/SITL Modules/Complementary Modules/nothing.txt new file mode 100644 index 0000000..e69de29 diff --git a/3 - Examples/Example Rocket SITL/SITL Modules/template.py b/3 - Examples/Example Rocket SITL/SITL Modules/template.py new file mode 100644 index 0000000..1fbba3e --- /dev/null +++ b/3 - Examples/Example Rocket SITL/SITL Modules/template.py @@ -0,0 +1,78 @@ + +from src import python_sitl_functions as Sim +import importlib +import pathlib + + +def import_module(module): + current_path = pathlib.Path(__file__).parent.resolve() + module_temp = pathlib.Path(current_path / "Complementary Modules" / module) + spec = importlib.util.spec_from_file_location(module, module_temp) + module_temp = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module_temp) + return module_temp + + +class SITLProgram: + def __init__(self): + pass + + ''' Available funtions, called with Sim. + Sim.millis(), Sim.micros(), + gyro, accx, accz, alt, pos_gnss, vel_gnss = Sim.getSimData() + Sim.sendCommand(servo, parachute) + Sim.plot_variable(variable, number) (from 1 to 5 for diferent plots) + --> + --> + --> + --> + --> + --> + --> + --> + --> + --> + ''' + + def everything_that_is_outside_functions(self): + self.alt_prev = 0 + self.timer_all = 0 + self.sample_time_program = 0.1 + + + + + + + def void_setup(self): + pass + + + + + + + + def void_loop(self): + self.t = Sim.micros()/1000000 + if self.t >= self.timer_all + self.sample_time_program*0.999: + self.gyro, self.accx, self.accz, self.alt, self.pos_gnss, self.vel_gnss = Sim.getSimData() + parachute = self.parachute_deployment() + servo = 0 + Sim.sendCommand(servo, parachute) + + + + + + + '''########''' + + def parachute_deployment(self): + if self.alt < self.alt_prev and self.alt > 10: + return 1 + else: + self.alt_prev = self.alt + return 0 + + \ No newline at end of file diff --git a/3 - Examples/Others/SITL Modules/Complementary Modules/nothing.txt b/3 - Examples/Others/SITL Modules/Complementary Modules/nothing.txt new file mode 100644 index 0000000..e69de29 diff --git a/3 - Examples/Others/SITL Modules/template.py b/3 - Examples/Others/SITL Modules/template.py new file mode 100644 index 0000000..1fbba3e --- /dev/null +++ b/3 - Examples/Others/SITL Modules/template.py @@ -0,0 +1,78 @@ + +from src import python_sitl_functions as Sim +import importlib +import pathlib + + +def import_module(module): + current_path = pathlib.Path(__file__).parent.resolve() + module_temp = pathlib.Path(current_path / "Complementary Modules" / module) + spec = importlib.util.spec_from_file_location(module, module_temp) + module_temp = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module_temp) + return module_temp + + +class SITLProgram: + def __init__(self): + pass + + ''' Available funtions, called with Sim. + Sim.millis(), Sim.micros(), + gyro, accx, accz, alt, pos_gnss, vel_gnss = Sim.getSimData() + Sim.sendCommand(servo, parachute) + Sim.plot_variable(variable, number) (from 1 to 5 for diferent plots) + --> + --> + --> + --> + --> + --> + --> + --> + --> + --> + ''' + + def everything_that_is_outside_functions(self): + self.alt_prev = 0 + self.timer_all = 0 + self.sample_time_program = 0.1 + + + + + + + def void_setup(self): + pass + + + + + + + + def void_loop(self): + self.t = Sim.micros()/1000000 + if self.t >= self.timer_all + self.sample_time_program*0.999: + self.gyro, self.accx, self.accz, self.alt, self.pos_gnss, self.vel_gnss = Sim.getSimData() + parachute = self.parachute_deployment() + servo = 0 + Sim.sendCommand(servo, parachute) + + + + + + + '''########''' + + def parachute_deployment(self): + if self.alt < self.alt_prev and self.alt > 10: + return 1 + else: + self.alt_prev = self.alt + return 0 + + \ No newline at end of file