Exemplo n.º 1
0
    void Start()
    {
        // Get the global RTClient object from the Qualisys system
        rtClient = RTClient.GetInstance();

        // Loop through discovered servers to find one that matches our needs
        foreach (var discoveryResponse in rtClient.GetServers())
        {
            // Check if the response has the right IP address
            if (discoveryResponse.IpAddress == host)
            {
                Debug.Log("Desired Host Found");
                server      = discoveryResponse;
                foundServer = true;
            }
            Debug.Log(discoveryResponse.IpAddress);
            // else{
            //     Debug.Log("Desired Host not found");
            // }
        }

        // If a server is found at the correct host, connect to the server
        if (foundServer)
        {
            rtClient.Connect(server, 4545, true, true, false, false, false);
        }
    }
 /// <summary>
 /// Updates the rotation and position of the Character
 /// </summary>
 public void Update()
 {
     if (rtClient == null)
     {
         rtClient = RTClient.GetInstance();
     }
     if (!rtClient.GetStreamingStatus())
     {
         return;
     }
     markerData = rtClient.Markers;
     if ((markerData == null || markerData.Count == 0))
     {
         Debug.LogError("The stream does not contain any markers");
         return;
     }
     if (skeletonBuilder != null)
     {
         skeleton = skeletonBuilder.SolveSkeleton(markerData);
     }
     else
     {
         ResetSkeleton();
     }
     SetAll();
     if (!headCam.UseHeadCamera && headCamera)
     {
         DestroyCamera();
     }
 }
 /// <summary>
 /// Locating the joints of the character and find the scale by which the position should be applied to
 /// </summary>
 public void Start()
 {
     rtClient = RTClient.GetInstance();
     //Find all joints of the characters
     jointsFound = charactersJoints.SetLimbs(this.transform, UseFingers);
     // disable the animation
     var animation = this.GetComponent<Animation>();
     if (animation) animation.enabled = false;
 }
Exemplo n.º 4
0
        private RTDE aRTDE;                  //RTDE instance, port: 30004
        public Form1()
        {
            InitializeComponent();
            // create instance of robot communication class
            aDashBoard = new DashBoard(textBox1.Text);
            aRTClient  = new RTClient(textBox1.Text);
            aRTDE      = new RTDE(System.Windows.Forms.Application.StartupPath + "\\RTDEConfig.xml", textBox1.Text);

            //aRTDE = new RTDE(@"D:\UR Work\020 VS Projects\DEMO_URSDK\DEMO_URSDK\bin\Debug\RTDEConfig.xml", textBox1.Text);
            timer1.Interval = Convert.ToInt32(textBox10.Text);
        }
Exemplo n.º 5
0
 void Update()
 {
     if (RTClient.GetInstance().GetStreamingStatus())
     {
         Disable();
     }
     if (contentPanel.childCount < 1)
     {
         UpdateList();
     }
 }
Exemplo n.º 6
0
 void Connect()
 {
     if (!RTClient.GetInstance().Connect(response, response.Port, true, true, true))
     {
         InfoText.color = Color.red;
         InfoText.text  = "Could not connect to this server";
     }
     else
     {
         SendMessageUpwards("Disable");
     }
 }
        /// <summary>
        /// Locating the joints of the character and find the scale by which the position should be applied to
        /// </summary>
        public void Start()
        {
            rtClient = RTClient.GetInstance();
            //Find all joints of the characters
            jointsFound = charactersJoints.SetLimbs(this.transform, UseFingers);
            // disable the animation
            var animation = this.GetComponent <Animation>();

            if (animation)
            {
                animation.enabled = false;
            }
        }
Exemplo n.º 8
0
 // Start is called before the first frame update
 void Start()
 {
     aRTClient    = new RTClient(AdrIP);
     aDashBoard   = new DashBoard(AdrIP);
     primaryInt   = new PrimaryInterface(AdrIP, AdrPort);
     demoInstance = new PrimaryInterface(AdrIP);
     aRTDE        = new RTDE("file:///F:/XC/Assets/UR10/URSDK/RTDEConfig.xml", AdrIP);
     URConnect();
     for (int i = 0; i < 6; i++)
     {
         pd.Add(0);
     }
 }
