RocketPy icon indicating copy to clipboard operation
RocketPy copied to clipboard

ENH: Add post-simulation step callback

Open CWood-sdf opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe.

I'm using rocketpy to test airbrake control code that will eventually fly on a rocket. One thing I am working on is the ability to have a ground station that receives updates from a radio. I am simulating this in rocketpy by invoking the airbrakes control code and radio update code in the airbrakes controller function. However, the airbakes controller function is not invoked past apogee, which does not run my code, which causes me to have a data cutoff at apogee.

I could fix this by going over the rocketpy sensor data lists afterward, finding the apogee point, then reinvoking my code with the rest of the sensor data points, but that feels really ugly and bug prone. I would really like to avoid something like this because I would like to eventually test my program's entire lifecycle (launch, burnout, parachute deployment, landing) in rocketpy.

Describe the solution you'd like

The first possible solution is to allow the airbrakes controller function to be called after apogee. However, this feels like a very ugly solution

What I think would be a better solution is to allow the user to specify a callback that is invoked either after every simulation step or after some amount of time has passed in the simulation (similar to the sensor update rates).

Additional context

CWood-sdf avatar Dec 20 '24 03:12 CWood-sdf

I really recommend you to spend some time reading the Flight class, as most of your answers will be found there.

RocketPy has different flight phases (rail, free flight, descent under parachute). When a parachute is deployed, there's no reason - simulation-wise - to keep feeding the airbakes, since they will no longer be used.

Just to be clear: are you saying the air brakes do not work after apogee, even when you launch the rocket without parachutes? If so, then we have a good problem to investigate.

All in all, I believe your issue's title and request seems pretty fair. We can discuss more before solving this.

Gui-FernandesBR avatar Dec 20 '24 06:12 Gui-FernandesBR

Sorry if I was not very clear, I do not want to update airbrakes code after the burnout/parachute phase. I would like something that can invoke listening/observing callbacks during the entire simulation lifecycle. I checked all the def add_ functions in the Flight class and I could not find something that matched this description.

CWood-sdf avatar Dec 20 '24 14:12 CWood-sdf