// Start is called before the first frame update void Start() { body = GetComponent <Rigidbody>(); navigator = GetComponent <PathNavigator>(); autopilot = GetComponent <Autopilot>(); vehicle = GetComponent <Vehicle>(); workers = new List <IWorker>(); int[] inputShape = null; for (int i = 0; i < 5; i++) { var model = ModelLoader.LoadFromStreamingAssets(modelName + i + ".nn"); workers.Add(WorkerFactory.CreateWorker(WorkerFactory.Type.CSharpBurst, model)); inputShape = model.inputs[0].shape; } classificationWorker = WorkerFactory.CreateWorker(WorkerFactory.Type.CSharpBurst, ModelLoader.LoadFromStreamingAssets(modelName + "C" + ".nn")); numObservations = (inputShape.Last() - 1) / 3; inputs = new Tensor(new TensorShape(inputShape)); estimations = new List <float>(); curvature = new float[numObservations]; camber = new float[numObservations]; inclination = new float[numObservations]; rearLeft = vehicle.wheels.Where(w => w.localAttachmentPosition.z < 0).Where(w => w.localAttachmentPosition.x < 0).ToArray(); rearRight = vehicle.wheels.Where(w => w.localAttachmentPosition.z < 0).Where(w => w.localAttachmentPosition.x > 0).ToArray(); }
public static void CargobobMagnet() { var player = API.GetPlayerPed(-1); if (API.IsPedInAnyHeli(player)) { var heli = API.GetVehiclePedIsIn(player, false); var pilot = API.GetPedInVehicleSeat(heli, -1); if (pilot != player && !Autopilot.IsOwnedAutopilot(pilot)) { Common.Notification("Player is not the pilot of this heli"); return; } if (API.IsCargobobMagnetActive(heli)) { API.SetCargobobPickupMagnetActive(heli, false); API.RetractCargobobHook(heli); } else { API.EnableCargobobHook(heli, 1); API.SetCargobobPickupMagnetActive(heli, true); } } else { Common.Notification("Player is not in a heli"); } }
public static AI CreateAI(AIParameters parameters, Spaceship spaceship, Autopilot autopilot, Spaceship mother) { if (parameters.AIType == AIType.Player) { return(null); } else if (parameters.AIType == AIType.PassiveAI) { return(new PassiveAI(spaceship, autopilot)); } else if (parameters.AIType == AIType.SimpleAI) { return(new SimpleAI(parameters, spaceship, autopilot)); } else if (parameters.AIType == AIType.DroneAI) { return(new DroneAI(parameters, spaceship, autopilot, mother)); } else if (parameters.AIType == AIType.TurretAI) { return(new TurretAI(parameters, spaceship, autopilot)); } else { return(null); } }
public SimpleAI(AIParameters parameters, Spaceship spaceship, Autopilot autopilot) : base(spaceship, autopilot) { Home = spaceship.Position; AgroDistance = Helpers.ParseFloat(parameters.Param1); DeagroDistance = Helpers.ParseFloat(parameters.Param2); DeagroTime = Helpers.ParseFloat(parameters.Param3); }
private JoystickOutput GetJoystickInput(long totalTicks) { // Get user joystick input or autopilot input based on previous state #if XBOX if (IsPlayerControlled) { return(GetUserInput()); } #else if (_useJoystick && IsPlayerControlled) { return(GetUserInput()); } #endif // Hover if button is pressed if (Keyboard.GetState().IsKeyDown(Keys.H)) { return(Autopilot.GetHoverOutput(AutopilotAwareState, totalTicks, out _controlGoal)); } // Use assisted autopilot if enabled in settings to control joystick output if (_scenario.AssistedAutopilot) { return(Autopilot.GetAssistedOutput(GetUserInput(), AutopilotAwareState, totalTicks, out _controlGoal)); } // Use autopilot to control joystick output return(Autopilot.GetOutput(AutopilotAwareState, totalTicks, out _controlGoal)); }
public static void TeleportToClosestVehicle(bool forcePassenger = false) { var vehicles = Vehicles.Get(); if (Common.GetClosestEntity(vehicles, out int vehicle)) { if (Vehicles.GetFreeSeat(vehicle, out int seat, forcePassenger)) { var player = API.GetPlayerPed(-1); API.SetPedIntoVehicle(player, vehicle, seat); } else { if (!forcePassenger) { var driver = API.GetPedInVehicleSeat(vehicle, -1); if (Autopilot.IsOwnedAutopilot(driver)) { API.DeletePed(ref driver); var player = API.GetPlayerPed(-1); API.SetPedIntoVehicle(player, vehicle, -1); return; } } Common.Notification("Closest vehicle doesn't have a free seat"); } }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.None; try { api = new WcPbApi(); api.Activate(Me); debugPanels = new Dictionary <string, DebugPanel>(); InitDebugPanels(); DebugPanel debugLog = DebugPanelByName("log"); debugLog.Title = "Debug Log"; // The remote control block is the forward reference for this grid. I should probably change this to something else.... remoteControlBlock = GridTerminalSystem.GetBlockWithName("Remote Control") as IMyRemoteControl; situationalAwareness = new SituationalAwareness(api, Me, AccelerationFilterCoeff, DebugPanelByName("sitcon"), DebugPanelByName("track")); navigationSystems = new NavigationSystems(GridTerminalSystem, remoteControlBlock); motionController = new Autopilot(navigationSystems, DebugPanelByName("heading"), DebugPanelByName("thrust")); currentTime = 0; } catch (Exception e) { Echo($"*** Caught exception {e.Message}\n{e.StackTrace}"); } }
public Controller(DroneClient client, AnalyzerOutput output, Config configuration, IoTHubController hubController) { analyzer = output; analyzer.PropertyChanged += Analyzer_PropertyChanged; droneClient = client; this.hubController = hubController; autoPilot = new Autopilot(client); config = configuration; }
public void CreatePlayerParty() { Debug.Log("Creating player party"); //create MacroAIParty for player PlayerParty = GameManager.Inst.NPCManager.MacroAI.GeneratePlayerParty(); PlayerAutopilot = PlayerShip.GetComponent <Autopilot>(); PlayerAutopilot.Initialize(PlayerParty, GameManager.Inst.NPCManager.AllFactions["player"]); Debug.Log("Creating player party DONE"); }
public DroneAI(AIParameters parameters, Spaceship spaceship, Autopilot autopilot, Spaceship mother) : base(spaceship, autopilot) { Mother = mother; AgroDistance = Helpers.ParseFloat(parameters.Param1); DeagroDistance = Helpers.ParseFloat(parameters.Param2); DeagroTime = Helpers.ParseFloat(parameters.Param3); OrbitAngle = 0f; }
public ShipBase SpawnPlayerShip(Loadout loadout, string factionID, MacroAIParty party) { ShipBase ship = GameManager.Inst.PlayerControl.PlayerShip; BuildShip(ship, loadout, factionID, party); Autopilot pilot = GameManager.Inst.PlayerControl.PlayerAutopilot; pilot.AvoidanceDetector = ship.MyReference.AvoidanceDetector; pilot.AvoidanceDetector.ParentShip = ship; //load weapons foreach (WeaponJoint joint in ship.MyReference.WeaponJoints) { joint.ParentShip = ship; foreach (KeyValuePair <string, InvItemData> jointSetup in loadout.WeaponJoints) { if (jointSetup.Key == joint.JointID && jointSetup.Value != null) { joint.LoadWeapon(jointSetup.Value); } } } for (int i = 0; i < loadout.Defensives.Count; i++) { if (loadout.Defensives[i] != null && loadout.Defensives[i].Item.GetStringAttribute("Defensive Type") == "Countermeasure") { CMDispenser dispenser = new CMDispenser(); dispenser.ParentShip = ship; dispenser.AmmoID = loadout.Defensives[i].RelatedItemID; dispenser.Type = DefensiveType.Countermeasure; ship.MyReference.Defensives.Add(dispenser); } } //load ammo bay ship.Storage.AmmoBayItems = new Dictionary <string, InvItemData>(); foreach (InvItemData item in loadout.AmmoBayItems) { ship.Storage.AmmoBayItems.Add(item.Item.ID, item); } ship.Storage.CargoBayItems = new List <InvItemData>(); foreach (InvItemData item in loadout.CargoBayItems) { ship.Storage.CargoBayItems.Add(item); } //In$8177BB //load power management setting ship.CurrentPowerMgmtButton = loadout.CurrentPowerMgmtButton; return(ship); }
public void Reset(TimeSpan totalGameTime, HelicopterScenario scenario, NavigationMap heightmap) { Console.WriteLine(@"Resetting helicopter."); _scenario = scenario; // TODO We would rather want to do Autopilot.Reset() than this fugly code Autopilot.IsAtDestination = false; Autopilot = Autopilot.Clone(); Autopilot.Task = scenario.Task.Clone(); Autopilot.Map = heightmap; Vector3 startPosition = scenario.StartPosition; Vector3 startVelocity = Vector3.Zero; Vector3 startAcceleration = Vector3.Zero; Quaternion startOrientation = Quaternion.Identity; if (Task.HoldHeightAboveGround > 0) { startPosition.Y = Autopilot.Map.GetAltitude(VectorHelper.ToHorizontal(startPosition)) + Task.HoldHeightAboveGround; } var startPhysicalState = new PhysicalHeliState( startOrientation, startPosition, startVelocity, startAcceleration); var initialState = new SimulationStepResults(startPhysicalState, totalGameTime); _physicalState = startPhysicalState; // Re-create the state provider when resetting because some sensors will have to re-initialize. _physics = new HeliPhysics(_collision, UseTerrainCollision); _sensors = new SensorModel(_sensorSpecifications, Autopilot.Map, startPosition, startOrientation); _perfectStateProvider = new PerfectState(); _estimatedStateProvider = new SensorEstimatedState(_sensors, startPhysicalState); // Wait for state to become stable. // while (!_perfectStateProvider.Ready) // { // TODO GPS will require N seconds of startup time // _perfectStateProvider.Update(initialState, 0, 0, new JoystickOutput()); // Sensors.Update(initialState, new JoystickOutput()); // Thread.Sleep(100); // } // When resetting, use perfect state as starting point. // TODO It should not be necessary to create this waypoint since it should never be used for navigation! Delete if safe. // Use start position and start orientation instead. const float defaultWaypointRadius = 5; var startWaypoint = new Waypoint(startPosition, 0, WaypointType.Intermediate, defaultWaypointRadius); _trueState = StateHelper.ToHeliState(startPhysicalState, GetHeightAboveGround(startPhysicalState.Position), startWaypoint, new JoystickOutput()); _estimatedState = _trueState; Log.Clear(); }
// Make sure '_autopilot' variable is initialized with an object private void InitializeAutopilot() { if (_autopilot != null) { return; } _autopilot = new Autopilot(_droneClient); _autopilot.OnOutOfObjectives += Autopilot_OnOutOfObjectives; }
private void Awake() { autopilot = GetComponent <Autopilot>(); navigator = GetComponent <PathNavigator>(); pathObservations = GetComponent <PathObservations>(); logToConsole = false; lastUndersteerError = 0f; navigator.Reset(); CreateProfile(); }
public void TestElementWithParams() { var elem = new Autopilot("name"); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Autopilot>name</Autopilot>", elem.ToString() ); }
public void TestEmptyElement() { var elem = new Autopilot(); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Autopilot></Autopilot>", elem.ToString() ); }
public static int[] SetSwitches(Ruta ruta, Autopilot autopilot,int screen, bool cam) { byte sw = (byte)(screen & 0x3); sw |= (byte)(((int)autopilot) << 2); sw |= (byte)(((int)ruta) << 4); if (!cam) sw |= 0x40; return build_packet((byte)REGS.Switches, new byte[] { sw }); }
public MiningRoutines(MyIni ini, CommandLine cmd, Autopilot ap, ISaveManager manager) { this.ap = ap; var keys = new List <MyIniKey>(); ini.GetKeys("mining-routine", keys); keys.ForEach(k => this.miningRoutes[k.Name] = ini.Get(k).ToInt32()); cmd.RegisterCommand(new Command("mine-recall", Command.Wrap(this._recall), "Goes to the given mining position", nArgs: 1)); cmd.RegisterCommand(new Command("mine-save", Command.Wrap(this._savePos), "Saves the current mining position", nArgs: 1)); manager.AddOnSave(_save); }
void Start() { Go.defaultEaseType = GoEaseType.CircIn; score = GameObject.Find("Score").GetComponent <Score>(); spawner = GameObject.Find("Asteroid Spawner").GetComponent <AsteroidSpawner>(); canvas = GameObject.Find("Canvas").GetComponent <Canvas>(); autopilot = GameObject.Find("Autopilot").GetComponent <Autopilot>(); welcomeText = GameObject.Find("WelcomeText").GetComponent <Text>(); autopilot.enabled = false; }
public void TestElementWithTextNode() { var elem = new Autopilot(); elem.AddText("Here is the content"); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Autopilot>Here is the content</Autopilot>", elem.ToString() ); }
// Make sure '_autopilot' variable is initialized with an object private void CreateAutopilot() { if (_autopilot != null) { return; } _autopilot = new Autopilot(_droneClient); _autopilot.OnOutOfObjectives += Autopilot_OnOutOfObjectives; _autopilot.BindToClient(); _autopilot.Start(); }
public override void Update(Dictionary <int, RadarProfile> radarProfiles) { int closestEnemyUID = Omniscience.NULL_UID; float closestEnemyDistance = float.MaxValue; foreach (RadarProfile radarProfile in radarProfiles.Values) { if (radarProfile.Team != Spaceship.Team) { float distance = (Spaceship.Position - radarProfile.Position).magnitude; if (distance < closestEnemyDistance) { closestEnemyUID = radarProfile.UID; closestEnemyDistance = distance; } } } if (closestEnemyDistance < AgroDistance) { Aggroed = true; AggroCountdown = DeagroTime; } else if (Aggroed == true && closestEnemyDistance > DeagroDistance) { AggroCountdown -= Time.deltaTime; if (AggroCountdown <= 0f) { Aggroed = false; } } if (Aggroed & closestEnemyUID != Omniscience.NULL_UID) { Autopilot.SetTarget(radarProfiles[closestEnemyUID].Position, AutopilotBehaviour.Seek); Spaceship.SelectTarget(closestEnemyUID); Spaceship.QueueAttack(1); } else { Spaceship.DropTarget(); if (Mother == null) { Autopilot.Halt(); } else { OrbitAngle += ORBIT_ANGULAR_SPEED * Time.deltaTime; Vector2 displacement = ORBIT_DISTANCE * (Quaternion.Euler(0, 0, OrbitAngle) * Vector2.right); Autopilot.SetTarget(Mother.Position + displacement, AutopilotBehaviour.Seek); } } }
protected override void OnCreate(Bundle savedInstanceState) { Autopilot.AutomaticTakeOff(this.ApplicationContext); TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App()); }
public void TestElementWithExtraAttributes() { var elem = new Autopilot(); elem.SetOption("newParam1", "value"); elem.SetOption("newParam2", 1); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Autopilot newParam1=\"value\" newParam2=\"1\"></Autopilot>", elem.ToString() ); }
public Spaceship(IMyGridTerminalSystem system, IMyIntergridCommunicationSystem igc) { this.system = system; this.igc = igc; cpu = FindRunningPB(system); control = FindBlockOfType <IMyRemoteControl>(system, this, Settings.TAG); connector = FindBlockOfType <IMyShipConnector>(system, this, Settings.TAG); debug = FindBlockOfType <IMyTextPanel>(system, this, Settings.TAG); if (debug == null) { IMyCockpit cockpit = FindBlockOfType <IMyCockpit>(system, this, Settings.TAG); if (cockpit.SurfaceCount > 0) { debug = cockpit.GetSurface(0); } } debug.Font = "Monospace"; debug.ContentType = ContentType.TEXT_AND_IMAGE; /* * screen = cockpit.GetSurface(0); * screen.ContentType = ContentType.SCRIPT; * MySpriteDrawFrame frame = screen.DrawFrame(); * * * frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", new Vector2(0, 0), new Vector2(512, 512), Color.Black)); * frame.Add(MySprite.CreateText("Ftiaxe Me!!!", "DEBUG", Color.White)); * frame.Dispose(); */ listener = igc.RegisterBroadcastListener(Settings.COMM_CHANNEL); listener = igc.RegisterBroadcastListener(Settings.COMM_CHANNEL); listener.SetMessageCallback(Settings.COMM_CHANNEL); thrusters = new ThrustersManager(this, control, system); autopilot = new Autopilot(this, control, FindBlockOfType <IMyGyro>(system, this)); cas = new CollisionAvoidanceSystem(this); fd = new FlightDirector(this); if (connector.Status == MyShipConnectorStatus.Connected) { flags = SpaceshipFlags.Dock; } else { flags = SpaceshipFlags.Idle; } }
private static void AbortAutopilot(Autopilot ____autopilot, ref Vector3 __result) { if (____autopilot.IsFlyingToDestination() && __result.magnitude > 0.1f) { ____autopilot.Abort(); } if (lowSpeedMode) { __result.x = Mathf.Clamp(__result.x, -lowSpeedMax, lowSpeedMax); __result.y = Mathf.Clamp(__result.y, -lowSpeedMax, lowSpeedMax); __result.z = Mathf.Clamp(__result.z, -lowSpeedMax, lowSpeedMax); } }
public override void OnInspectorGUI() { Autopilot a = (Autopilot)target; if (DrawDefaultInspector()) { if (a.Chadburn != lastChadburn) { a.Chadburn = a.Chadburn; // Triggers the property setter } } lastChadburn = a.Chadburn; }
public static int[] SetSwitches(Ruta ruta, Autopilot autopilot, int screen, bool cam) { byte sw = (byte)(screen & 0x3); sw |= (byte)(((int)autopilot) << 2); sw |= (byte)(((int)ruta) << 4); if (!cam) { sw |= 0x40; } return(build_packet((byte)REGS.Switches, new byte[] { sw })); }
public void TestAllowGenericChildNodes() { var elem = new Autopilot(); elem.AddChild("generic-tag").AddText("Content").SetOption("tag", true); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Autopilot>" + Environment.NewLine + " <generic-tag tag=\"True\">Content</generic-tag>" + Environment.NewLine + "</Autopilot>", elem.ToString() ); }
public void TestMixedContent() { var elem = new Autopilot(); elem.AddText("before") .AddChild("Child").AddText("content"); elem.AddText("after"); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Autopilot>before<Child>content</Child>after</Autopilot>", elem.ToString() ); }
public void Initialize ( Liscense liscense, AIParameters aiParameters, Dictionary <FlotsamType, int> lootDrops, Hull hull, Engine engine, Reactor reactor, ShieldGenerator shieldGenerator, LifeSupport lifeSupport, Weapon[] weapons ) { Hull = hull; Engine = engine; Reactor = reactor; ShieldGenerator = shieldGenerator; LifeSupport = lifeSupport; Weapons = weapons; WeaponInputs = new bool[Weapons.Length]; base.Initialize ( thrustForce: Engine.ThrustForceMultiplier * Mathf.PI * Mathf.Pow(Hull.Size, 2), turnForce: Engine.TurnForceMultiplier * Mathf.PI * Mathf.Pow(Hull.Size, 2), maximumSpeed: Engine.MaximumSpeed, mass: Hull.Mass ); transform.localScale = new Vector2(Hull.Size, Hull.Size); Liscense = liscense; SelectedWeapon = 0; ShowFDN = (Team != 0); Immunities = new List <AttackImmunityRecord>(); Autopilot = new FastAutopilot(this); AI = AI.CreateAI(aiParameters, this, Autopilot, Liscense.Mother); LootDrops = lootDrops; Credits = 0f; Scrap = Hull.HullSpace; Bullets = 0; Rockets = 0; Mines = 0; Drones = 0; Turrets = 0; ModelSpecificInitialization(); }
void Start() { Go.defaultEaseType = GoEaseType.CircIn; score = GameObject.Find("Score").GetComponent<Score>(); spawner = GameObject.Find("Asteroid Spawner").GetComponent<AsteroidSpawner>(); canvas = GameObject.Find("Canvas").GetComponent<Canvas>(); autopilot = GameObject.Find("Autopilot").GetComponent<Autopilot>(); welcomeText = GameObject.Find("WelcomeText").GetComponent<Text>(); autopilot.enabled = false; }