Пример #1
0
 // Use this for initialization
 void Start()
 {
     controller = GetComponent <IRobotController>();
     tr         = body.GetComponent <Transform>();
     angles     = new List <float> [8];
     for (int i = 0; i < 8; i++)
     {
         angles[i] = new List <float>();
     }
     times = new List <float>();
 }
Пример #2
0
 public RobotInfo(IRobotController robotController, Location attackLocation, bool turnCompleted, bool hasOutage)
 {
     Team           = robotController.Team;
     RobotType      = robotController.RobotType;
     AttackLocation = attackLocation;
     Location       = robotController.Location;
     Health         = robotController.Health;
     Energy         = robotController.Energy;
     TurnCompleted  = turnCompleted;
     HasOutage      = hasOutage;
     Id             = robotController.Id;
 }
Пример #3
0
    void Update()
    {
        if (infoText == null)
        {
            return;
        }

        sb.Length   = 0;
        sb.Capacity = 16;
        float   speed    = controller.Speed;
        float   steer    = controller.SteerAngle;
        float   vAngle   = controller.VerticalAngle;
        float   throttle = controller.ThrottleInput;
        float   brake    = controller.BrakeInput;
        Vector2 position = new Vector2(controller.Position.x, controller.Position.z);
//		Vector3 position = controller.Position;
        float pitch = controller.Pitch;
        // new: set yaw angle counter-clockwise and relative to positive-x
        float yaw = IRobotController.ConvertAngleToCCWXBased(controller.Yaw);
//		float yaw = controller.Yaw;
        float roll = controller.Roll;

        sb.Append("Throttle: " + throttle.ToString("F1") + "\n");
        sb.Append("Brake: " + brake.ToString("F1") + "\n");
        sb.Append("Steer angle: " + steer.ToString("F4") + "\n");
        sb.Append("Ground speed: " + speed.ToString("F1") + "m/s\n");
        sb.Append("Position: " + position.ToString() + "\n");
        sb.Append("Pitch angle: " + pitch.ToString("F2") + "\n");
        sb.Append("Yaw angle: " + yaw.ToString("F2") + "\n");
        sb.Append("Roll angle: " + roll.ToString("F2") + "\n");
//		sb.Append ( "Camera zoom: " + controller.Zoom.ToString ( "F1" ) + "x\n" );
        sb.Append("Is near objective: " + (controller.IsNearObjective ? "Yes" : "No") + "\n");
        sb.Append("Is picking up:" + (controller.IsPickingUpSample ? "Yes" : "No"));
        infoText.text = sb.ToString();

        if (controller.PickupProgress != -1)
        {
            if (!progressParent.activeSelf)
            {
                progressParent.SetActive(true);
            }
            progressBar.fillAmount = controller.PickupProgress;
        }
        else
        {
            if (progressParent.activeSelf)
            {
                progressParent.SetActive(false);
            }
        }
    }
Пример #4
0
    void Start()
    {
        _socket = GameObject.Find("SocketIO").GetComponent <SocketIOComponent>();
        _socket.On("open", OnOpen);
        _socket.On("data", OnData);
        _socket.On("manual", onManual);
        _socket.On("fixed_turn", OnFixedTurn);
        _socket.On("pickup", OnPickup);
//		_socket.On ( "get_samples", GetSamplePositions );
        robotController   = robotRemoteControl.robot;
        frontFacingCamera = robotController.recordingCam;
        inset1Tex         = new Texture2D(1, 1);
        inset2Tex         = new Texture2D(1, 1);
        inset3Tex         = new Texture2D(1, 1);
    }
Пример #5
0
        public static void ResetSimulation()
        {
            var problemsPath = ProblemsFinder.FindProblemsFolderPath();

            problem = ProblemLoader.LoadProblem(Path.Combine(problemsPath, "prob-150.desc"), null);

            controller = new ScoreNActionsController(problem, new SmartIslandController(problem, null));
            //controller = new ScoreNActionsController(problem, new IslandFinderController(problem, new ScoreNActionsController(problem, new DijkstraController(problem))));
            //controller = new CachingScoreTurnActionsController(problem, new SmartIslandController(problem, null));
            //controller = new ScoreTurnActionsController(problem, new SmartIslandController(problem, null));
            //controller = new ScoreTurnActionsController(problem, new IslandFinderController(problem, new ScoreSingleActionsController(problem, new DijkstraController(problem))));
            //controller = new IslandFinderController(problem, new ScoreSingleActionsController(problem, new DijkstraController(problem)));
            //controller = new ScoreTurnActionsController(problem, new ScoreSingleActionsController(problem, new DijkstraController(problem)));
            start = false;
        }