Exemplo n.º 9
0
 private void textBox1_TextChanged(object sender, EventArgs e)   //IP address change event
 {
     aDashBoard = new DashBoard(textBox1.Text);
     if (aRTClient.Status != RTClientStatus.Stopped)
     {
         aRTClient.stopRTClient();
     }
     aRTClient = new RTClient(textBox1.Text);
     if (aRTDE.isSynchronizing)
     {
         aRTDE.stopSync();
     }
     aRTDE = new RTDE(System.Windows.Forms.Application.StartupPath + "\\RTDEConfig.xml", textBox1.Text);
 }
 /// <summary>
 /// Updates the rotation and position of the Character
 /// </summary>
 public void Update()
 {
     if (rtClient == null) rtClient = RTClient.GetInstance();
     if (!rtClient.GetStreamingStatus()) return;
     markerData = rtClient.Markers;
     if ((markerData == null || markerData.Count == 0))
     {
         Debug.LogError("The stream does not contain any markers");
         return;
     }
     if (skeletonBuilder != null) skeleton = skeletonBuilder.SolveSkeleton(markerData);
     else ResetSkeleton();
     SetAll();
     if (!headCam.UseHeadCamera && headCamera) DestroyCamera();
 }
Exemplo n.º 11
0
 public void UpdateList()
 {
     for (int i = 0; i < contentPanel.childCount; i++)
     {
         Destroy(contentPanel.GetChild(i).gameObject);
     }
     discoveryResponses = RTClient.GetInstance().GetServers();
     foreach (DiscoveryResponse server in discoveryResponses)
     {
         GameObject   newServer    = Instantiate(serverButtonPrefab) as GameObject;
         ServerButton serverButton = newServer.GetComponent <ServerButton>();
         serverButton.HostText.text      = server.HostName;
         serverButton.IpAddressText.text = server.IpAddress + ":" + server.Port;
         serverButton.InfoText.text      = server.InfoText;
         serverButton.response           = server;
         newServer.transform.SetParent(contentPanel);
     }
 }
Exemplo n.º 12
0
 public void Initialize(string host, int port)
 {
     _host = host;
     _port = port;
     try
     {
         _webDataClient = new RTClient();
         _webDataClient.Connect(_host, _port);
         _webDataClient.Login("WebDispatcher");
         _webDataClient.DataReceived += DataClient_DataReceived;
         // _webDataClient.CommandReceived += DataClient_CommandReceived;
         _webDataClient.Register(new string[] { "*" });
         _macAddress = SystemHelper.GetMACAddress(string.Empty);
     }
     catch (Exception ex)
     {
         _logService.Error(string.Format("ExistCatch:<-{0}->:{1}", "Initialize", ex.ToString()));
     }
 }
Exemplo n.º 13
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();
        }
Exemplo n.º 14
0
    // Start is called before the first frame update
    void Start()
    {
        rtClient = RTClient.GetInstance();

        // Loop through discovered servers to find one that matches our needs
        foreach (var discoveryResponse in rtClient.GetServers())
        {
            if (discoveryResponse.IpAddress == host)
            {
                Debug.Log("Desired Host Found");
                server      = discoveryResponse;
                foundServer = true;
            }
        }

        // Maybe do something on update to attempt again?
        if (foundServer)
        {
            rtClient.Connect(server, 4545, true, true, false, false, false, false);
        }
    }
Exemplo n.º 15
0
    IEnumerator Connect()
    {
        RTClient.GetInstance().StartConnecting(response.IpAddress, -1, true, true, false, true, false, true);
        InfoText.color = Color.yellow;
        InfoText.text  = "Connecting ...";

        while (RTClient.GetInstance().ConnectionState == RTConnectionState.Connecting)
        {
            yield return(null);
        }

        if (RTClient.GetInstance().ConnectionState == RTConnectionState.Connected)
        {
            SendMessageUpwards("Disable");
        }
        else
        {
            InfoText.color = Color.red;
            InfoText.text  = "Could not connect to this server";
        }
    }
