Beispiel #1
0
        /// <summary>
        /// Apply Joints Action.
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public bool ApplyAction(ActionAxes action)
        {
            Joints newJnt;

            // @TODO: implement joint limits checks and general safety...

            // Modify current Joints
            if (action.relative)
            {
                // If user issued a relative action, make sure there are absolute values to work with.
                // (This limitation is due to current lack of FK/IK solvers)
                if (axes == null)  // could also check for motionType == MotionType.Joints ?
                {
                    logger.Warning($"Cannot apply \"{action}\", must provide absolute Joints values first before applying relative ones...");
                    return(false);
                }

                newJnt = Joints.Add(axes, action.joints);
            }
            else
            {
                newJnt = new Joints(action.joints);
            }

            prevAxes = axes;
            axes     = newJnt;

            // Flag the lack of other geometric data
            prevPosition = position;
            position     = null;
            prevRotation = rotation;
            rotation     = null;

            if (isExtruding)
            {
                this.ComputeExtrudedLength();
            }

            if (_logRelativeActions && action.relative)
            {
                logger.Verbose("Axes at " + this.axes);
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Apply Joints Action.
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public bool ApplyAction(ActionAxes action)
        {
            Joints newJnt;

            // @TODO: implement joint limits checks and general safety...

            // Modify current Joints
            if (action.relative)
            {
                // If user issued a relative action, make sure there are absolute values to work with.
                // (This limitation is due to current lack of FK/IK solvers)
                if (joints == null)  // could also check for motionType == MotionType.Joints ?
                {
                    Console.WriteLine("Sorry, must provide absolute Joints values first before applying relative ones..." + this);
                    return(false);
                }

                newJnt = Joints.Add(joints, action.joints);
            }
            else
            {
                newJnt = new Joints(action.joints);
            }

            prevJoints = joints;
            joints     = newJnt;

            // Flag the lack of other geometric data
            prevPosition = position;
            position     = null;
            prevRotation = rotation;
            rotation     = null;

            if (isExtruding)
            {
                this.ComputeExtrudedLength();
            }

            return(true);
        }