Пример #6
0
        public Program()
        {
            this.logger = ServiceLocator.Get <ILogger>();

            this.InitializeHardwareInterface("/dev/serial0", 9600);
            this.InitializeVirtualWindowHost();
            this.InitializeRobot();

            this.robotController = new TestController(this.robot);
            //this.robotController = new TrackingController(this.robot);
            //this.robotController = new PebblesController(this.robot);
            //this.robotController = new GateController(this.robot);
            //this.robotController = new DanceController(this.robot);
            this.logger.LogDebug($"Initialized controller '{this.robotController}'");
        }
    void EmitTelemetry(SocketIOEvent obj)
    {
//		Debug.Log ( "Emitting" );
        UnityMainThreadDispatcher.Instance().Enqueue(() =>
        {
            print("Attempting to Send...");

            // Collect Data from the Car
            Dictionary <string, string> data = new Dictionary <string, string>();

            data["steering_angle"] = robotController.SteerAngle.ToString("N4");
//			data["vert_angle"] = robotController.VerticalAngle.ToString ("N4");
            data["throttle"] = robotController.ThrottleInput.ToString("N4");
            data["brake"]    = robotController.BrakeInput.ToString("N4");
            data["speed"]    = robotController.Speed.ToString("N4");
            Vector3 pos      = robotController.Position;
            data["position"] = pos.x.ToString("N4") + robotController.csvSeparatorChar + pos.z.ToString("N4");
            data["pitch"]    = robotController.Pitch.ToString("N4");
            // new: convert the angle to CCW, x-based
            data["yaw"]         = IRobotController.ConvertAngleToCCWXBased(robotController.Yaw).ToString("N4");
            data["roll"]        = robotController.Roll.ToString("N4");
            data["fixed_turn"]  = robotController.IsTurningInPlace ? "1" : "0";
            data["near_sample"] = robotController.IsNearObjective ? "1" : "0";
            data["picking_up"]  = robotController.IsPickingUpSample ? "1" : "0";
            Debug.Log("picking_up is " + robotController.IsPickingUpSample);
            data["sample_count"] = ObjectiveSpawner.samples.Length.ToString();

            StringBuilder sample_x = new StringBuilder();
            StringBuilder sample_y = new StringBuilder();
            for (int i = 0; i < ObjectiveSpawner.samples.Length; i++)
            {
                GameObject go = ObjectiveSpawner.samples[i];
                sample_x.Append(go.transform.position.x.ToString("N2") + robotController.csvSeparatorChar);
                sample_y.Append(go.transform.position.z.ToString("N2") + robotController.csvSeparatorChar);
            }
            if (ObjectiveSpawner.samples.Length != 0)
            {
                sample_x.Remove(sample_x.Length - 1, 1);
                sample_y.Remove(sample_y.Length - 1, 1);
            }
            data["samples_x"] = sample_x.ToString();
            data["samples_y"] = sample_y.ToString();
            data["image"]     = Convert.ToBase64String(CameraHelper.CaptureFrame(frontFacingCamera));

//			Debug.Log ("sangle " + data["steering_angle"] + " vert " + data["vert_angle"] + " throt " + data["throttle"] + " speed " + data["speed"] + " image " + data["image"]);
            _socket.Emit("telemetry", new JSONObject(data));
        });
    }
Пример #8
0
    // Use this for initialization
    void Start()
    {
        string nameOfDiaplay = this.name;

        foots      = new List <GameObject>();
        footPoss   = new List <RectTransform>();
        footImages = new List <Image>();
        offsets    = new float[] { frontFootOffset, rearFootOffset };

        for (int i = 0; i < 4; i++)
        {
            foots.Add(GameObject.Find(nameOfDiaplay + "/Foot" + i));
            footPoss.Add(foots[i].GetComponent <RectTransform>());
            footImages.Add(foots[i].GetComponent <Image>());
        }

        robot = gameSystem.GetComponent <GlobalScript>().workingRobot.GetComponent <IRobotController>();
    }