Exemplo n.º 16
0
    //public float moveMult = 1f;

    void Start()
    {
        // Get a reference to the global Qualisys client object
        rtClient = RTClient.GetInstance();
    }
Exemplo n.º 17
0
 // Start is called before the first frame update
 void Start()
 {
     rtClient = RTClient.GetInstance();
 }
Exemplo n.º 18
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();
        }
        /// <summary>
        ///PointCloudの各点に対応する色の配列
        /// </summary>
        //System.Numerics.Vector3[] vertices;

        /// <summary>
        /// vertices中の何番目の点を描画するかのリスト(全部描画するけど手続き上必要)
        /// </summary>
        //Color[] colors;

        /// <summary>
        /// 座標変換(Color⇔Depth対応やDepth→xyzなど)をするためのクラス
        /// </summary>
        //int[] indices;

        /// <summary>
        /// Initializes a new instance of the MainWindow class.
        /// </summary>
        public MainWindow()
        {
            //set the robotic arm
            aDashBoard = new DashBoard("169.254.213.1");
            aRTClient  = new RTClient("169.254.213.1");
            primaryInt = new PrimaryInterface("169.254.213.1", 30001); //30001
            aRTClient.startRTClient();                                 //169.254.213.1     //192.168.1.128
            primaryInt.startPrimary();

            // Open the default device
            this.kinect = Device.Open();

            // Configure camera modes
            this.kinect.StartCameras(new DeviceConfiguration
            {
                ColorFormat            = ImageFormat.ColorBGRA32,
                ColorResolution        = ColorResolution.R1080p,
                DepthMode              = DepthMode.NFOV_2x2Binned,
                SynchronizedImagesOnly = true
            });
            //NFOV
            matrix_T_tool2tcp[0, 0] = -0.707;
            matrix_T_tool2tcp[0, 1] = -0.0739;
            matrix_T_tool2tcp[0, 2] = 0.7031;
            matrix_T_tool2tcp[0, 3] = 0.0566;
            matrix_T_tool2tcp[1, 0] = 0.7070;
            matrix_T_tool2tcp[1, 1] = -0.0739;
            matrix_T_tool2tcp[1, 2] = 0.7031;
            matrix_T_tool2tcp[1, 3] = 0.0566;
            matrix_T_tool2tcp[2, 0] = 0;
            matrix_T_tool2tcp[2, 1] = 0.9945;
            matrix_T_tool2tcp[2, 2] = 0.1045;
            matrix_T_tool2tcp[2, 3] = 0.1002;
            matrix_T_tool2tcp[3, 0] = 0;
            matrix_T_tool2tcp[3, 1] = 0;
            matrix_T_tool2tcp[3, 2] = 0;
            matrix_T_tool2tcp[3, 3] = 1;

            this.transform   = this.kinect.GetCalibration().CreateTransformation();
            this.colorWidth  = this.kinect.GetCalibration().ColorCameraCalibration.ResolutionWidth;
            this.colorHeight = this.kinect.GetCalibration().ColorCameraCalibration.ResolutionHeight;
            this.depthWidth  = this.kinect.GetCalibration().DepthCameraCalibration.ResolutionWidth;
            this.depthHeight = this.kinect.GetCalibration().DepthCameraCalibration.ResolutionHeight;
            this.bitmap      = new WriteableBitmap(colorWidth, colorHeight, 96.0, 96.0, PixelFormats.Bgra32, null);
            this.num         = depthHeight * depthWidth;

            vertices_0_b1 = new Vector3[num];
            vertices_0_b2 = new Vector3[num];
            vertices_0_b3 = new Vector3[num];
            vertices_0_b4 = new Vector3[num];
            vertices_0_b5 = new Vector3[num];

            colors_0_b1 = new Color32[num];
            colors_0_b2 = new Color32[num];
            colors_0_b3 = new Color32[num];
            colors_0_b4 = new Color32[num];
            colors_0_b5 = new Color32[num];


            this.DataContext = this;

            this.InitializeComponent();
        }
