Exemplo n.º 1
0
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Create robot target from coordinate and quaternion values.
 /// </summary>
 /// <param name="ptX">Coordinate</param>
 /// <param name="ptY">Coordinate</param>
 /// <param name="ptZ">Coordinate</param>
 /// <param name="q1">Quaternion</param>
 /// <param name="q2">Quaternion</param>
 /// <param name="q3">Quaternion</param>
 /// <param name="q4">Quaternion</param>
 /// <returns></returns>
 public static RobTarget RobTargetAtVals(double ptX, double ptY, double ptZ, double q1, double q2, double q3, double q4)
 {
     var target = new RobTarget();
     {
         target.FillFromString2(
             string.Format(
                 "[[{0},{1},{2}],[{3},{4},{5},{6}],[0,0,0,0],[9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09]];",
                 ptX, ptY, ptZ, q1, q2, q3, q4));
     }
     return target;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Create robot target from point and list of quaternion values.
 /// </summary>
 /// <param name="point">Point</param>
 /// <param name="quatList">List of quaternions</param>
 /// <returns></returns>
 public static RobTarget RobTargetAtPoint1(Point point, List<double> quatList)
 {
     var target = new RobTarget();
     if (point != null)
     {
         target.FillFromString2(
             string.Format(
                 "[[{0},{1},{2}],[{3},{4},{5},{6}],[0,0,0,0],[9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09]];",
                 point.X, point.Y, point.Z, quatList[0], quatList[1], quatList[2], quatList[3]));
     }
     return target;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create robot target from plane.
 /// </summary>
 /// <param name="plane">Plane</param>
 /// <returns></returns>
 public static RobTarget RobTargetAtPlane(Plane plane)
 {
     var target = new RobTarget();
     if (plane != null)
     {
         List<double> quatDoubles = RobotUtils.PlaneToQuaternian(plane);
         target.FillFromString2(
             string.Format(
                 "[[{0},{1},{2}],[{3},{4},{5},{6}],[0,0,0,0],[9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09]];",
                 plane.Origin.X, plane.Origin.Y, plane.Origin.Z, quatDoubles[0], quatDoubles[1], quatDoubles[2], quatDoubles[3]));
     }
     return target;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Create robot target from point and quaternion values.
 /// </summary>
 /// <param name="point">Point</param>
 /// <param name="q1">Quaternion</param>
 /// <param name="q2">Quaternion</param>
 /// <param name="q3">Quaternion</param>
 /// <param name="q4">Quaternion</param>
 /// <returns></returns>
 public static RobTarget RobTargetAtPoint0(Point point, double q1, double q2, double q3, double q4)
 {
     var target = new RobTarget();
     if (point != null)
     {
         target.FillFromString2(
             string.Format(
                 "[[{0},{1},{2}],[{3},{4},{5},{6}],[0,0,0,0],[9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09,9.999999999E09]];",
                 point.X, point.Y, point.Z, q1, q2, q3, q4));
     }
     return target;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Send robot target to controller.
        /// </summary>
        /// <param name="moduleName">Name of module</param>
        /// <param name="targetName">Name of target</param>
        /// <param name="targetValue">New value for target</param>
        public static void sendRobTargetToController(string moduleName, string targetName, string targetValue)
        {
            try
            {
                var scanner = new NetworkScanner();
                scanner.Scan();

                ControllerInfoCollection controllers = scanner.Controllers;
                using (var controller = ControllerFactory.CreateFrom(controllers[0]))
                {
                    controller.Logon(UserInfo.DefaultUser);
                    using (Mastership.Request(controller.Rapid))
                    {
                        if (controller.OperatingMode == ControllerOperatingMode.Auto)
                        {
                            using (var task = controller.Rapid.GetTask("T_ROB1"))
                            {
                                var target = new RobTarget();
                                using (var rapidData = task.GetRapidData(moduleName, targetName))
                                {
                                    if (rapidData.Value is RobTarget)
                                    {
                                        target.FillFromString2(targetValue);
                                        rapidData.Value = target;
                                    }
                                }

                                var result = task.Start(true);
                                Debug.WriteLine(result.ToString());

                                task.ResetProgramPointer();
                            }
                        }
                        else
                        {
                            Debug.WriteLine("Automatic mode is required to start execution from a remote client.");
                        }
                    }
                    controller.Logoff();
                }

            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
            }
        }