private void GetRobotAxisLimits(ITxRobot robot)
        {
            lowerLimits = new ArrayList();
            upperLimits = new ArrayList();

            if (robot as TxRobot is ITxDevice robotAsDevice)
            {
                foreach (TxJoint joint in robotAsDevice.DrivingJoints)
                {
                    if (joint.HardLimits is TxJointConstantHardLimits constantLimits)
                    {
                        lowerLimits.Add(constantLimits.LowerLimit);
                        upperLimits.Add(constantLimits.UpperLimit);
                    }
                    else if (joint.HardLimits is TxJointVariableHardLimits variableLimits)
                    {
                        lowerLimits.Add(variableLimits.LimitsData.Limits[0].JointLowerLimitValue);
                        upperLimits.Add(variableLimits.LimitsData.Limits[0].JointUpperLimitValue);
                    }
                    else
                    {
                        lowerLimits.Add(joint.LowerSoftLimit);
                        upperLimits.Add(joint.UpperSoftLimit);
                    }
                }
            }
        }
        private void CheckA23Singularity(ITxRobot irobot)
        {
            TxRobot robot = irobot as TxRobot;

            if (robot != null)
            {
                double?jointA3HomeValue = null;
                foreach (TxPose pose in robot.PoseList)
                {
                    if (pose.Name.Equals("HOME"))
                    {
                        TxPoseData poseDataHome = pose.PoseData;
                        robot.CurrentPose = poseDataHome;
                        jointA3HomeValue  = (double)pose.Device.CurrentPose.JointValues[2];
                        break;
                    }
                }
                if (jointA3HomeValue != null)
                {
                    double a3SingularityValue = RwMathUtilities.Rad2Deg((double)jointA3HomeValue) - 90.0;
                    double a3CurrentValue     = RwMathUtilities.Rad2Deg((double)currentJointValues[2]);
                    if (RwMathUtilities.Abs(a3CurrentValue - a3SingularityValue) < deltaA23Singularity)
                    {
                        AxisLimitsResult = string.IsNullOrEmpty(AxisLimitsResult)
                            ? $"A23 Singularity: {a3CurrentValue:F1}"
                            : string.Join("; ", AxisLimitsResult, $"A23 Singularity: {a3CurrentValue:F1}");
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Get the directory of a selected robot in the RobotsMachineDataFiles directory
        /// </summary>
        /// <param name="robot">The robot</param>
        /// <returns>The path to the robot machine data directory</returns>
        public static string GetMachineDataDirectory(this ITxRobot robot)
        {
            string path       = string.Empty;
            string systemRoot = TxApplication.SystemRootDirectory;

            if (robot is ITxProcessModelObject processModelObject)
            {
                path = RwFileAndDirectoryUtilities.CombinePathSegments(systemRoot.TrimEnd('\\'), "RobotsMachineDataFiles", processModelObject.ProcessModelId.ExternalId);
            }
            return(path);
        }
Exemple #4
0
        /// <summary>
        /// Get the joint values of the robot assigned to a location
        /// </summary>
        /// <param name="location">The location from which to get the joint values</param>
        /// <returns>The joint values</returns>
        private ArrayList GetRobotPoseDataFromLocation(ITxRoboticLocationOperation location)
        {
            ITxRobot robot = location.ParentRoboticOperation.Robot;

            if (robot != null)
            {
                TxPoseData pose = robot.GetPoseAtLocation(location);
                if (pose != null)
                {
                    return(pose.JointValues);
                }
            }
            return(null);
        }
        private void CheckA1Singularity(ITxRobot irobot)
        {
            TxTransformation currentWorkingFrame = TxApplication.ActiveDocument.WorkingFrame;
            TxRobot          robot = irobot as TxRobot;

            if (robot != null)
            {
                if (location is ITxLocatableObject locateableLocation)
                {
                    TxApplication.ActiveDocument.WorkingFrame = robot.AbsoluteLocation;
                    double locationXvalue = locateableLocation.LocationRelativeToWorkingFrame.Translation.X;
                    double locationYvalue = locateableLocation.LocationRelativeToWorkingFrame.Translation.Y;
                    double xyValue        = RwMathUtilities.Length(locationXvalue, locationYvalue, 0.0);
                    if (RwMathUtilities.Abs(xyValue) < deltaA1Singularity)
                    {
                        AxisLimitsResult = string.IsNullOrEmpty(AxisLimitsResult)
                            ? $"A1 Singularity: {xyValue:F1}"
                            : string.Join("; ", AxisLimitsResult, $"A1 Singularity: {xyValue:F1}");
                    }
                    TxApplication.ActiveDocument.WorkingFrame = currentWorkingFrame;
                }
            }
        }
        public override void Execute(object cmdParams)
        {
            ////遍历获取所有机器人列表
            //TxObjectList rolist = TxApplication.ActiveDocument.PhysicalRoot.GetAllDescendants(new TxTypeFilter(typeof(TxRobot)));

            //拾取机器人
            TxObjectList rolist = TxApplication.ActiveSelection.GetFilteredItems(new TxTypeFilter(typeof(TxRobot)));

            foreach (TxRobot robot in rolist)
            {
                //创建机器人program
                ITxRoboticProgram RobotProgram = TxApplication.ActiveDocument.RoboticProgramRoot.CreateProgram(new TxRoboticProgramCreationData(robot));
                RobotProgram.Name = robot.Name + "_Program";

                //将机器人program加载到path editor中
                TxApplication.ViewersManager.PathEditorViewer.SetRoboticProgram(RobotProgram);

                //将机器人的所有op添加到robot program中
                //TxObjectList rplist = robot.GetAllDescendants(new TxTypeFilter(typeof(ITxRoboticOperation)));
                TxObjectList rplist = robot.SimulatingOperations;
                foreach (ITxRoboticOperation item in rplist)
                {
                    ITxRoboticProgramElement txRoboticProgramElement = item as ITxRoboticProgramElement;
                    RobotProgram.AddElement(txRoboticProgramElement);
                    if (txRoboticProgramElement.Name.ToUpper() == "MAIN" | txRoboticProgramElement.Name.ToUpper() == "CELL")
                    {
                        RobotProgram.SetElementNumber(txRoboticProgramElement, 125);
                    }
                }

                //将当前robot program设置为default program,即下载当前program到PS robot中
                ITxRobot         txRobot          = robot as ITxRobot;
                TxRoboticProgram txRoboticProgram = RobotProgram as TxRoboticProgram;

                txRobot.DefaultProgram = txRoboticProgram;
            }
        }
 private void CheckSingularities(ITxRobot robot)
 {
     CheckA1Singularity(robot);
     CheckA23Singularity(robot);
     CheckA5Singularity();
 }