Exemplo n.º 20
0
        /// <summary>
        /// ...
        /// </summary>
        void LateUpdate()
        {
            if (eyeAnchor == null)
            {
                return;
            }

            // Get streamed rigid body definition of rift
            if (useRiftRigidBody && RTClient.GetInstance().GetStreamingStatus())
            {
                SixDOFBody rift = RTClient.GetInstance().GetBody(bodyName);
                if (rift != null && !rift.Rotation.Convert().IsNaN())
                {
                    sixDOFBodyRotation = new Quaternion(rift.Rotation.x, rift.Rotation.y, rift.Rotation.z, rift.Rotation.w);

                    // Reorientate the camera rig to match the 6 DOF coordinate system
                    if (
                        useInternalTracking &&
                        needsCameraRigReorientation &&
                        sixDOFBodyRotation != Quaternion.identity
                        )
                    {
                        Debug.Log("Calibrating Oculus Rift Pose...");
                        Debug.Log("Rift rotation " + rift.Rotation.eulerAngles);
                        Debug.Log("Anchor rotation " + eyeAnchor.localEulerAngles);

                        // Align the camera rig coordinate system to the QTM coordinate system by a rotation over the y-axis
                        //offsetAngle = (360 - eyeAnchor.eulerAngles.y) + sixDOFBodyRotation.eulerAngles.y;
                        //offsetAngle = eyeAnchor.localEulerAngles.y + sixDOFBodyRotation.eulerAngles.y + 180; // 180 cause of the rigid body axes
                        offsetAngle = 180 + sixDOFBodyRotation.eulerAngles.y - eyeAnchor.localEulerAngles.y;

                        // Enable avatar mesh
                        foreach (SkinnedMeshRenderer renderer in renderers)
                        {
                            renderer.enabled = true;
                        }

                        // OVR global coordinate system is calibrated
                        needsCameraRigReorientation = false;
                    }

                    // Show mirrored avatar when camera rig is orientated
                    if (showMirror)
                    {
                        mirroredCharacterJoints.root.gameObject.SetActive(true);
                    }

                    //RTClient.GetInstance().SetStatusMessage("OCULUS_RIFT", "", true);
                }
                else
                {
                    //RTClient.GetInstance().SetStatusMessage("OCULUS_RIFT", "", false);
                }
            }
            else if (!useRiftRigidBody && showMirror)
            {
                mirroredCharacterJoints.root.gameObject.SetActive(true);
            }

            // Get avatars head
            Transform head   = characterJoints.head;
            Vector3   lookAt = eyeAnchor.forward * 10.0f;

            // Set head orientation to rift orientation and position the camera rig in front of the head
            if (useInternalTracking)
            {
                head.rotation = eyeAnchor.rotation;
                cameraRig.transform.eulerAngles = new Vector3(0, this.transform.eulerAngles.y + offsetAngle, 0);
                //cameraRig.transform.position = head.position + head.rotation * cameraOffset;
                //cameraRig.transform.localPosition = head.position + cameraRig.transform.rotation * cameraOffset;
                //cameraRig.transform.localPosition = head.position + eyeAnchor.rotation * cameraOffset;
                // Need to substract the position of the eye anchor
                cameraRig.transform.localPosition =
                    head.position
                    - cameraRig.transform.rotation * eyeAnchor.localPosition
                    + eyeAnchor.rotation * cameraOffset;
            }
            else
            {
                head.localRotation = sixDOFBodyRotation;
            }

            // Draw debug ray in look direction
            Debug.DrawRay(eyeAnchor.position, lookAt, Color.green);

            // Set pose of the mirrored avatar
            if (showMirror)
            {
                setMirroredAvatarPose();
            }
        }