Beispiel #1
0
 public void MotionAll(RobotMotion motion)
 {
     foreach (var r in robots)
     {
         r.AddMotion(new RobotMotion(motion));
     }
 }
Beispiel #2
0
 static ServerMediation()
 {
     st_ServerCenter  = GameObject.Find("Network").GetComponent <ServerCenter>();
     st_ScreenBuild   = GameObject.Find("MyScreen").GetComponent <ScreenBuild>();
     st_ButtonRespond = GameObject.Find("MyButton").GetComponent <ButtonRespond>();
     st_RobotMotion   = GameObject.Find("MyMotion").GetComponent <RobotMotion>();
     st_Camerascript  = GameObject.Find("CameraFree").GetComponent <Camerascript>();
 }
Beispiel #3
0
 public void empty()
 {
     FILEPATH     = Application.dataPath + "\\StreamingAssets\\Programs\\";
     GSKFile      = new ROBOTFILE(FILEPATH);
     button       = GameObject.Find("MyButton").GetComponent <ButtonRespond>();
     ScreenScript = GameObject.Find("MyScreen").GetComponent <ScreenBuild>();
     MotionScript = GameObject.Find("MyMotion").GetComponent <RobotMotion>();
     TipsShow     = GameObject.Find("MainScript").GetComponent <TipsWindow>();
     Voice        = GameObject.Find("MainScript").GetComponent <doVoiceExe>();
     TipsMo       = new TipsMotion();
     TipsManager  = new TipsInfoManager();
 }
Beispiel #4
0
    private string getPointInfo()
    {
        RobotMotion Motionscript = GameObject.Find("MyMotion").GetComponent <RobotMotion>();

        float[] angle8 = Motionscript.CurrentAngle_All();
        string  point  = "(";

        for (int i = 0; i < 8; i++)
        {
            point += angle8[i].ToString();
            if (i != 7)
            {
                point += ",";
            }
        }
        point += ")";
        return(point);
    }
Beispiel #5
0
 void Start()
 {
     panelcamera = GameObject.Find("CameraUI").GetComponent <Camera>();
     Rays[0]     = GameObject.Find("ray1");
     Rays[1]     = GameObject.Find("ray2");
     Rays[2]     = GameObject.Find("ray3");
     Rays[3]     = GameObject.Find("ray4");
     Rays[4]     = GameObject.Find("ray5");
     Rays[5]     = GameObject.Find("ray6");
     Closeray();
     TeXiao              = GameObject.Find("texiao");
     Factory             = GameObject.Find("Model");
     Scene1              = GameObject.Find("scene1");
     Xipan1              = GameObject.Find("xipan1");
     Pen1                = GameObject.Find("penpen");
     BigPaws             = GameObject.Find("MechanicalArm_63_2");
     Scene3_6            = GameObject.Find("MechanicalArm_63");
     Scene3_table        = GameObject.Find("scx17_1");
     Scene2              = GameObject.Find("scene2");
     Scene5              = GameObject.Find("scene5");
     Scene6              = GameObject.Find("scene6");
     Robot1              = GameObject.Find("Robot_01");
     Scene3              = GameObject.Find("scene3");
     Scene4              = GameObject.Find("scene4");
     Scene10             = GameObject.Find("scene0");
     axisGuid            = GameObject.Find("AxisTips");
     upDownTrans         = GameObject.Find("upDownTrans").GetComponent <Transform>();
     rightLeftTrans      = GameObject.Find("rightLeftTrans").GetComponent <Transform>();
     ExcelPath           = Application.dataPath + "/StreamingAssets/Excel/MyCamera.xls";
     this.camera.enabled = false;//自由相机不工作
     axisGuid.SetActive(false);
     robotmove         = GameObject.Find("MyMotion").GetComponent <RobotMotion>();
     origianlWorkpiece = GameObject.Find("scx0261");
     ConveyorBelt      = GameObject.Find("chuansongdai35");
     TeXiao.SetActive(false);
     BigPaws.SetActive(false);
     Scene3_table.SetActive(false);
 }
