Ejemplo n.º 1
0
        /// <summary>
        /// Add a state-control pair to the current configuration. See the enums
        /// State and Control in TrimAxis.h for the available options.
        /// Will fail if the given state is already configured.
        /// </summary>
        /// <param name="state">the accel or other condition to zero</param>
        /// <param name="control">the control used to zero the state</param>
        /// <returns>true if add is successful</returns>
        public bool AddState(StateType state, ControlType control)
        {
            bool result = true;

            mode = TrimMode.Custom;
            //vector <TrimAxis*>::iterator iAxes = TrimAxes.begin();
            foreach (TrimAxis iAxes in TrimAxes)
            {
                if (iAxes.GetStateType() == state)
                {
                    result = false;
                }
            }
            if (result)
            {
                TrimAxes.Add(new TrimAxis(fdmex, fgic, state, control));

                sub_iterations = new double[TrimAxes.Count];
                successful     = new double[TrimAxes.Count];
                solution       = new bool[TrimAxes.Count];
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Clear all state-control pairs and set a predefined trim mode
        /// </summary>
        /// <param name="tm">the set of axes to trim. Can be:
        /// tLongitudinal, tFull, tGround, tCustom, or tNone</param>
        public void SetMode(TrimMode tm)
        {
            ClearStates();
            mode = tm;
            switch (tm)
            {
            case TrimMode.Full:
                if (log.IsDebugEnabled)
                {
                    log.Debug("  Full Trim");
                }
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Wdot, ControlType.Alpha));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Udot, ControlType.Throttle));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Qdot, ControlType.PitchTrim));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Hmgt, ControlType.Beta));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Vdot, ControlType.Phi));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Pdot, ControlType.Aileron));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Rdot, ControlType.Rudder));
                break;

            case TrimMode.Longitudinal:
                if (log.IsDebugEnabled)
                {
                    log.Debug("  Longitudinal Trim");
                }
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Wdot, ControlType.Alpha));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Udot, ControlType.Throttle));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Qdot, ControlType.PitchTrim));
                break;

            case TrimMode.Ground:
                if (log.IsDebugEnabled)
                {
                    log.Debug("  Ground Trim");
                }
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Wdot, ControlType.AltAGL));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Qdot, ControlType.Theta));
                //TrimAxes.push_back(new TrimAxis(fdmex,fgic,tPdot,tPhi ));
                break;

            case TrimMode.Pullup:
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Nlf, ControlType.Alpha));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Udot, ControlType.Throttle));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Qdot, ControlType.PitchTrim));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Hmgt, ControlType.Beta));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Vdot, ControlType.Phi));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Pdot, ControlType.Aileron));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Rdot, ControlType.Rudder));
                break;

            case TrimMode.Turn:
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Wdot, ControlType.Alpha));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Udot, ControlType.Throttle));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Qdot, ControlType.PitchTrim));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Vdot, ControlType.Beta));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Pdot, ControlType.Aileron));
                TrimAxes.Add(new TrimAxis(fdmex, fgic, StateType.Rdot, ControlType.Rudder));
                break;

            case TrimMode.Custom:
            case TrimMode.None:
                break;
            }
            //cout + "TrimAxes.size(): " + TrimAxes.size() + endl;
            sub_iterations = new double[TrimAxes.Count];
            successful     = new double[TrimAxes.Count];
            solution       = new bool[TrimAxes.Count];
            current_axis   = 0;
        }