Beispiel #1
0
        public void TestToStringFromEnumAndJointObject()
        {
            var robotJoints = new RobotJoints {
                joint1  = 0,
                joint2  = 100,
                joint3  = 0,
                joint4  = 0,
                joint5  = 0,
                joint6  = 0,
                gripper = 0
            };

            var expectedParameters = "0,100,0,0,0,0,0";
            var expectedCommand    = "12,0,100,0,0,0,0,0";
            var expectedCode       = 12;

            string rawCommand = $"{(int) RobotCommand.CommandType.DriveTo},{robotJoints}";

            Assert.Equal(expectedCommand, rawCommand);
            RobotCommand robotCommand = RobotCommand.FromString(rawCommand);

            Assert.True(robotCommand.Code.Equals(expectedCode), "Correct Command Code parsed");
            Assert.Equal(expectedParameters, robotCommand.Parameters);
            Assert.Equal(expectedCommand, robotCommand.ToString());
        }
        //public void Carry(string Get_Position,string Put_Position,Job Get_Job, Job Put_Job)
        //{

        //}

        public void DoWork(RobotCommand Type, Job Job)
        {
            switch (Type)
            {
            case RobotCommand.Get:
                Get(Job);
                break;

            case RobotCommand.Put:
                Put(Job);
                break;

            case RobotCommand.GetAndWait:
                GetAndWait(Job);
                break;

            case RobotCommand.GetAfterWait:
                GetAfterWait(Job);
                break;

            case RobotCommand.PutAndWait:
                PutAndWait(Job);
                break;
            }
        }
    void ValidMoveCommandGiven(List <Vector2> commandList, Vector2 endPos, float timeForMove)
    {
        //Is overriding commands?
        bool isOverriding = selectedRobot.GetLatestMoveTime() < prepTimer;         //TODO Use in dialog box

        //Add commands
        Vector2 simulPos  = selectedRobot.ghostPos;
        float   simulTime = prepTimer;
        float   endRot    = selectedRobot.ghostRot;

        foreach (Vector2 move in commandList)
        {
//			Vector2 lastPos = simulPos;
            simulPos  += move;
            simulTime += RobotCommand.CommandDuration(CommandType.MOVE_TO, selectedRobot.prepRobotHeight);
            Command cmd = new Command(CommandType.MOVE_TO, (int)simulPos.x, (int)simulPos.y, -1);
            selectedRobot.robotCommand.AddCommand(cmd);
            selectedRobot.SetStateAtTime(simulTime, simulPos);
        }



        //Update prep timer and prep values
        UpdatePrepValues(prepTimer + timeForMove);
        selectedRobot.robotPrepTimer = prepTimer;

        //Visual stuff (and ghostPos)
        guiCtrl.UpdateSelectedRobot(selectedRobot);
        pathArwCtrl.UpdatePath(selectedRobot, commandList, isOverriding);
        SetGhost(selectedRobot, endPos, endRot);
        SetSelector(Tools.CleanPos(selectedRobot.ghostPos));
    }
        public ShellViewModel(
            IEventAggregator eventAggregator,
            SocketClient socketClient,
            RobotCommand moveCommand,
            ControllerClass controllerClass
            )
        {
            _socketClient    = socketClient;
            _dashboardClient = new SocketClient(eventAggregator);

            _roboServer = new SocketServer(eventAggregator);

            _robotCommand    = moveCommand;
            _controllerClass = controllerClass;

            _eventAggregator = eventAggregator;
            _eventAggregator.Subscribe(this);

            _controllerClass.StartController();

            _serial       = new SerialCommunication(eventAggregator);
            _BTConnection = new BluetoothConnection(eventAggregator);

            ComPortList       = SerialPort.GetPortNames();
            BaudRateList      = DataLists.GetBaudRates();
            MotorStepTypeList = DataLists.GetStepTypes();
        }