Beispiel #6
0
    // Use this for initialization
    void Start()
    {
        joystick     = GameObject.Find("MoveJoystick");
        joystickBind = joystick.GetComponent <JoystickBind>();
        if (!joystickBind.getBinded())
        {
            etcJoystick = joystick.GetComponent <ETCJoystick>();
            robotMotion = gameObject.GetComponent <RobotMotion>();
            etcJoystick.onMove.AddListener(robotMotion.JoystickMove);
            etcJoystick.onTouchStart.AddListener(robotMotion.JoystickMoveStart);
            etcJoystick.onTouchUp.AddListener(robotMotion.JoysitckMoveEnd);

            mainCamera         = GameObject.Find("Main Camera");
            cameraMotion       = mainCamera.GetComponent <CameraMotion>();
            cameraMotion.Robot = gameObject;

            minimapCamera       = GameObject.Find("MinimapCamera");
            minimapMotion       = minimapCamera.GetComponent <MinimapMotion>();
            minimapMotion.Robot = gameObject;

            joystickBind.bindJoystick();
        }
    }
Beispiel #7
0
    public void Initial(string casename, string filename)
    {
        ObjectInitial();
        StageTotal    = 0;
        stage_current = 0;
        DetectNo      = 0;
        caseName      = casename;
        FileName      = filename;
        TipsShow      = GameObject.Find("MainScript").GetComponent <TipsWindow>();
        Voice         = GameObject.Find("MainScript").GetComponent <doVoiceExe>();
        TipsMo        = new TipsMotion();
        TipsManager   = new TipsInfoManager();
        button        = GameObject.Find("MyButton").GetComponent <ButtonRespond>();
        FILEPATH      = Application.dataPath + "\\StreamingAssets\\Programs\\";
        GSKFile       = new ROBOTFILE(FILEPATH);
        ScreenScript  = GameObject.Find("MyScreen").GetComponent <ScreenBuild>();
        MotionScript  = GameObject.Find("MyMotion").GetComponent <RobotMotion>();

        CalculateTotalStage();
        CaseIntro.SetActive(true);
        CaseIntro.CaseStart(casename);
        PanelInitial();//面板初始化
    }
Beispiel #8
0
 public RobotMotion(RobotMotion src) : this(src.animation, src.duration)
 {
 }
Beispiel #9
0
 // 保存されたMotionを追加していく
 public void AddMotion(RobotMotion m)
 {
     motions.Add(m);
 }
Beispiel #10
0
 void Start()
 {
     robotmotion = GameObject.Find("MyMotion").GetComponent <RobotMotion>();
     basicTips   = GameObject.Find("MainScript").GetComponent <BasicOperate>();
     button      = GameObject.Find("MyButton").GetComponent <ButtonRespond>();
 }
