From 94b07c0a5f468ca6ba850d5099d44f4ec2735fc5 Mon Sep 17 00:00:00 2001 From: plaa Date: Sun, 5 Sep 2010 08:40:47 +0000 Subject: [PATCH] Launch rod velocity in FlightData git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@75 180e2498-e6e9-4542-8430-84ac67f01cd8 --- ChangeLog | 5 +++ .../file/openrocket/OpenRocketLoader.java | 3 +- .../sf/openrocket/simulation/FlightData.java | 41 ++++++++++++++++++- .../simulation/RK4SimulationStepper.java | 2 +- 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e7d7cb76..2bef3cad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-09-04 Sampo Niskanen + + * Added launch rod velocity to FlightData + * [BUG] Total velocity was measured from airspeed + 2010-09-03 Sampo Niskanen * Released version 1.1.1 diff --git a/src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java b/src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java index 47e76a4f..090ee3ea 100644 --- a/src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java +++ b/src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java @@ -1534,8 +1534,9 @@ class FlightDataHandler extends ElementHandler { } catch (NumberFormatException ignore) { } + // TODO: HIGH: Store and load launchRodVelocity data = new FlightData(maxAltitude, maxVelocity, maxAcceleration, maxMach, - timeToApogee, flightTime, groundHitVelocity); + timeToApogee, flightTime, groundHitVelocity, Double.NaN); } data.getWarningSet().addAll(warningSet); diff --git a/src/net/sf/openrocket/simulation/FlightData.java b/src/net/sf/openrocket/simulation/FlightData.java index 8d388afb..57fd7c8d 100644 --- a/src/net/sf/openrocket/simulation/FlightData.java +++ b/src/net/sf/openrocket/simulation/FlightData.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.List; import net.sf.openrocket.aerodynamics.WarningSet; +import net.sf.openrocket.logging.LogHelper; +import net.sf.openrocket.startup.Application; import net.sf.openrocket.util.MathUtil; import net.sf.openrocket.util.Mutable; @@ -21,6 +23,7 @@ import net.sf.openrocket.util.Mutable; * @author Sampo Niskanen */ public class FlightData { + private static final LogHelper log = Application.getLogger(); /** * An immutable FlightData object with NaN data. @@ -45,6 +48,7 @@ public class FlightData { private double timeToApogee = Double.NaN; private double flightTime = Double.NaN; private double groundHitVelocity = Double.NaN; + private double launchRodVelocity = Double.NaN; /** @@ -66,10 +70,11 @@ public class FlightData { * @param timeToApogee time to apogee. * @param flightTime total flight time. * @param groundHitVelocity ground hit velocity. + * @param launchRodVelocity TODO */ public FlightData(double maxAltitude, double maxVelocity, double maxAcceleration, double maxMachNumber, double timeToApogee, double flightTime, - double groundHitVelocity) { + double groundHitVelocity, double launchRodVelocity) { this.maxAltitude = maxAltitude; this.maxVelocity = maxVelocity; this.maxAcceleration = maxAcceleration; @@ -77,6 +82,7 @@ public class FlightData { this.timeToApogee = timeToApogee; this.flightTime = flightTime; this.groundHitVelocity = groundHitVelocity; + this.launchRodVelocity = launchRodVelocity; } @@ -161,6 +167,10 @@ public class FlightData { return groundHitVelocity; } + public double getLaunchRodVelocity() { + return launchRodVelocity; + } + /** @@ -183,6 +193,7 @@ public class FlightData { groundHitVelocity = Double.NaN; } + // Time to apogee List time = branch.get(FlightDataType.TYPE_TIME); List altitude = branch.get(FlightDataType.TYPE_ALTITUDE); @@ -206,12 +217,40 @@ public class FlightData { else timeToApogee = Double.NaN; + + // Launch rod velocity + eventloop: for (FlightEvent event : branch.getEvents()) { + if (event.getType() == FlightEvent.Type.LAUNCHROD) { + double t = event.getTime(); + List velocity = branch.get(FlightDataType.TYPE_VELOCITY_TOTAL); + if (velocity == null) { + break; + } + for (int i = 0; i < velocity.size(); i++) { + if (time.get(i) >= t) { + launchRodVelocity = velocity.get(i); + break eventloop; + } + } + } + } + // Max. acceleration (must be after apogee time) if (branch.get(FlightDataType.TYPE_ACCELERATION_TOTAL) != null) { maxAcceleration = calculateMaxAcceleration(); } else { maxAcceleration = Double.NaN; } + + log.info("Computed flight values:" + + " maxAltitude=" + maxAltitude + + " maxVelocity=" + maxVelocity + + " maxAcceleration=" + maxAcceleration + + " maxMachNumber=" + maxMachNumber + + " timeToApogee=" + timeToApogee + + " flightTime=" + flightTime + + " groundHitVelocity=" + groundHitVelocity + + " launchRodVelocity=" + launchRodVelocity); } diff --git a/src/net/sf/openrocket/simulation/RK4SimulationStepper.java b/src/net/sf/openrocket/simulation/RK4SimulationStepper.java index 45be122d..8ef74c85 100644 --- a/src/net/sf/openrocket/simulation/RK4SimulationStepper.java +++ b/src/net/sf/openrocket/simulation/RK4SimulationStepper.java @@ -557,7 +557,7 @@ public class RK4SimulationStepper extends AbstractSimulationStepper { } if (store.flightConditions != null) { - data.setValue(FlightDataType.TYPE_VELOCITY_TOTAL, store.flightConditions.getVelocity()); + data.setValue(FlightDataType.TYPE_VELOCITY_TOTAL, status.getRocketVelocity().length()); data.setValue(FlightDataType.TYPE_MACH_NUMBER, store.flightConditions.getMach()); } -- 2.30.2