Beispiel #5
0
        public RobotCommandResponse HandleCommand(RobotCommand command, IRobot robot, ISurface surface)
        {
            if (!robot.IsPlaced)
            {
                return(new RobotCommandResponse(RobotResponseType.Invalid, RobotCommandType.Right));
            }
            if (robot.Direction == null)
            {
                return(new RobotCommandResponse(RobotResponseType.Invalid, RobotCommandType.Right));
            }

            switch (robot.Direction.Value)
            {
            case RobotDirection.North:
                robot.Direction = RobotDirection.East;
                break;

            case RobotDirection.East:
                robot.Direction = RobotDirection.South;
                break;

            case RobotDirection.South:
                robot.Direction = RobotDirection.West;
                break;

            case RobotDirection.West:
                robot.Direction = RobotDirection.North;
                break;
            }
            return(new RobotCommandResponse(RobotResponseType.Processed, RobotCommandType.Right));
        }
Beispiel #6
0
        public void DoRobotCommandFor(RobotCommand robotCommand)
        {
            if (IsReadyForRobotCommand())
            {
                Task.Run(() =>
                {
                    string addressID = robotCommand.PortAddressId;
                    EnumLoadUnload enumLoadUnload = GetEnumLoadUnloadFrom(robotCommand);
                    if (!LocalPackage.MainFlowHandler.LoadUnloadCommand(addressID, enumLoadUnload))
                    {
                        OnLogDebugEvent?.Invoke(this, new MessageHandlerArgs()
                        {
                            ClassMethodName = GetType().Name + ":" + System.Reflection.MethodBase.GetCurrentMethod().Name,
                            Message         = "LocalPackage.MainFlowHandler.LoadUnloadCommand return fail."
                        });

                        //TODO : Vertify will local package publish robot fail event?
                        //OnRobotEndEvent?.Invoke(this, EnumRobotEndType.RobotError);
                    }
                });
            }
            else
            {
                OnLogDebugEvent?.Invoke(this, new MessageHandlerArgs()
                {
                    ClassMethodName = GetType().Name + ":" + System.Reflection.MethodBase.GetCurrentMethod().Name,
                    Message         = $"LocalPackage is not ready for robot command.[ReadySignal={LocalPackage.MainFlowHandler.localData.LoadUnloadData.Ready}][ErrorSignal={LocalPackage.MainFlowHandler.localData.LoadUnloadData.ErrorBit}]"
                });
            }
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            app = new App();

            field  = app.StartApp();
            inputP = new InputProcessor();
            robot  = field.GetRobot();
            robot.SetBatteryCustom(1000000);
            history = new History();

            MoveUpC    = new MoveUpCommand(field.GetRobot());
            MoveLeftC  = new MoveLeftCommand(field.GetRobot());
            MoveRightC = new MoveRightCommand(field.GetRobot());
            MoveDownC  = new MoveDownCommand(field.GetRobot());


            inputP.AddMap("w", MoveUpC);
            inputP.AddMap("a", MoveLeftC);
            inputP.AddMap("d", MoveRightC);
            inputP.AddMap("s", MoveDownC);
            Console.WriteLine("Your robot is " + robot.GetCompilerTimeType().ToString());

            shower = new FieldShower();

            Console.WriteLine("Press any button to start");
            Console.ReadLine();

            Run();
        }
        public void RobotInWrongDirection()
        {
            var robot  = new RobotCommand();
            var result = robot.InitializeCommands("PLACE 0,0,NORTH");

            Assert.AreEqual(string.Empty, result);
        }
Beispiel #9
0
 public void RemoveCommand(RobotCommand command)
 {
     if (command != null && commands.Contains(command)) {
         commands.Remove(command);
         EditorUtility.SetDirty(this);
     }
 }
Beispiel #10
0
 public void AddNewCommand(RobotCommand command)
 {
     if (command != null) {
         commands.Add(command);
         EditorUtility.SetDirty(this);
     }
 }
Beispiel #11
0
        void ParseMessage(string speech)
        {
            Regex           rx      = new Regex("(<[^>]+>)");
            MatchCollection matches = rx.Matches(speech);

            if (matches.Count > 0)
            {
                foreach (Match match in matches)
                {
                    GroupCollection groupCollection = match.Groups;
                    string          command         = groupCollection[1].ToString();
                    speech = speech.Replace(command, "");

                    int index = command.IndexOf(",");
                    if (index > 0)
                    {
                        string[] commands = command.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
                        string   motion   = commands[0].Substring(1, commands[0].Length - 1);
                        string   face     = commands[1].Substring(0, commands[1].Length - 1);
                        //Debug.Log(motion + "::" + face);

                        RobotCommand robotCommand = new RobotCommand();
                        robotCommand.speech = speech;
                        robotCommand.motion = motion.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)[1];
                        robotCommand.face   = face.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)[1];

                        currentCommands.Add(robotCommand);
                    }
                }
            }
        }
