Beispiel #1
0
        //  ╔═╗═╗ ╦╔╦╗╔═╗╦═╗╔╗╔╔═╗╦      ╔═╗═╗ ╦╦╔═╗
        //  ║╣ ╔╩╦╝ ║ ║╣ ╠╦╝║║║╠═╣║      ╠═╣╔╩╦╝║╚═╗
        //  ╚═╝╩ ╚═ ╩ ╚═╝╩╚═╝╚╝╩ ╩╩═╝────╩ ╩╩ ╚═╩╚═╝
        public bool ApplyAction(ActionExternalAxis action)
        {
            // Cartesian targets
            if (action.target == ExternalAxesTarget.All || action.target == ExternalAxesTarget.Cartesian)
            {
                if (this.externalAxesCartesian == null)
                {
                    this.externalAxesCartesian = new ExternalAxes();
                }


                if (action.relative)
                {
                    if (this.externalAxesCartesian[action.axisNumber - 1] == null)
                    {
                        //logger.Info($"Cannot apply \"{action}\", must initialize absolute axis value first for axis {action.axisNumber} before applying relative ones...");
                        logger.Error("Cannot increase cartesian external axis, value has not been initialized. Try `ExternalAxisTo()` instead.");
                        return(false);
                    }

                    this.externalAxesCartesian[action.axisNumber - 1] += action.value;
                }
                else
                {
                    this.externalAxesCartesian[action.axisNumber - 1] = action.value;
                }
            }

            // Joint targets
            if (action.target == ExternalAxesTarget.All || action.target == ExternalAxesTarget.Joint)
            {
                if (this.externalAxesJoints == null)
                {
                    this.externalAxesJoints = new ExternalAxes();
                }

                if (action.relative)
                {
                    if (this.externalAxesJoints[action.axisNumber - 1] == null)
                    {
                        //logger.Info($"Cannot apply \"{action}\", must initialize absolute axis value first for axis {action.axisNumber} before applying relative ones...");
                        logger.Error("Cannot increase joint external axis, value has not been initialized. Try `ExternalAxisTo()` instead.");
                        return(false);
                    }

                    this.externalAxesJoints[action.axisNumber - 1] += action.value;
                }
                else
                {
                    this.externalAxesJoints[action.axisNumber - 1] = action.value;
                }
            }

            if (_logRelativeActions && action.relative)
            {
                logger.Verbose("External Axis " + action.axisNumber + " set to " + this.externalAxesJoints[action.axisNumber - 1]);
            }

            return(true);
        }
Beispiel #2
0
        //  ╔═╗═╗ ╦╔╦╗╔═╗╦═╗╔╗╔╔═╗╦      ╔═╗═╗ ╦╦╔═╗
        //  ║╣ ╔╩╦╝ ║ ║╣ ╠╦╝║║║╠═╣║      ╠═╣╔╩╦╝║╚═╗
        //  ╚═╝╩ ╚═ ╩ ╚═╝╩╚═╝╚╝╩ ╩╩═╝────╩ ╩╩ ╚═╩╚═╝
        public bool ApplyAction(ActionExternalAxis action)
        {
            if (this.externalAxes == null)
            {
                this.externalAxes = new ExternalAxes();
            }

            if (action.relative)
            {
                if (this.externalAxes[action.axisNumber - 1] == null)
                {
                    Console.WriteLine($"Sorry, must initialize absolute axis value first for axis {action.axisNumber} before applying relative ones... Action: " + action.ToInstruction());
                    return(false);
                }

                this.externalAxes[action.axisNumber - 1] += action.value;
            }
            else
            {
                this.externalAxes[action.axisNumber - 1] = action.value;
            }

            return(true);
        }