Пример #9
0
        static void Main(string[] args)
        {
            List <IPosition> objectsOnMap = new List <IPosition>();

            objectsOnMap.Add(new Position(1, 2, CompassDirection.North));
            objectsOnMap.Add(new Position(10, 20, CompassDirection.East));
            objectsOnMap.Add(new Position(50, 40, CompassDirection.South));
            objectsOnMap.Add(new Position(90, 90, CompassDirection.West));

            pluto = new Planet
            {
                Xsize        = 100,
                Ysize        = 100,
                ObjectsOnMap = objectsOnMap
            };

            robotController       = new RobotController(new Position(0, 0, CompassDirection.North), pluto);
            queueOfCommandsRunner = new RobotQueueCommandRunner(robotController);

            DisplayWelcome();
            DisplayPlanetSize();
            DisplayMenu();
        }
Пример #10
0
 void Awake()
 {
     robotController = robotInput.controller;
     SetTrainingMode(isTrainingMode);
     saveStatus.text = "";
 }
Пример #11
0
 public Warehouse(IRobotController <IRobot> robotController)
 {
     RobotController = robotController;
 }
Пример #12
0
 public IslandFinderController(Problem problem, IRobotController nextController)
 {
     Problem        = problem;
     NextController = nextController;
 }
Пример #13
0
        public ScoreNActionsController(Problem problem, IRobotController nextController) : base(problem, nextController)
        {
            var actions = new[]
            {
                RobotAction.Up, RobotAction.Down, RobotAction.Left, RobotAction.Right, RobotAction.TurnLeft,
                RobotAction.TurnRight
            };

            // generate list of all possible 1 move actions
            foreach (var a in actions)
            {
                ActionList.Add(new List <RobotAction> {
                    a
                });
            }

            // generate all 2 move actions
            foreach (var a in actions)
            {
                foreach (var b in actions)
                {
                    ActionList.Add(new List <RobotAction> {
                        a, b
                    });
                }
            }

            // generate all 3 move actions
            foreach (var a in actions)
            {
                foreach (var b in actions)
                {
                    foreach (var c in actions)
                    {
                        ActionList.Add(new List <RobotAction> {
                            a, b, c
                        });
                    }
                }
            }

            // generate all 4 move actions
            foreach (var a in actions)
            {
                foreach (var b in actions)
                {
                    foreach (var c in actions)
                    {
                        foreach (var d in actions)
                        {
                            ActionList.Add(new List <RobotAction> {
                                a, b, c, d
                            });
                        }
                    }
                }
            }

            // generate all 5 move actions
            foreach (var a in actions)
            {
                foreach (var b in actions)
                {
                    foreach (var c in actions)
                    {
                        foreach (var d in actions)
                        {
                            foreach (var e in actions)
                            {
                                ActionList.Add(new List <RobotAction> {
                                    a, b, c, d, e
                                });
                            }
                        }
                    }
                }
            }

            //foreach (var a in actions)
            //    foreach (var b in actions)
            //        foreach (var c in actions)
            //            foreach (var d in actions)
            //                foreach (var e in actions)
            //                    foreach (var f in actions)
            //                        ActionList.Add(new List<RobotAction> { a, b, c, d, e, f });

            //foreach (var a in actions)
            //    foreach (var b in actions)
            //        foreach (var c in actions)
            //            foreach (var d in actions)
            //                foreach (var e in actions)
            //                    foreach (var f in actions)
            //                        foreach (var g in actions)
            //                            ActionList.Add(new List<RobotAction> { a, b, c, d, e, f, g });

            Console.WriteLine($"Evaluating {ActionList.Count} possible move sets");
        }
Пример #14
0
 public SmartIslandController(Problem problem, IRobotController nextController) : base(problem, nextController)
 {
 }
Пример #15
0
 public ScoreSingleActionsController(Problem problem, IRobotController nextController)
 {
     Problem        = problem;
     NextController = nextController;
 }
Пример #16
0
 public void SetRobotController(IRobotController robotController)
 {
     RobotController = robotController;
 }
 public CachingScoreTurnActionsController(Problem problem, IRobotController nextController) : base(problem, nextController)
 {
 }
 public RobotQueueCommandRunner(IRobotController controller)
 {
     _robotController = controller;
 }
Пример #19
0
 private void SetSelectedController(IRobotController controller)
 {
     selectedController = controller;
     selectedController.Commander = arduinoCommander;
     selectedController.Parent = Handle;
 }
Пример #20
0
 public RobotController(Problem problem, IRobotController nextController)
 {
     Problem        = problem;
     NextController = nextController;
 }