Beispiel #11
0
    public bool SolvingA3()
    {
        MoveScript = GameObject.Find("MyMotion").GetComponent <RobotMotion>();
        Special    = false;
        //theta1.....2
        float[] A_1 = new float[2];
        A_1[0] = Mathf.Atan2(Py, Px) - Mathf.Atan2(d3, Mathf.Sqrt(Px * Px + Py * Py - d3 * d3));
        A_1[1] = Mathf.Atan2(Py, Px) - Mathf.Atan2(d3, -Mathf.Sqrt(Px * Px + Py * Py - d3 * d3));
        if (Mathf.Abs(A_1[0] * 180 / Mathf.PI - theta1) < Mathf.Abs(A_1[1] * 180 / Mathf.PI - theta1))
        {
            angle1 = A_1[0];
        }
        else
        {
            angle1 = A_1[1];
        }
        theta1 = angle1 * 180 / Mathf.PI;
        if (float.IsNaN(theta1) || float.IsInfinity(theta1))
        {
            Debug.Log("theta1无穷大或者不是实数");
            return(false);
        }

        //theta3......2
        float[] A_3 = new float[2];
        float   k3  = (Px * Px + Py * Py + Pz * Pz + a1 * a1 - 2 * a1 * (Mathf.Cos(angle1) * Px + Mathf.Sin(angle1) * Py) - a2 * a2 - a3 * a3 - d3 * d3 - d4 * d4) / (2 * a2);

        A_3[0] = Mathf.Atan2(a3, d4) - Mathf.Atan2(k3, Mathf.Sqrt(a3 * a3 + d4 * d4 - k3 * k3));
        A_3[1] = Mathf.Atan2(a3, d4) - Mathf.Atan2(k3, -Mathf.Sqrt(a3 * a3 + d4 * d4 - k3 * k3));
        A_3[0] = A_3[0] * 180 / Mathf.PI;//转换成度数
        A_3[1] = A_3[1] * 180 / Mathf.PI;
        if ((float.IsNaN(A_3[0]) || float.IsInfinity(A_3[0])) && (float.IsNaN(A_3[1]) || float.IsInfinity(A_3[1])))
        {
            Debug.Log("theta3无穷大或者不是实数");
            angle3 = theta3 * Mathf.PI / 180;
            return(false);
        }
        else
        {
            if (!MoveScript.AngleLimit(3, A_3[0]))
            {
                if (MoveScript.AngleLimit(3, A_3[0] + 360))
                {
                    A_3[0] = A_3[0] + 360;
                    Debug.Log("+360");
                }
                else if (MoveScript.AngleLimit(3, A_3[0] - 360))
                {
                    A_3[0] = A_3[0] - 360;
                    Debug.Log("-360");
                }
                else
                {
                    A_3[0] = 9999;
                }
            }
            if (!MoveScript.AngleLimit(3, A_3[1]))
            {
                if (MoveScript.AngleLimit(3, A_3[1] + 360))
                {
                    A_3[1] = A_3[1] + 360;
                    Debug.Log("+360");
                }
                else if (MoveScript.AngleLimit(3, A_3[1] - 360))
                {
                    A_3[1] = A_3[1] - 360;
                    Debug.Log("-360");
                }
                else
                {
                    A_3[1] = 9999;
                }
            }
            if (A_3[0] == 9999 && A_3[1] == 9999)
            {
                Debug.Log("theta3超过运动极限" + A_3);
                return(false);
            }
            if (Mathf.Abs(A_3[0] - theta3) < Mathf.Abs(A_3[1] - theta3))
            {
                theta3 = A_3[0];
            }
            else
            {
                theta3 = A_3[1];
            }
            angle3 = theta3 / 180 * Mathf.PI;
        }



        //theta2.....2
        float[] A_2 = new float[2];
        float   k21 = (-a3 - a2 * Mathf.Cos(angle3)) * Pz - (Mathf.Cos(angle1) * Px + Mathf.Sin(angle1) * Py - a1) * (d4 - a2 * Mathf.Sin(angle3));
        float   k22 = (a2 * Mathf.Sin(angle3) - d4) * Pz + (a3 + a2 * Mathf.Cos(angle3)) * (Mathf.Cos(angle1) * Px + Mathf.Sin(angle1) * Py - a1);

        A_2[0] = Mathf.Atan2(k21, k22) - angle3 + Mathf.PI / 2;
        A_2[1] = Mathf.Atan2(k21, k22) - angle3 - Mathf.PI / 2;
        A_2[0] = A_2[0] * 180 / Mathf.PI;//转换成度数
        A_2[1] = A_2[1] * 180 / Mathf.PI;
        if ((float.IsNaN(A_2[0]) || float.IsInfinity(A_2[0])) && (float.IsNaN(A_2[1]) || float.IsInfinity(A_2[1])))
        {
            Debug.Log("theta2无穷大或者不是实数");
            return(false);
        }
        else
        {
            if (!MoveScript.AngleLimit(2, A_2[0]))
            {
                if (MoveScript.AngleLimit(2, A_2[0] + 360))
                {
                    A_2[0] = A_2[0] + 360;
                    Debug.Log("+360");
                }
                else if (MoveScript.AngleLimit(2, A_2[0] - 360))
                {
                    A_2[0] = A_2[0] - 360;
                    Debug.Log("-360");
                }
                else
                {
                    A_2[0] = 9999;
                }
            }
            if (!MoveScript.AngleLimit(2, A_2[1]))
            {
                if (MoveScript.AngleLimit(2, A_3[1] + 360))
                {
                    A_2[1] = A_2[1] + 360;
                    Debug.Log("+360");
                }
                else if (MoveScript.AngleLimit(2, A_2[1] - 360))
                {
                    A_2[1] = A_2[1] - 360;
                    Debug.Log("-360");
                }
                else
                {
                    A_2[1] = 9999;
                }
            }
            if (A_2[0] == 9999 && A_2[1] == 9999)
            {
                Debug.Log("theta2超过运动极限");
                return(false);
            }
            if (Mathf.Abs(A_2[0] - theta2) < Mathf.Abs(A_2[1] - theta2))
            {
                theta2 = A_2[0];
            }
            else
            {
                theta2 = A_2[1];
            }
            angle2 = (theta2 - 90) / 180 * Mathf.PI;//90 90 90
        }


        //theta4.....2
        float[] A_4 = new float[2];
        float   k41 = Mathf.Sin(angle1) * Ax - Mathf.Cos(angle1) * Ay;
        float   k42 = Mathf.Cos(angle1) * Mathf.Cos(angle3 + angle2) * Ax + Mathf.Sin(angle1) * Mathf.Cos(angle3 + angle2) * Ay - Mathf.Sin(angle2 + angle3) * Az;

        A_4[0] = Mathf.Atan2(-k41, -k42);
        A_4[1] = Mathf.Atan2(-k41, -k42) + Mathf.PI;
        A_4[0] = A_4[0] * 180 / Mathf.PI;
        A_4[1] = A_4[1] * 180 / Mathf.PI;
        if (Mathf.Abs(-k41) < 0.00001f && Mathf.Abs(-k42) < 0.00001f)//奇异点
        {
            angle4 = (theta4) * Mathf.PI / 180;
        }
        else
        {
            if (float.IsNaN(theta4) || float.IsInfinity(theta4))
            {
                Debug.Log("theta4无穷大或者不是实数");
            }
            if (!MoveScript.AngleLimit(4, A_4[0]))
            {
                //Debug.Log("A_4[0]" + A_4[0]);
                A_4[0] = 9999;
            }
            if (!MoveScript.AngleLimit(4, A_4[1]))
            {
                if (MoveScript.AngleLimit(4, A_4[1] - 360))
                {
                    A_4[1] = A_4[1] - 360;
                    //Debug.Log("-360 :" + A_4[1]);
                }
                else
                {
                    A_4[1] = 9999;
                }
            }
            if (A_4[0] == 9999 && A_4[1] == 9999)
            {
                Debug.Log("theta4超过运动极限");
                return(false);
            }
            else if (Mathf.Abs(A_4[0] - theta4) < Mathf.Abs(A_4[1] - theta4))
            {
                //if (Mathf.Abs(A_4[0] - theta4) < 90)
                //{
                theta4 = A_4[0];
                //}
                //else
                //{

                //    Debug.Log("xxx" + A_4[0] + ",,," + A_4[1]);
                //}
            }
            else
            {
                //if (Mathf.Abs(A_4[1] - theta4) < 90)
                //{
                theta4 = A_4[1];
                //}
                //else
                //{

                //    Debug.Log("xxx" + A_4[0] + ",,," + A_4[1]);
                //}
            }
            angle4 = theta4 / 180 * Mathf.PI;
        }


        //theta5.....1
        float A_5;
        float k51 = (Mathf.Sin(angle4) * Mathf.Sin(angle1) + Mathf.Cos(angle1) * Mathf.Cos(angle4) * Mathf.Cos(angle2 + angle3)) * Ax + (Mathf.Cos(angle4) * Mathf.Sin(angle1) * Mathf.Cos(angle2 + angle3) - Mathf.Cos(angle1) * Mathf.Sin(angle4)) * Ay - Mathf.Sin(angle2 + angle3) * Mathf.Cos(angle4) * Az;
        float k52 = -Mathf.Sin(angle2 + angle3) * Mathf.Cos(angle1) * Ax - Mathf.Sin(angle2 + angle3) * Mathf.Sin(angle1) * Ay - Mathf.Cos(angle2 + angle3) * Az;

        A_5 = Mathf.Atan2(-k51, k52);
        //float k51 = -Mathf.Cos(angle4) * k42 - Mathf.Sin(angle4) * k41;
        //float k52 = -Mathf.Sin(angle2 + angle3) * (Mathf.Cos(angle1) * Ax + Mathf.Sin(angle1) * Ay) + Mathf.Cos(angle2 + angle3) * Az;
        //A_5 = Mathf.Atan2(k51, k52);

        if (float.IsNaN(theta5) || float.IsInfinity(theta5))
        {
            Debug.Log("theta5无穷大或者不是实数");
            angle5 = (theta5) * Mathf.PI / 180;
            //return false;
        }
        else
        {
            A_5 = A_5 * 180 / Mathf.PI;
            if (!MoveScript.AngleLimit(5, A_5))
            {
                //Debug.Log("theta4 " + theta4);
                //Debug.Log("A_5: " + A_5);

                if (MoveScript.AngleLimit(5, A_5 + 360))
                {
                    A_5 = A_5 + 360;
                    //Debug.Log("A_5: " + A_5);
                }
                //else if (MoveScript.AngleLimit(5, A_5 - 180))
                //{
                //    A_5 = A_5 - 180;
                //    Debug.Log("A_5: " + A_5);
                //}
                //else
                //{
                //    Debug.Log("theta5超过运动极限" + A_5);
                //    return false;
                //}
            }
            //特殊处理部分,绕过突变点
            //if (Mathf.Abs(A_5 - theta5) > 20)
            //{
            //    Special = true;
            //    Debug.Log("tubian" + theta5);
            //}
            //else
            {
                theta5 = A_5;
                //Debug.Log("A_5 :"+A_5);
                angle5 = theta5 / 180 * Mathf.PI;
            }
        }


        //theta6.....1
        float A_6;
        float k61 = (Mathf.Cos(angle1) * Mathf.Sin(angle4) * Mathf.Cos(angle2 + angle3) - Mathf.Cos(angle4) * Mathf.Sin(angle1)) * Nx + (Mathf.Cos(angle1) * Mathf.Cos(angle4) + Mathf.Sin(angle1) * Mathf.Sin(angle4) * Mathf.Cos(angle2 + angle3)) * Ny - Mathf.Sin(angle2 + angle3) * Mathf.Sin(angle4) * Nz;
        float k62 = (Mathf.Sin(angle4) * Mathf.Sin(angle1) * Mathf.Cos(angle5) - Mathf.Cos(angle1) * Mathf.Sin(angle5) * Mathf.Sin(angle2 + angle3) + Mathf.Cos(angle1) * Mathf.Cos(angle4) * Mathf.Cos(angle2 + angle3) * Mathf.Cos(angle5)) * Nx - (Mathf.Cos(angle1) * Mathf.Sin(angle4) * Mathf.Cos(angle5) + Mathf.Sin(angle1) * Mathf.Sin(angle5) * Mathf.Sin(angle2 + angle3) - Mathf.Sin(angle1) * Mathf.Cos(angle4) * Mathf.Cos(angle5) * Mathf.Cos(angle2 + angle3)) * Ny + (-Mathf.Sin(angle5) * Mathf.Cos(angle2 + angle3) - Mathf.Cos(angle4) * Mathf.Cos(angle5) * Mathf.Sin(angle2 + angle3)) * Nz;

        A_6 = Mathf.Atan2(-k61, k62);
        //float V112 = Mathf.Cos(angle1) * Ox + Mathf.Sin(angle1) * Oy;
        //float V132 = Mathf.Sin(angle1) * Ox - Mathf.Cos(angle1) * Oy;
        //float V332 = -Mathf.Sin(angle2 + angle3) * V112 + Mathf.Cos(angle2 + angle3) * Oz;
        //float V312 = Mathf.Cos(angle2 + angle3) * V112 + Mathf.Sin(angle2 + angle3) * Oz;
        //float V432 = Mathf.Sin(angle4) * V312 + Mathf.Cos(angle4) * V132;
        //float V422 = V332;
        //float V412 = Mathf.Cos(angle4) * V312 - Mathf.Sin(angle4) * V132;
        //float k61 = -Mathf.Cos(angle5) * V412 - Mathf.Sin(angle5) * V422;
        //float k62 = -V432;
        //A_6 = Mathf.Atan2(k61, k62);

        if (float.IsNaN(theta6) || float.IsInfinity(theta6))
        {
            Debug.Log("theta6无穷大或者不是实数");
            angle6 = (theta6) * Mathf.PI / 180;
            //return false;
        }
        else
        {
            A_6 = A_6 * 180 / Mathf.PI;
            if (!MoveScript.AngleLimit(6, A_6))
            {
                if (MoveScript.AngleLimit(6, A_6 + 360))
                {
                    A_6 = A_6 + 360;
                }
                else if (MoveScript.AngleLimit(6, A_6 - 360))
                {
                    A_6 = A_6 - 360;
                }
                else
                {
                    Debug.Log("theta6超过运动极限" + A_6);
                    return(false);
                }
            }
            theta6 = A_6;
            angle6 = theta6 / 180 * Mathf.PI;
        }

        //特殊情况处理
        //if (Special)
        //{
        //    theta4 = 5;
        //    theta5 = 0;
        //    theta6 = -theta4;
        //}

        return(true);
    }
