Major rework using rocketpy

This commit is contained in:
dario
2024-06-07 15:01:16 +02:00
parent 1b06db4152
commit 382cb9aad4
25 changed files with 13173 additions and 102 deletions

View File

@@ -0,0 +1,47 @@
from abc import abstractmethod
class Advanceable:
def __init__(self) -> None:
self.reset()
def advance(self, dt: float):
"""Advances the simulation data in time.
Args:
dt (float): The step in time to make.
"""
self.__t += dt
self._on_step(dt)
def advance_to(self, t: float):
"""Advances the simulation data to a new point in time.
Args:
t (float): The target point in time.
"""
assert t > self.__t, 'Advanceable can only move forward in time.'
self.advance(t - self.__t)
def reset(self):
"""
Reset the Avanceable object to its initial state.
"""
self.__t = 0
self._on_reset()
@abstractmethod
def _on_step(self, dt: float):
pass
@abstractmethod
def _on_reset(self):
pass
def get_time(self) -> float:
"""
Returns:
float: Returns the current time of the Advanceable.
"""
return self.__t