Inheritance: InstructionPacketBase
Exemplo n.º 1
0
        public void CanMoveServo(byte id, CommunicationObject sender)
        {
            var movment1 = new MovmentComandAX12(id, 0x0ff, 0x150);
            var movment2 = new MovmentComandAX12(id, 0x1ff, 0x150);
            var instructionPacket = new InstructionPacketSyncMovment(sender, movment1);
            instructionPacket.Send();

            Thread.Sleep(2000);
            instructionPacket = new InstructionPacketSyncMovment(sender, movment2);
            instructionPacket.Send();

            sender.Dispose();
        }
Exemplo n.º 2
0
        public void CanCreateInstructionPacketForSyncedMovment()
        {
            ISender sender = new FakeSender();
            var movment1 = new MovmentComandAX12(0, 0x010, 0x150);
            var movment2 = new MovmentComandAX12(1, 0x220, 0x360);
            var movment3 = new MovmentComandAX12(2, 0x030, 0x170);
            var movment4 = new MovmentComandAX12(3, 0x220, 0x380);
            var instructionPacket = new InstructionPacketSyncMovment(sender, movment1, movment2, movment3, movment4);

            var corectResult = new byte[]
                                   {
                                       0XFF, 0XFF, 0XFE, 0X18, 0X83, 0X1E, 0X04, 0X00, 0X10, 0X00, 0X50, 0X01, 0X01,
                                       0X20, 0X02, 0X60, 0X03, 0X02, 0X30, 0X00, 0X70, 0X01, 0X03, 0X20, 0X02, 0X80,
                                       0X03, 0X12
                                   };
            Assert.AreEqual(corectResult, instructionPacket.ToByte());
            // Console.WriteLine(BitConverter.ToString(corectResult));
            // Console.WriteLine(BitConverter.ToString(instructionPacket.ToByte()));
        }
Exemplo n.º 3
0
        public void CanMoveServo5()
        {
            ISender sender = new CommunicationObject("COM4");
            var movment1 = new MovmentComandAX12(5, 0x0ff, 0x150);
            var movment2 = new MovmentComandAX12(3, 0x0ff, 0x150);

            var instructionPacket = new InstructionPacketSyncMovment(sender, movment1, movment2);
            instructionPacket.Send();

            ((CommunicationObject) sender).Dispose();
        }
Exemplo n.º 4
0
        public void RotateBody15degresCW()
        {
            ISender sender = new CommunicationObject(COMPORT);
            Phoenix phoenix = RobotFactory.CreatePhoenix(HomePositionFactory.CreateHomePosition());
            phoenix.RotateBody(40,1);

            var movments = phoenix.GetMovements();

            var instructionPacket = new InstructionPacketSyncMovment(sender, movments);
            instructionPacket.Send();

            ((CommunicationObject)sender).Dispose();
        }
Exemplo n.º 5
0
        public void MoveBodyToStartPosition3()
        {
            ISender sender = new CommunicationObject(COMPORT);
            Phoenix phoenix = RobotFactory.CreatePhoenix(HomePositionFactory.CreateHomePosition4());

            var movments = phoenix.GetMovements();
            var instructionPacket = new InstructionPacketSyncMovment(sender, movments);
            instructionPacket.Send();
            Thread.Sleep((int)ServoBase.TimeBox * 1000);
            for (int i = 0; i < 15; i++)
            {

                phoenix.MoveBody(0, 90, -1);
                movments = phoenix.GetMovements();
                instructionPacket = new InstructionPacketSyncMovment(sender, movments);
                instructionPacket.Send();
                Thread.Sleep((int)ServoBase.TimeBox * 1000 - 10);
            }
            for (int i = 0; i < 15; i++)
            {

                phoenix.MoveBody(0, 90, 1);
                movments = phoenix.GetMovements();
                instructionPacket = new InstructionPacketSyncMovment(sender, movments);
                instructionPacket.Send();
                Thread.Sleep((int)ServoBase.TimeBox * 1000 + 10);
            }

            ((CommunicationObject)sender).Dispose();
        }
Exemplo n.º 6
0
        public void MoveBodyToStartPosition()
        {
            ISender sender = new CommunicationObject("COM4");
            Phoenix phoenix = RobotFactory.CreatePhoenix(HomePositionFactory.CreateHomePosition());

            var movments = phoenix.GetMovements();

             var instructionPacket = new InstructionPacketSyncMovment(sender, movments);
             instructionPacket.Send();

             ((CommunicationObject)sender).Dispose();
        }