Beispiel #12
0
    // Update is called once per frame
    void Update()
    {
        int mcode = MouseCode();

        if (mcode == 1 || mcode == 2)
        {
            RobotMotion[] motions = new RobotMotion[] {
                new RobotMotion(
                    (r, p) =>
                {
                    if (p >= 0.5)
                    {
                        r.Pose("Left");
                    }
                }, 2f
                    ),
                new RobotMotion(
                    (r, p) =>
                {
                    if (p >= 0.5)
                    {
                        r.Pose("Right");
                    }
                }, 2f
                    ),
            };

            List <int>[] selected = new List <int>[]
            {
                new List <int>()
                {
                    0, 0
                },
                new List <int>()
                {
                    0, 0
                },
            };
            for (int cnt = 0; cnt < groups.Count; cnt++)
            {
                groups[cnt].MotionRandom(motions, selected[cnt]);
            }

            RobotMotion dance = new RobotMotion(
                (r, p) =>
            {
                r.GetComponent <Transform>().localRotation =
                    Quaternion.Euler(0, 360f * p, 0);
            }, 2f
                );


            if (selected[0][mcode - 1] > selected[1][mcode - 1])
            {
                Debug.Log("左");
                groups[0].MotionAll(dance);
            }
            else if (selected[0][mcode - 1] < selected[1][mcode - 1])
            {
                Debug.Log("右");
                groups[1].MotionAll(dance);
            }
            else
            {
                Debug.Log("引き分け");
            }
        }
    }
