예제 #1
0
            // Constructor
            public AutoPilotManager(IMyGridTerminalSystem myGridTerminalSystem, UIManager uIManager, float powerFactor, int precisionFactor, int scanDistance)
            {
                List <IMyRemoteControl> controllers = new List <IMyRemoteControl>();

                myGridTerminalSystem.GetBlocksOfType(controllers);

                foreach (IMyRemoteControl c in controllers)
                {
                    remotePilot      = c;
                    controlReference = remotePilot;
                }
                wheelController      = new WheelController(myGridTerminalSystem, controlReference);
                this.powerFactor     = powerFactor;
                this.precisionFactor = precisionFactor;
                maxScanDistance      = scanDistance;
                state               = PilotState.DRIVING;
                this.uIManager      = uIManager;
                collisionController = new CollisionController(myGridTerminalSystem, remotePilot.GetValueBool("CollisionAvoidance"));
                uIManager.printOnScreens("service", $"Found {collisionController.cameras.Count} cameras for collision detection.");
            }
예제 #2
0
            private double Move()
            {
                double destination = UpdatePosition();

                remotePilot.HandBrake = false;
                double tillCollision = -1;

                if (remotePilot.GetValueBool("CollisionAvoidance") && state == PilotState.DRIVING)
                {
                    double scanDistance = Math.Min(destination, maxScanDistance);
                    tillCollision = collisionController.checkForCollisions(scanDistance);
                }
                if (tillCollision != -1)
                {// collision detected, reduce speed and steer right
                    state = PilotState.AVOID;

                    Vector3D targetPosition = Vector3D.Transform(new Vector3D(10, 0, 10), controlReference.WorldMatrix);
                    addObjectiveFirst(targetPosition);
                    uIManager.printOnScreens("service", "[SYS] Avoiding collision");
                    return(destination);
                }
                Cruise(destination, remotePilot.SpeedLimit, RelativeTarget); // Apply Power
                return(destination);
            }