Beispiel #12
0
    private void ExecuteCommand(float nextCommandInSeconds, bool draw = true)
    {
        if (instructionsFeed.Count == 0)
        {
            OnRobotLost?.Invoke();
            return;
        }
        RobotCommand cmd = instructionsFeed[0].command;

        instructionsFeed.RemoveAt(0);
        if (cmd != RobotCommand.NONE)
        {
            trashDeck.Add(cmd);
        }

        if (!reachedGoal)
        {
            OnSendCommand?.Invoke(cmd, nextCommandInSeconds);
        }
        if (draw)
        {
            DrawToFeed();
        }
        else
        {
            SendSynchFeed();
        }
    }
Beispiel #13
0
 public void Execute_IsInvoked()
 {
     //rm.Setup(x => rm.Object.ActionMoveDown());
     rc = new MoveDownCommand(rm.Object);
     rc.Execute();
     Assert.AreEqual(1, 1);
     //Mock.Get(rm).Verify(x => rm.Object.ActionMoveDown(), Times.Exactly(1));
 }
        public void ParseWestCommandTest()
        {
            const string input = "W 5";
            var command = CommandParser.ParseRobotCommand(input);

            var expectedCommand = new RobotCommand(Direction.West, 5);
            Assert.AreEqual(expectedCommand, command);
        }
Beispiel #15
0
 private void RemoteController_OnSendCommand(RobotCommand command, float nextCommandInSeconds)
 {
     if (command == RobotCommand.NONE)
     {
         return;
     }
     StartCoroutine(Progress(nextCommandInSeconds));
 }
        public void RobotReportAfterBeingPlaced()
        {
            var robot  = new RobotCommand();
            var result = robot.InitializeCommands("PLACE 0,0,NORTH");

            result = robot.InitializeCommands("REPORT");
            Assert.AreEqual("0,0, and direction is NORTH", result);
        }
        public void RobotNotPlaced()
        {
            var robot   = new RobotCommand();
            var command = "REPORT";
            var result  = robot.InitializeCommands(command);

            Assert.AreEqual($"Robot not placed, cannot process command { command}", result);
        }
Beispiel #18
0
//	public ServerRobotCommand(int robotID){
//
//		this.robotID = robotID;
//		//		this.ownerId = ownerId;
//		playbackCmdID = -1;
//		lastCmd = null;
//	}

    public ServerRobotCommand(RobotCommand robCmd)
    {
        this.robotID      = robCmd.robotID;
        this.turnCommands = robCmd.turnCommands;

        playbackCmdID = -1;
        lastCmd       = null;
    }
 void AddCommand(InternalRobotMessage internalRobotMessage)
 {
     lock (commandsLock)
     {
         var command = new RobotCommand(internalRobotMessage.commandDescription, internalRobotMessage.message);
         commands.Add(command);
     }
 }
        //public void Carry(string Get_Position,string Put_Position,Job Get_Job, Job Put_Job)
        //{

        //}

        public void DoWork(RobotCommand Type, Job Job)
        {
            switch (Type)
            {
            case RobotCommand.ALIGN:
                ALIGN(Job);
                break;
            }
        }
Beispiel #21
0
        void PlayCommand()
        {
            RobotCommand command = currentCommands[0];

            speechController.Play(command.speech);
            currentCommands.RemoveAt(0);

            Debug.Log(command.motion + " : " + command.face);
        }
Beispiel #22
0
        public void Test1()
        {
            ChangedEventHandler a = null;

            a += CollectEnergy;
            RobotCommand res = a(new List <Robot.Common.Robot>(), 1, new Map());

            Assert.AreEqual(new CollectEnergyCommand(), res);
        }
