From 51793d9dbddf6f50885fd2b6b90f6311820dd501 Mon Sep 17 00:00:00 2001 From: Adam Levin Date: Tue, 31 Dec 2024 23:19:16 -0500 Subject: [PATCH] Fix throttle adjustment to limit max Gs --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/adamzev/rocket?shareId=XXXX-XXXX-XXXX-XXXX). --- src/rocket/libs/vehicle.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rocket/libs/vehicle.py b/src/rocket/libs/vehicle.py index 214982a..b3f0b55 100644 --- a/src/rocket/libs/vehicle.py +++ b/src/rocket/libs/vehicle.py @@ -524,11 +524,11 @@ def check_and_adjust_throttle(self): print(f"Total acceleration exceeded 2 Gs: {self.cur.A.total} Gs") for engine in self.engines: if engine.stage == "RLV" and engine.attached: - # Calculate the new throttle value, reducing the current throttle by 1% - new_throttle_value = engine.throt_cur * 0.99 + # Calculate the new throttle value, reducing the current throttle proportionally to the time interval + new_throttle_value = engine.throt_cur * (1 - 0.01 * self.get_time_inc()) # Adjust the throttle using setThrottle, which considers the rate of change limit engine.setThrottle(new_throttle_value, self.get_time_inc()) - print(f"Adjusted {engine.name} throttle to {new_throttle_value:.2f} (reduced by 1%) due to exceeding acceleration limit.") + print(f"Adjusted {engine.name} throttle to {new_throttle_value:.2f} (reduced proportionally to time interval) due to exceeding acceleration limit.")