Exemple #1
0
 private void button4_Click(object sender, EventArgs e)
 {
     aRTDE.startSync();
     if (!aRTDE.isSynchronizing)
     {
         Thread.Sleep(10);
     }
     button4.Enabled = false;
     button5.Enabled = true;
 }
Exemple #2
0
        private void initURRobot()
        {
            aDashBoard = new DashBoard("192.168.100.11");
            aRTClient  = new RTClient("192.168.100.11");
            aRTDE      = new RTDE(System.Environment.CurrentDirectory + "\\RTDEConfig.xml", "192.168.100.11");
            //RTDE用于采集数据
            aRTDE.startSync();
            if (!aRTDE.isSynchronizing)
            {
                Thread.Sleep(10);
            }
            //RTClient用来控制
            aRTClient.startRTClient();
            while (aRTClient.Status != RTClientStatus.Syncing)
            {
                Thread.Sleep(10);
            }
            Thread thread = new Thread(new ThreadStart(refreshRobotData));

            thread.Start();
        }
Exemple #3
0
    private IEnumerator timer2_Tick()
    {
        while (true)
        {
            try
            {
                aRTDE.startSync(); //启动 RTDE server 同步
            }
            catch
            {
                throw;
            }
            if (aRTDE.isSynchronizing)
            {
                RTDEOutputObj outobj = aRTDE.getOutputObj(); //读取 RTDE output 数据
                CurTCPPos = outobj.actual_TCP_pose;
                //CurPX = outobj.actual_TCP_pose.X;
                //CurPY = outobj.actual_TCP_pose.Y;
                //CurPZ = outobj.actual_TCP_pose.Z;
                //CurRX = outobj.actual_TCP_pose.Rx;
                //CurRY = outobj.actual_TCP_pose.Ry;
                //CurRZ = outobj.actual_TCP_pose.Rz;

                CurJointPos = outobj.actual_q;
                //CurJ1 = outobj.actual_q.X;//机座
                //CurJ2 = outobj.actual_q.Y;//肩部
                //CurJ3 = outobj.actual_q.Z;//肘部
                //CurJ4 = outobj.actual_q.Rx;//手腕1
                //CurJ5 = outobj.actual_q.Ry;//手腕2
                //CurJ6 = outobj.actual_q.Rz;//手腕3

                string      tcppose = outobj.actual_TCP_pose.ToString();
                RTDEMessage aMsg    = new RTDEMessage("Content of message", "Message source",
                                                      RTDEMessage.INFO_MESSAGE); //创建 RTDEMessage 对象, Warning Level 为 Info
                aRTDE.sendMessage(aMsg);                                         //发送 RTDEMessage
                RTDEInputObj inobj = new RTDEInputObj();                         //创建 RTDE input 对象
                                                                                 // 将数字输出置为 0b00000011,RTDEInputObj 同步数据一定要是 RTDEConfig.xml 文件中已经配置好的 input
                inobj.standard_digital_output = 3;
                aRTDE.setInputObj(inobj);                                        //发送 input
            }

            //TCP当前位置
            if (CurTCPPos != null)
            {
                //ActTCPTB_X.Text = (CurTCPPos.X * 1000).ToString("0.00");
                //ActTCPTB_Y.Text = (CurTCPPos.Y * 1000).ToString("0.00");
                //ActTCPTB_Z.Text = (CurTCPPos.Z * 1000).ToString("0.00");
                //ActTCPTB_RX.Text = (CurTCPPos.Rx).ToString("0.00");
                //ActTCPTB_RY.Text = (CurTCPPos.Ry).ToString("0.00");
                //ActTCPTB_RZ.Text = (CurTCPPos.Rz).ToString("0.00");
            }
            //关节当前位置
            if (CurJointPos != null)
            {
                Pos[0].text = (CurJointPos.X * 180 / PI).ToString("0.00");
                Pos[1].text = (CurJointPos.Y * 180 / PI).ToString("0.00");
                Pos[2].text = (CurJointPos.Z * 180 / PI).ToString("0.00");
                Pos[3].text = (CurJointPos.Rx * 180 / PI).ToString("0.00");
                Pos[4].text = (CurJointPos.Ry * 180 / PI).ToString("0.00");
                Pos[5].text = (CurJointPos.Rz * 180 / PI).ToString("0.00");
            }
            aRTDE.stopSync(); //关闭 RTDE server 同步,释放资源
            yield return(new WaitForSeconds(1f));
        }
    }
Exemple #4
0
        private RTDE aRTDE;                  //RTDE instance, port: 30004
        #endregion

        #region initialize
        private void initData()
        {
            aDashBoard = new DashBoard("192.168.100.11");
            aRTClient  = new RTClient("192.168.100.11");
            aRTDE      = new RTDE(System.Environment.CurrentDirectory + "\\RTDEConfig.xml", "192.168.100.11");
            //RTDE用于采集数据
            aRTDE.startSync();
            if (!aRTDE.isSynchronizing)
            {
                Thread.Sleep(10);
            }


            for (int i = 0; i < 16; i++)
            {
                dataGridData myData = new dataGridData();
                myData.varName  = "I" + i;
                myData.varValue = 0;
                RobotInputData.Add(myData);
            }
            for (int i = 0; i < 16; i++)
            {
                dataGridData myData = new dataGridData();
                myData.varName  = "O" + i;
                myData.varValue = 0;
                RobotOutputData.Add(myData);
            }

            dataGridData otherData = new dataGridData();

            otherData.varName  = "A1";
            otherData.varValue = 0;
            RobotOtherData.Add(otherData);

            otherData          = new dataGridData();
            otherData.varName  = "A2";
            otherData.varValue = 0;
            RobotOtherData.Add(otherData);

            otherData          = new dataGridData();
            otherData.varName  = "A3";
            otherData.varValue = 0;
            RobotOtherData.Add(otherData);

            otherData          = new dataGridData();
            otherData.varName  = "A4";
            otherData.varValue = 0;
            RobotOtherData.Add(otherData);

            otherData          = new dataGridData();
            otherData.varName  = "A5";
            otherData.varValue = 0;
            RobotOtherData.Add(otherData);

            otherData          = new dataGridData();
            otherData.varName  = "A6";
            otherData.varValue = 0;
            RobotOtherData.Add(otherData);

            Thread thread = new Thread(new ThreadStart(refreshRobotData));

            thread.Start();
        }