Exemplo n.º 1
0
        public void UpdateTrajectoryModel(double setThrust, double setGravity, double setInitSpeed, double setParachuteReleaseHeight, double setDropHeight,
                                          double setTargetDescentVelocityLarge, double setTargetDescentVelocitySmall, double setTargetDescentVelocitySmallAltitude)
        {
            guidanceTrajectory = new TrajectoryModel(setThrust, setGravity, setInitSpeed, setParachuteReleaseHeight, setDropHeight, setTargetDescentVelocityLarge,
                                                     setTargetDescentVelocitySmall, setTargetDescentVelocitySmallAltitude);
            AxialAlpha   = new AxialThruster(setThrust);
            AxialBeta    = new AxialThruster(setThrust);
            AxialCharlie = new AxialThruster(setThrust);

            altitude = setParachuteReleaseHeight;
            velocity = setInitSpeed;
            PrescribedIgnitionAltitude = setParachuteReleaseHeight;
        }
        /// <summary>
        /// The testing method for the Trajectory Model
        /// </summary>
        /// <returns>Returns success or failure status values based on tests</returns>
        public bool SelfTest()
        {
            /* For these test cases we test 15 different test cases looking for expected, manually calculated outputs with a known scenario
             *  Scenario -
             *    Gravity = 8 m/s^2
             *    Initial Speed = 8 m/s
             *      Parachute Release Height = 5000m
             *      Drop Height = 5m
             *      Target Descent Velocity Large = 100 m/s
             *      Target Descent Velocity Small = 5 m/s
             *      Target Descent Velocity Altitude = 500m
             *      Thruster Thrust = 24m/s^2
             *
             *  Test Cases (form: altitude, descent velocity) - NOTE: 0.33333333333333331 is used for 1/3 throttle calculation due to under the hood math calculations and comparisons in c#
             *  10000m, 1000m/s = 0 throttle
             *  10000m, 100m/s = 0 throttle;
             *  10000m, 0m/s = 0 throttle
             *  4999m, 500m/s = 1 throttle;
             *  4999m, 100m/s = 0.33333333333333331 throttle;
             *  4999m, 0m/s = 0 throttle;
             *  501m, 500m/s = 1 throttle;
             *  501m, 100m/s = 0.33333333333333331 throttle;
             *  501m, 0m/2 = 0 throttle;
             *  250m, 75m/s = 1 throttle;
             *  250m, 5m/s = 0.33333333333333331 throttle;
             *  250m, 0m/s = .125 throttle;
             *  4m, 100m/s = 0 throttle;
             *  4m, 5m/s = 0 throttle;
             *  4m, 0m/s = 0 throttle;
             */
            bool            returnVal           = true;
            TrajectoryModel testTrajectoryModel = new TrajectoryModel(24, 8, 8, 5000, 5, 100, 5, 500);

            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(10000, 1000) == 0);
            }
            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(10000, 100) == 0);
            }
            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(10000, 0) == 0);
            }
            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(4999, 500) == 1);
            }
            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(4999, 100) == 0.33333333333333331);
            }
            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(4999, 0) == 0);
            }
            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(501, 500) == 1);
            }
            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(501, 100) == 0.33333333333333331);
            }
            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(501, 0) == 0);
            }
            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(250, 75) == 1);
            }
            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(250, 5) == 0.33333333333333331);
            }
            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(250, 0) == .125);
            }
            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(4, 100) == 0);
            }
            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(4, 5) == 0);
            }
            if (returnVal == true)
            {
                returnVal = (testTrajectoryModel.calcThrottle(4, 0) == 0);
            }

            return(returnVal);
        }