Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Acceleration is zero in SimulationListener's SimulationStatus #2443

Open
Graicc opened this issue Jan 20, 2024 · 2 comments
Open

[Bug] Acceleration is zero in SimulationListener's SimulationStatus #2443

Graicc opened this issue Jan 20, 2024 · 2 comments
Assignees
Labels

Comments

@Graicc
Copy link

Graicc commented Jan 20, 2024

Describe the bug

The acceleration in SimulationStatus.getRocketAcceleration() is (0,0,0) until apogee for all simulation listeners. On unstable (tested on b9084), postAccelerationCalculation contains the acceleration data, but the status still contains zero. On 23.09, the acceleration data in postAccelerationCalculation is null.

To Reproduce

public class MyListener extends AbstractSimulationListener {
	@Override
	public void postStep(SimulationStatus status) throws SimulationException {
		var accel = status.getRocketAcceleration(); // is (0,0,0)
	}
	
	@Override
	public AccelerationData postAccelerationCalculation(SimulationStatus status, AccelerationData acceleration) throws SimulationException {
		var goodAccel = acceleration.getLinearAccelerationWC(); // Correct
		var accel = status.getRocketAcceleration(); // is (0,0,0)
	}
}

Screenshots / .ork file

image
Only the z component is shown in the screenshot, but all fields were 0.

OpenRocket version

unstable

What platform are you running on?

Windows

Additional context

Migrated from conversation in the OpenRocket Discord here: https://discord.com/channels/1073297014814691328/1078118846818439199/1197974403049336892

The last message, from @JoePfeiffer:

As you've discovered, the RK4 stepper doesn't set the acceleration in the simulation status; that doesn't end up getting used until the landing stepper starts up. I'm not sure at the moment whether the bug is not putting the acceleration data in the status or if it's having the place in the status to put it, but it's clearly one or the other. The store actually seems like the better place to have it anyway, so go ahead and keep using that.

@Graicc Graicc added the bug label Jan 20, 2024
@SiboVG
Copy link
Member

SiboVG commented Jan 20, 2024

Thanks for filing the issue!

@JoePfeiffer
Copy link
Contributor

Storage of simulation variables is kind of a mess right now. SimulationStatus mainly contains what I think of as status variables, like the event queue, whether we've cleared the launch rod, and stuff like that. It also contains things like the current rocket position, and thinks it contains the current acceleration. For the RK4 stepper, we both have an RK4SimulationStatus that extends SimulationStatus and adds a few things that seem to me like they belong in SimulationStatus (like max Z acceleration encountered), and adds a private static DataStore class that contains the data necessary for the stepper (like the acceleration, thrust force, and more). Meanwhile, the "official" place all the data is stored after a simulation step is in a FlightDataBranch. I cleaned up (and fixed) a little of this last year (see #2352), but am hoping to do more after NARCON.

The Euler stepper actually does put acceleration data in the SimulationStatus, something I should have fixed back when I refactored it last year, but didn't.

This, along with improving simulation step size calculation, is the main stuff I want to work on right now.

@JoePfeiffer JoePfeiffer self-assigned this Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants