Example #1
0
        public override void PreUpdate(double dt)
        {
            // Update sub-model atmospheric properties
            mainRotor.Density = Atmosphere.Density;
            tailRotor.Density = Atmosphere.Density;
            if (Fuselage != null)
            {
                Fuselage.mrdistance = MainRotor.Translation - Fuselage.Translation;
            }
            if (horizontalStabilizer != null)
            {
                horizontalStabilizer.Density = Atmosphere.Density;
            }
            if (verticalStabilizer != null)
            {
                verticalStabilizer.Density = Atmosphere.Density;
            }
            mainRotor.HeightAboveGround = Height - mainRotor.Translation[2];

            // Update sub-model controls
            mainRotor.Collective = FCS.Collective;
            mainRotor.LongCyclic = FCS.LongCyclic;
            mainRotor.LatCyclic  = FCS.LatCyclic;
            tailRotor.Collective = -FCS.Pedal;     // TODO make pedal-collective inversion a parameter, or figure it out

            // Update engine and drivetrain
            if (UseEngineModel)
            {
                if (Engine.phase == Engine.Phase.START && GearBox.autoBrakeRPM > 1e-5)
                {
                    GearBox.BrakeEnabled = false;
                }
                GearBox.MainRotorLoad    = MainRotor.Enabled ? MainRotor.ShaftTorque : 0;
                GearBox.TailRotorLoad    = TailRotor.Enabled ? TailRotor.ShaftTorque : 0;
                GearBox.MainRotorInertia = MainRotor.Enabled ? MainRotor.Inertia : 0;
                GearBox.TailRotorInertia = TailRotor.Enabled ? TailRotor.Inertia : 0;
                GearBox.Update(dt);
                Engine.load    = GearBox.Load;
                Engine.inertia = GearBox.Inertia;
                Engine.Update(dt);
                GearBox.RotspeedDrive = Engine.RotSpeed;
                MainRotor.RotSpeed    = MainRotor.Enabled ? GearBox.MainRotorSpeed : 0;
                TailRotor.RotSpeed    = TailRotor.Enabled ? GearBox.TailRotorSpeed : 0;
            }
        }
Example #2
0
        public override Helicopter LoadDefault()
        {
            Mass    = 2450;
            Inertia = Matrix <double> .Build.DenseOfArray(new double[, ] {
                { 1762, 0, 1085 },
                { 0, 9167, 0 },
                { 1085, 0, 8687 }
            });

            MainRotor             = new Rotor().LoadDefault();
            MainRotor.Translation = Vector <double> .Build.DenseOfArray(new double[] { 0.0071, 0, -1.5164 });

            MainRotor.Rotation = Matrix <double> .Build.RotationY(-6.3 *Math.PI / 180.0);

            TailRotor             = new Rotor().LoadDefaultTailRotor();
            TailRotor.Translation = Vector <double> .Build.DenseOfArray(new double[] { -7.5, 0, -0.8001 });

            TailRotor.Rotation = Matrix <double> .Build.DenseOfArray(new double[, ] {
                { 1, 0, 0 },
                { 0, 0, -1 },
                { 0, 1, 0 }
            });

            HorizontalStabilizer             = new Stabilizer().LoadDefaultHorizontal();
            HorizontalStabilizer.Translation = Vector <double> .Build.DenseOfArray(new double[] { -5.8, 0, -0.5 });

            HorizontalStabilizer.Rotation = Matrix <double> .Build.RotationY(5 *Math.PI / 180.0);

            VerticalStabilizer             = new Stabilizer().LoadDefaultVertical();
            VerticalStabilizer.Translation = Vector <double> .Build.DenseOfArray(new double[] { -7.3, 0, -1.5 });

            VerticalStabilizer.Rotation = Matrix <double> .Build.RotationX(90 *Math.PI / 180.0) * Matrix <double> .Build.RotationY(5 *Math.PI / 180.0);

            Fuselage             = new Fuselage().LoadDefault();
            Fuselage.Translation = Vector <double> .Build.DenseOfArray(new double[] { 0.0178, 0, 0.0127 });

            FCS     = new FlightControlSystem().LoadDefault();
            Engine  = new Engine().LoadDefault();
            GearBox = new GearBox().LoadDefault();

            return(this);
        }
Example #3
0
        public override void PreUpdate(double dt)
        {
            // Update sub-model atmospheric properties
            foreach (var rotor in Rotors)
            {
                rotor.Density           = Atmosphere.Density;
                rotor.HeightAboveGround = Height - rotor.Translation[2];
            }

            // Update sub-model controls
            foreach (var rotor in Rotors)
            {
                rotor.Collective = FCS.Collective;
                if (rotor.Translation.x() > 0)
                {
                    rotor.Collective -= FCS.LongCyclic;
                }
                if (rotor.Translation.x() < 0)
                {
                    rotor.Collective += FCS.LongCyclic;
                }
                if (rotor.Translation.y() > 0)
                {
                    rotor.Collective -= FCS.LatCyclic;
                }
                if (rotor.Translation.y() < 0)
                {
                    rotor.Collective += FCS.LatCyclic;
                }
                if (rotor.direction == Rotor.Direction.CounterClockwise)
                {
                    rotor.Collective += FCS.Pedal;
                }
                if (rotor.direction == Rotor.Direction.Clockwise)
                {
                    rotor.Collective -= FCS.Pedal;
                }

                if (rotor.Collective > 1.0)
                {
                    rotor.Collective = 1.0;
                }
                if (rotor.Collective < -1.0)
                {
                    rotor.Collective = -1.0;
                }
            }

            // Update engine and drivetrain
            if (UseEngineModel)
            {
                if (Engine.phase == Engine.Phase.START && GearBox.autoBrakeRPM > 1e-5)
                {
                    GearBox.BrakeEnabled = false;
                }
                GearBox.MainRotorLoad    = 0;
                GearBox.MainRotorInertia = 0;
                foreach (var rotor in Rotors)
                {
                    if (!rotor.Enabled)
                    {
                        continue;
                    }
                    GearBox.MainRotorLoad    += Math.Abs(rotor.ShaftTorque);
                    GearBox.MainRotorInertia += rotor.Inertia;
                }
                GearBox.TailRotorLoad    = 0;
                GearBox.TailRotorInertia = 0;
                GearBox.Update(dt);
                Engine.load    = GearBox.Load;
                Engine.inertia = GearBox.Inertia;
                Engine.Update(dt);
                GearBox.RotspeedDrive = Engine.RotSpeed;
                foreach (var rotor in Rotors)
                {
                    rotor.RotSpeed = rotor.Enabled ? GearBox.MainRotorSpeed : 0;
                }
            }
        }