Esempio n. 1
0
        /// <inheritdoc />
        public int InstructionListJoints(out string errorMsg,
                                         out Mat jointList,
                                         double mmStep     = 10.0,
                                         double degStep    = 5.0,
                                         string saveToFile = "",
                                         CollisionCheckOptions collisionCheck = CollisionCheckOptions.CollisionCheckOff,
                                         ListJointsType flags = 0,
                                         int timeoutSec       = 3600)
        {
            Link.check_connection();
            Link.send_line("G_ProgJointList");
            Link.send_item(this);
            double[] parameter = { mmStep, degStep, (double)collisionCheck, (double)flags };
            Link.send_array(parameter);

            //joint_list = save_to_file;
            Link.ReceiveTimeout = timeoutSec * 1000;
            if (string.IsNullOrEmpty(saveToFile))
            {
                Link.send_line("");
                jointList = Link.rec_matrix();
            }
            else
            {
                Link.send_line(saveToFile);
                jointList = null;
            }

            int errorCode = Link.rec_int();

            Link.ReceiveTimeout = Link.DefaultSocketTimeoutMilliseconds;
            errorMsg            = Link.rec_line();
            Link.check_status();
            return(errorCode);
        }
Esempio n. 2
0
        /// <inheritdoc />
        public InstructionListJointsResult GetInstructionListJoints(
            double mmStep     = 10.0,
            double degStep    = 5.0,
            string saveToFile = "",
            CollisionCheckOptions collisionCheck = CollisionCheckOptions.CollisionCheckOff,
            ListJointsType flags = 0,
            int timeoutSec       = 3600,
            double time_step     = 0.2)
        {
            InstructionListJointsResult result =
                new InstructionListJointsResult {
                JointList = new List <InstructionListJointsResult.JointsResult>()
            };

            string errorMessage;
            Mat    jointList;

            result.ErrorCode = InstructionListJoints(out errorMessage, out jointList, mmStep, degStep, saveToFile,
                                                     collisionCheck,
                                                     flags, timeoutSec, time_step);
            result.ErrorMessage = errorMessage;

            var numberOfJoints = GetLink(ItemType.Robot).Joints().Length;

            for (var colId = 0; colId < jointList.Cols; colId++)
            {
                var joints = new double[numberOfJoints];
                for (var rowId = 0; rowId < numberOfJoints; rowId++)
                {
                    joints[rowId] = jointList[rowId, colId];
                }

                int           jointError    = (int)jointList[numberOfJoints, colId];
                ErrorPathType errorType     = (ErrorPathType)Convert.ToUInt32(jointError.ToString(), 2);
                var           maxLinearStep = jointList[numberOfJoints + 1, colId];
                var           maxJointStep  = jointList[numberOfJoints + 2, colId];
                var           moveId        = (int)jointList[numberOfJoints + 3, colId];
                result.JointList.Add(
                    new InstructionListJointsResult.JointsResult
                {
                    Joints        = joints,
                    Error         = errorType,
                    MaxLinearStep = maxLinearStep,
                    MaxJointStep  = maxJointStep,
                    MoveId        = moveId
                }
                    );
            }

            return(result);
        }