Beispiel #23
0
        public void Test3()
        {
            ChangedEventHandler a = null;

            a += CreateNewRobot;
            RobotCommand res = a(new List <Robot.Common.Robot>(), 1, new Map());

            Assert.AreEqual(new CreateNewRobotCommand(), res);
        }
        public void Robot_Test_0_0_North()
        {
            var robot  = new RobotCommand();
            var result = robot.InitializeCommands("PLACE 0,0,NORTH");

            result = robot.InitializeCommands("LEFT");
            result = robot.InitializeCommands("REPORT");
            Assert.AreEqual("0,0, and direction is WEST", result);
        }
Beispiel #25
0
        public void Test4()
        {
            ChangedEventHandler a = null;

            a += Move;
            RobotCommand res = a(new List <Robot.Common.Robot>(), 1, new Map());

            Assert.AreEqual(new MoveCommand(), res);
        }
Beispiel #26
0
    //GENERAL
    public void TurnStarted()
    {
        transform.position = Tools.CleanPos(transform.position);
        startTurnPos       = pos;

        robotCommand = new RobotCommand(robotID);
        robotHistory.Clear();
        rCmdCtrl.SetGhost(this, pos, currAngle);
    }
        public void CleanWestTest()
        {
            var startLocation = new Location(22, 10);
            var command = new RobotCommand(Direction.West, 23);
            var robot = new RobotCleaner(startLocation);
            robot.ExecuteCommand(command);

            var expectedLastLocation = new Location(-1, 10);
            Assert.AreEqual(expectedLastLocation, robot.LastLocation);
        }
        public void Robot_Report_0_0_North()
        {
            var robot  = new RobotCommand();
            var result = robot.InitializeCommands("PLACE 0,0,NORTH");

            result = robot.InitializeCommands("MOVE");
            result = robot.InitializeCommands("REPORT");
            //assert
            Assert.AreEqual("0,1, and direction is NORTH", result);
        }
        private async void PlayCommand_Execute(object parameter)
        {
            var cmd = new RobotCommand(SelectedRobotIndex, SelectedCommand, Double.Parse(Payload));
            await RobotCommandExecuter.ExecuteAsync(cmd);

            //add to in memory repo
            CommandRepository.Add(cmd);

            //update UI
            ExecutedCommandText.Add(GetCommandText(cmd));
        }
Beispiel #30
0
 public void Undo()
 {
     if (this.stack.Count > 0)
     {
         RobotCommand rc = this.stack.Pop();
         rc.Undo();
     }
     else
     {
         throw new NoHistoryException("There is no moves to undo");
     }
 }
Beispiel #31
0
        public void GivenProcess_WhenInputParsed_ThenCommandProcessed()
        {
            var aResponse    = new RobotCommandResponse(RobotResponseType.Processed);
            var robotCommand = new RobotCommand();

            _commandParser.Setup(x => x.TryParse("REPORT", out robotCommand)).Returns(true);
            _commandProcessor.Setup(x => x.ProcessCommand(robotCommand)).Returns(aResponse);

            var response = _processor.Process("REPORT");

            response.Should().Be(aResponse);
        }
        protected override GamePhase Run(GameLogic game)
        {
            int commandId = game.Programming.GetRegister(game.executionState.CurrentRobot)[game.executionState.CurrentRegister];

            if (commandId != -1 && (game.Entitys[game.executionState.CurrentRobot] as RobotInfo)?.Health > 0)            //-1 is an empty register
            {
                RobotCommand cmd = game.Programming[commandId];
                cmd.Execute(game, game.executionState.CurrentRobot);
                Thread.Sleep(game.AnimationDelay);
            }
            return(new PostStatementPhase());
        }
Beispiel #33
0
        public void runProg([FromBody] string rawProgram)
        {
            Console.WriteLine("Execute Program");
            var robotProgram = new RobotProgram();

            foreach (var rawCommand in rawProgram.Split('\n'))
            {
                var robotCommand = RobotCommand.FromString(rawCommand);
                robotProgram.Commands.Add(robotCommand);
            }
            this._rosService.RunProgram(robotProgram);
        }
        public void Robot_Test_1_2_East()
        {
            var robot  = new RobotCommand();
            var result = robot.InitializeCommands("PLACE 1,2,EAST");

            result = robot.InitializeCommands("MOVE");
            result = robot.InitializeCommands("MOVE");
            result = robot.InitializeCommands("LEFT");
            result = robot.InitializeCommands("MOVE");
            result = robot.InitializeCommands("REPORT");
            Assert.AreEqual("3,3, and direction is NORTH", result);
        }
