Example #1
0
        /// <summary>
        /// Moves robot to specified position (sets target position).
        /// </summary>
        /// <param name="targetPosition">target position</param>
        /// <param name="targetVelocity">target velocity (velocity after targetDuration)</param>
        /// <param name="targetDuration">desired movement duration in seconds</param>
        public void MoveTo(RobotVector targetPosition, RobotVector targetVelocity, double targetDuration)
        {
            if (!isInitialized)
            {
                throw new InvalidOperationException("Robot is not initialized");
            }

            if (!Limits.CheckPosition(targetPosition))
            {
                throw new ArgumentException("Target position is outside the available workspace:" +
                                            $"{Environment.NewLine}{targetPosition}");
            }

            if (!Limits.CheckVelocity(targetVelocity))
            {
                throw new ArgumentException("target velocity exceeding max value " +
                                            $"({Limits.MaxVelocity.XYZ} [mm/s], {Limits.MaxVelocity.ABC} [deg/s]):" +
                                            $"{Environment.NewLine}{targetVelocity}");
            }

            lock (forceMoveSyncLock) {
                if (forceMoveMode)
                {
                    return;
                }
            }

            generator.SetTargetPosition(targetPosition, targetVelocity, targetDuration);
        }
Example #2
0
        /// <summary>
        /// Receives data (IPOC, cartesian and axis position) from the robot asynchronously,
        /// raises <see cref="KUKARobot.FrameRecived">FrameReceived</see> event
        /// </summary>
        private async Task ReceiveDataAsync()
        {
            InputFrame receivedFrame = await rsiAdapter.ReceiveDataAsync();

            RobotVector correction = receivedFrame.Position - position;

            if (!Limits.CheckCorrection(correction))
            {
                Uninitialize();
                throw new InvalidOperationException("Correction limit has been exceeded:" +
                                                    $"{Environment.NewLine}{correction}");
            }

            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) {
                IPOC         = receivedFrame.IPOC;
                position     = receivedFrame.Position;
                axisPosition = receivedFrame.AxisPosition;
            }

            FrameReceived?.Invoke(receivedFrame);
        }
Example #3
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 #4
0
        public void MoveTo(RobotMovement[] movementsStack)
        {
            lock (forceMoveSyncLock) {
                if (isForceMoveModeEnabled)
                {
                    return;
                }
            }

            if (!isInitialized)
            {
                throw new InvalidOperationException("Robot is not initialized");
            }

            for (int i = 0; i < movementsStack.Length; i++)
            {
                RobotMovement movement = movementsStack[i];

                if (!Limits.CheckPosition(movement.TargetPosition))
                {
                    throw new ArgumentException("Target position is outside the available workspace:" +
                                                $"{Environment.NewLine}{movement.TargetPosition}");
                }

                if (!Limits.CheckVelocity(movement.TargetVelocity))
                {
                    throw new ArgumentException("Target velocity exceeding max value:" +
                                                $"{Environment.NewLine}{movement.TargetVelocity}");
                }
            }

            RobotVector currentVelocity;
            RobotVector currentAcceleration;

            lock (generatorSyncLock) {
                generator.SetMovements(movementsStack);
                currentVelocity     = generator.Velocity;
                currentAcceleration = generator.Acceleration;
            }

            MovementChanged?.Invoke(this, new MovementChangedEventArgs {
                Position       = Position,
                Velocity       = currentVelocity,
                Acceleration   = currentAcceleration,
                MovementsStack = movementsStack
            });
        }
Example #5
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);
        }