public Autopilot(Task t, PIDSetup pidSetup)
 {
     PIDSetup = pidSetup;
     Navigation = NavigationState.EnRoute;
     Actions = Actions.None;
     Task = t;
     Output = new OutputController(pidSetup);
     IsTruePositionWithinRadius = false;
 }
        private static PIDSetup ParsePIDSetup(XmlNode pidSetupNode)
        {
            var result = new PIDSetup();
            result.Name = pidSetupNode.GetAttribute("Name");
            result.PitchAngle = ParsePID(pidSetupNode.SelectSingleNode("PID[@Name='PitchAngle']"));
            result.RollAngle = ParsePID(pidSetupNode.SelectSingleNode("PID[@Name='RollAngle']"));
            result.YawAngle = ParsePID(pidSetupNode.SelectSingleNode("PID[@Name='YawAngle']"));
            result.Throttle = ParsePID(pidSetupNode.SelectSingleNode("PID[@Name='Throttle']"));
            result.ForwardsAccel = ParsePID(pidSetupNode.SelectSingleNode("PID[@Name='Velocity']"));
            result.RightwardsAccel = ParsePID(pidSetupNode.SelectSingleNode("PID[@Name='Velocity']"));

            return result;
        }
        private static PIDSetup ParsePIDSetup(XmlNode pidSetupNode)
        {
            var result = new PIDSetup();

            result.Name            = pidSetupNode.GetAttribute("Name");
            result.PitchAngle      = ParsePID(pidSetupNode.SelectSingleNode("PID[@Name='PitchAngle']"));
            result.RollAngle       = ParsePID(pidSetupNode.SelectSingleNode("PID[@Name='RollAngle']"));
            result.YawAngle        = ParsePID(pidSetupNode.SelectSingleNode("PID[@Name='YawAngle']"));
            result.Throttle        = ParsePID(pidSetupNode.SelectSingleNode("PID[@Name='Throttle']"));
            result.ForwardsAccel   = ParsePID(pidSetupNode.SelectSingleNode("PID[@Name='Velocity']"));
            result.RightwardsAccel = ParsePID(pidSetupNode.SelectSingleNode("PID[@Name='Velocity']"));

            return(result);
        }
        public HelicopterBase(Game game, TestConfiguration testConfiguration, TerrainCollision collision,
                              ICameraProvider cameraProvider, BasicEffect effect, SunlightParameters skyParams, HelicopterScenario scenario,
                              bool playEngineSound, bool isPlayerControlled, bool drawText)
            : base(game)
        {
            if (game == null || cameraProvider == null || effect == null || skyParams == null)
            {
                throw new ArgumentNullException("", @"One or several of the necessary arguments were null!");
            }



            _game = game;
            _testConfiguration    = testConfiguration;
            _sensorSpecifications = testConfiguration.Sensors;
            _collision            = collision;
            _flyBySensors         = testConfiguration.FlyBySensors;

            if (_collision != null)
            {
                _collision.CollidedWithTerrain += gameTime => Crashed(gameTime);
            }


            _basicEffect       = effect;
            _skyParams         = skyParams;
            _scenario          = scenario;
            _drawText          = drawText;
            _cameraProvider    = cameraProvider;
            IsPlayerControlled = isPlayerControlled;

            _playEngineSound = playEngineSound;

            _estimatedState = new HeliState();

            PIDSetup pidSetup = SimulatorResources.GetPIDSetups()[0];

            Autopilot = new Autopilot(_scenario.Task, pidSetup);
            Log       = new List <HelicopterLogSnapshot>();
        }
 public void SetPIDSetup(PIDSetup pidSetup)
 {
     if (_helicopter != null) // && _helicopter.Autopilot != null && _helicopter.Autopilot.Output != null)
         _helicopter.Autopilot.Output.PIDSetup = pidSetup;
     else
         _initialPIDSetup = pidSetup;
 }