Launch rod velocity in FlightData
authorplaa <plaa@180e2498-e6e9-4542-8430-84ac67f01cd8>
Sun, 5 Sep 2010 08:40:47 +0000 (08:40 +0000)
committerplaa <plaa@180e2498-e6e9-4542-8430-84ac67f01cd8>
Sun, 5 Sep 2010 08:40:47 +0000 (08:40 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@75 180e2498-e6e9-4542-8430-84ac67f01cd8

ChangeLog
src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java
src/net/sf/openrocket/simulation/FlightData.java
src/net/sf/openrocket/simulation/RK4SimulationStepper.java

index e7d7cb7692371c5488a06addb879c9e42e1b197d..2bef3cadcda616579490764a367b422252d43ceb 100644 (file)
--- 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
index 47e76a4f636e00ad9de4d35036d7d4692b6d7579..090ee3ea0e4cae923ba1a7637133b92bafdfc6d0 100644 (file)
@@ -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);
index 8d388afba6ff6fdd66d94bcdcf6e5921218c554a..57fd7c8d541b49ecc84cd84de781db5d742d7a7b 100644 (file)
@@ -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 <sampo.niskanen@iki.fi>
  */
 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<Double> time = branch.get(FlightDataType.TYPE_TIME);
                List<Double> 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<Double> 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);
        }
        
        
index 45be122dbdf215f7db4594b1f5b816ff5eaaaa58..8ef74c8581c40791ffab558f99231ad74f8a1ed7 100644 (file)
@@ -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());
                }