Beispiel #35
0
 /// <summary>
 /// Moves Roboter arm to given absolut coordinates
 /// </summary>
 /// <param name="coordinates">Coordinates to move to</param>
 /// <param name="speed">Speed to move</param>
 /// <param name="instant">whether to execute command instant or not</param>
 public void MoveAbsolut(Coordinate coordinates, int speed, bool instant)
 {
     var message = new RobotCommand("MP", coordinates.ToString());
     Speed(speed, instant);
     SendMessage(message, instant);
 }
Beispiel #36
0
 /// <summary>
 /// Closes Grip of Robot
 /// </summary>
 /// <param name="instant">whether to execute command instant or not</param>
 public void GripClose(bool instant)
 {
     RobotCommand command = new RobotCommand("GC", "");
     SendMessage(command, instant);
 }
Beispiel #37
0
 //@deprecated
 //TODO: remove
 public void AddNewCommand(RobotCommand command)
 {
     mainBlock.AddNewCommand(command);
 }
Beispiel #38
0
 /// <summary>
 /// Sets the Speed
 /// </summary>
 /// <param name="speed">Speed value to set, must be between 1 and 7</param>
 /// <param name="instant">whether to execute command instant or not</param>
 public void Speed(int speed, bool instant)
 {
     if (speed > 0 && speed < 8)
     {
         RobotCommand command = new RobotCommand("SP", speed.ToString());
         SendMessage(command, instant);
     }
     else
     {
         RobotCommand command = new RobotCommand("SP", "5");
         SendMessage(command, instant);
     }
 }
Beispiel #39
0
 /// <summary>
 /// Moves to Origin Position
 /// </summary>
 /// <param name="instant">whether to execute command instant or not</param>
 public void Origin(bool instant)
 {
     RobotCommand command = new RobotCommand("OG", "");
     SendMessage(command, instant);
 }
Beispiel #40
0
 /// <summary>
 /// Moves to Nest Position
 /// </summary>
 /// <param name="instant">whether to execute command instant or not</param>
 public void Nest(bool instant)
 {
     RobotCommand command = new RobotCommand("NT", "");
     SendMessage(command, instant);
 }
Beispiel #41
0
 /// <summary>
 /// Sends Message
 /// </summary>
 /// <param name="message"></param>
 private void SendMessage(RobotCommand message, bool instant)
 {
     if (instant)
     {
         _connection.Write(message.ToString());
     }
     else
     {
         commands.Add(message);
     }
 }
Beispiel #42
0
 /// <summary>
 /// Turns by specified angles
 /// </summary>
 /// <param name="j1">angle 1</param>
 /// <param name="j2">angle 2</param>
 /// <param name="j3">angle 3</param>
 /// <param name="j4">angle 4</param>
 /// <param name="j5">angle 5</param>
 /// <param name="instant">whether to execute command instant or not</param>
 public void MoveJoint(decimal j1, decimal j2, decimal j3, decimal j4, decimal j5, int speed, bool instant)
 {
     RobotCommand command = new RobotCommand("MJ",j1.ToString() + ", " + j2.ToString() + ", " + j3.ToString() + ", " + j4.ToString() + ", " + j5.ToString());
     Speed(speed, instant);
     SendMessage(command, instant);
 }
Beispiel #43
0
 /// <summary>
 /// Opens Grip of Robot
 /// </summary>
 /// <param name="instant">whether to execute command instant or not</param>
 public void GripOpen(bool instant)
 {
     RobotCommand command = new RobotCommand("GO", "");
     SendMessage(command, instant);
 }
Beispiel #44
0
 public void Timeout(string millis)
 {
     RobotCommand command = new RobotCommand("TI", millis);
     SendMessage(command, false);
 }