Beispiel #13
0
    void OnGUI()
    {
        RobotMotion motionss = GameObject.Find("MyMotion").GetComponent <RobotMotion>();

        //if(GUILayout.Button("go"))
        //{
        //    float[] actual = motionss.CurrentAngle_All();
        //    Vector3 StartPoint = motionss.IKA.SolutionOfKinematics(actual);
        //    Quaternion Posture = motionss.IKA.SolutionOfKinematics_posture(actual);
        //    float[] theory = motionss.IKA.AcceptInterPointPosture(StartPoint, Posture, actual);
        //    for (int i = 0; i < 6; i++)
        //    {
        //        Debug.Log("第"+i+"轴的转动角度:"+theory[i]);
        //        if (Mathf.Abs(actual[i] - theory[i])>0.5)
        //        {
        //            Debug.Log("机械臂运动学逆解出现错误!!" + "实际角度:" + actual[i] + ",理论角度:" + theory[i]+".");
        //        }
        //    }
        //}
        if (GUILayout.Button("camera"))
        {
            Camerascript cameras = GameObject.Find("CameraFree").GetComponent <Camerascript>();
            cameras.SwitchCamera();
        }
        //if (GUILayout.Button("add scene"))
        //{
        //    GSKDATA.Scene_NO++;
        //}
        if (GUILayout.Button("部件提示功能"))
        {
            FuncPara.componentTips = !FuncPara.componentTips;
        }

        //if (GUILayout.Button("姿态检测"))
        //{
        //    float[] actual = motionss.CurrentAngle_All();
        //    Quaternion Posture = motionss.IKA.SolutionOfKinematics_posture(actual);
        //    Quaternion Posture2 = GameObject.Find("Shape13").GetComponent<Transform>().rotation;
        //    Debug.Log("理论姿态" + Posture.ToString("0.000"));
        //    Debug.Log("实际姿态" + Posture2.ToString("0.000"));
        //}

        if (GUILayout.Button("IO面板"))
        {
            GameObject.Find("MyButton").GetComponent <ButtonRespond>().ShowIOPanel();
        }

        if (GUILayout.Button("示教器面板"))
        {
            GameObject.Find("MyButton").GetComponent <ButtonRespond>().ShowPanel();
        }

        if (GUILayout.Button("返回零点"))
        {
            GameObject.Find("MyMotion").GetComponent <RobotMotion>().ReturnToZero();
        }

        if (GUILayout.Button("视角还原"))
        {
            GameObject.Find("CameraFree").GetComponent <Camerascript>().CameraPosition();
        }

        if (GUILayout.Button("清空画板"))
        {
            GUILine.TextureInitial(paletter1);
        }
        if (GUILayout.Button("画画"))
        {
            GSKDATA.Painting = true;
        }
        if (GUILayout.Button("案例一"))
        {
            GSKDATA.Painting = true;
        }
        if (GUILayout.Button("案例二"))
        {
            GSKDATA.Painting = true;
        }
        if (GUILayout.Button("方向"))
        {
            Transform tooldir  = GameObject.Find("Circle0571").GetComponent <Transform>();
            Transform tooldir2 = GameObject.Find("qt208").GetComponent <Transform>();
            Debug.Log(tooldir.forward.ToString("0.00"));
            Debug.Log(tooldir2.forward.ToString("0.00"));
        }
        if (GUILayout.Button("光晕"))
        {
            GameObject.Find("qt208").AddComponent <FlashingController>();
        }
        if (GUILayout.Button("GuidPath"))
        {
            GameObject.Find("CameraFree").GetComponent <Camerascript>().SetPathGuid();
        }
        if (GUILayout.Button("教学"))
        {
        }
        if (GUILayout.Button("练习"))
        {
        }
    }
