Ejemplo n.º 1
0
 private void textBox8_TextChanged(object sender, EventArgs e)
 {
     if (aRTDE.isSynchronizing)
     {
         try
         {
             double tempV = Convert.ToDouble(textBox8.Text);
             if (tempV > 0 && tempV <= 1)
             {
                 RTDEInputObj InObj = new RTDEInputObj();
                 InObj.speed_slider_mask     = 1;
                 InObj.speed_slider_fraction = tempV;
                 aRTDE.setInputObj(InObj);
             }
         }
         catch { }
     }
 }
Ejemplo n.º 2
0
 private void textBox11_TextChanged(object sender, EventArgs e)
 {
     if (aRTDE.isSynchronizing)
     {
         try
         {
             byte tempV = Convert.ToByte(textBox11.Text);
             if (tempV >= 0 && tempV <= 255)
             {
                 RTDEInputObj InObj = new RTDEInputObj();
                 InObj.standard_digital_output_mask = 255;
                 InObj.standard_digital_output      = tempV;
                 aRTDE.setInputObj(InObj);
             }
         }
         catch
         { }
     }
 }
Ejemplo n.º 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));
        }
    }