Example #1
0
        private async Task <long> ReceiveDataAsync()
        {
            InputFrame receivedFrame = await rsiAdapter.ReceiveDataAsync();

            if (!Limits.CheckAxisPosition(receivedFrame.AxisPosition))
            {
                Uninitialize();
                throw new InvalidOperationException("Axis position limit has been exceeded:" +
                                                    $"{Environment.NewLine}{receivedFrame.AxisPosition}");
            }

            if (!Limits.CheckPosition(receivedFrame.Position))
            {
                Uninitialize();
                throw new InvalidOperationException("Available workspace limit has been exceeded:" +
                                                    $"{Environment.NewLine}{receivedFrame.Position}");
            }

            lock (receivedDataSyncLock) {
                position     = receivedFrame.Position;
                axisPosition = receivedFrame.AxisPosition;
            }

            FrameReceived?.Invoke(this, new FrameReceivedEventArgs {
                ReceivedFrame = receivedFrame
            });

            return(receivedFrame.IPOC);
        }
Example #2
0
 public Robot()
 {
     rsiAdapter   = new RSIAdapter();
     generator    = new TrajectoryGenerator();
     position     = RobotVector.Zero;
     axisPosition = RobotAxisVector.Zero;
     HomePosition = RobotVector.Zero;
 }
Example #3
0
 public RobotEmulator(RobotVector homePosition)
 {
     HomePosition     = homePosition;
     generator        = new TrajectoryGenerator();
     position         = RobotVector.Zero;
     axisPosition     = RobotAxisVector.Zero;
     correctionBuffor = new List <RobotVector>();
     correction       = RobotVector.Zero;
 }
Example #4
0
        private long ReceiveDataAsync()
        {
            correctionBuffor.Add(correction);
            RobotVector currentCorrection = RobotVector.Zero;

            if (correctionBuffor.Count == 8)
            {
                currentCorrection = correctionBuffor[0];
                correctionBuffor.RemoveAt(0);
            }

            InputFrame receivedFrame = new InputFrame {
                Position     = position + currentCorrection,
                AxisPosition = RobotAxisVector.Zero,
                IPOC         = 0
            };

            if (!Limits.CheckAxisPosition(receivedFrame.AxisPosition))
            {
                Uninitialize();
                throw new InvalidOperationException("Axis position limit has been exceeded:" +
                                                    $"{Environment.NewLine}{receivedFrame.AxisPosition}");
            }

            if (!Limits.CheckPosition(receivedFrame.Position))
            {
                Uninitialize();
                throw new InvalidOperationException("Available workspace limit has been exceeded:" +
                                                    $"{Environment.NewLine}{receivedFrame.Position}");
            }

            lock (receivedDataSyncLock) {
                position     = receivedFrame.Position;
                axisPosition = receivedFrame.AxisPosition;
            }

            FrameReceived?.Invoke(this, new FrameReceivedEventArgs {
                ReceivedFrame = receivedFrame
            });

            return(receivedFrame.IPOC);
        }
Example #5
0
 public InputFrame(string data)
 {
     IPOC         = long.Parse(new Tag(data, "IPOC").Value);
     Position     = ExtractPosition(new Tag(data, "RIst"));
     AxisPosition = ExtractAxisPosition(new Tag(data, "AIPos"));
 }