Beispiel #14
0
        /// <summary>
        /// 对机器人程序进行操作
        /// </summary>
        /// <param name="FM"></param>
        /// <param name="robotTask"></param>
        /// <param name="listBoxMain"></param>
        /// <param name="listBoxTarget"></param>
        /// <param name="Pbar"></param>
        public void ReadTaskTagList(Form FM, RobotTask robotTask, ListBox listBoxMain, ListBox listBoxTarget, ProgressBar Pbar, ref List <Tag> tagList, ref List <Tag> viatagList, ref List <Tag> processtagList)
        {
            listBoxMain.Items.Clear();
            listBoxTarget.Items.Clear();
            tagList.Clear();
            viatagList.Clear();
            processtagList.Clear();
            if (robotTask.ChildrenActivities.Count < 1)
            {
                Pbar.Maximum = 100;
                Pbar.Value   = 100;
                Pbar.Step    = 1;
                return;
            }
            Pbar.Value = 0;
            //List<Tag> tagList = new List<Tag>(); // Init A container to Save Target Tag List
            //List<Tag> viatagList = new List<Tag>(); // Init A container to Save Target Tag List
            //List<Tag> processtagList = new List<Tag>(); // Init A container to Save Target Tag List
            Pbar.Maximum = robotTask.ChildrenActivities.Count;
            try
            {
                foreach (Operation soperation in robotTask.ChildrenActivities)
                {
                    foreach (Activity activity in soperation.ChildrenActivities)
                    {
                        string activityName = activity.Type;
                        if (activityName == "DNBRobotMotionActivity")
                        {
                            RobotMotion robotMotion = (RobotMotion)activity;
                            short       TagetType   = -1;
                            robotMotion.GetTargetType(ref TagetType); //Type of the Target (Cartesian = 0, Joint = 1, Tag = 2, Home = 3).
                            if (TagetType != 2)
                            {
                                continue;
                            }
                            try
                            {
                                Tag tag = null;
                                robotMotion.GetTagTarget(ref tag);
                                var Return = tagList.Find(
                                    delegate(Tag tag1)
                                {
                                    return(tag1.get_Name() == tag.get_Name()); //需要修改为检查ID 名称可重复
                                });                                            // Check Repeact
                                if (Return == null)                            //当列表中不存在时 把新对象加载进入
                                {
                                    //确定当前Opration类型 The Via Mode (1 if the target is a via point and 0 if the Target is Untyped (process)).
                                    short ViaMode = -1;
                                    soperation.GetViaMode(ref ViaMode);
                                    switch (ViaMode)
                                    {
                                    case 0:
                                        processtagList.Add(tag);
                                        break;

                                    case 1:
                                        viatagList.Add(tag);
                                        break;

                                    default:
                                        break;
                                    }
                                    tagList.Add(tag);
                                    string TagName = tag.get_Name();
                                    listBoxMain.Items.Add(TagName);
                                }
                            }
                            catch (Exception)
                            {
                                continue;
                                //throw;
                            }
                        }
                    }
                    Pbar.PerformStep();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("在处理Oprations时发生错误,请联系或在帮助选项中反馈该问题!" + e.Message);
            }
            Pbar.Value = Pbar.Maximum;
        }