// Create connection to server public void CreateConnection() { int numberofAttempts = 0; while (!mViconClient.IsConnected().Connected&& numberofAttempts < 3) { Output_Connect connect = mViconClient.Connect(HostNameAndPort); System.Threading.Thread.Sleep(200); ++numberofAttempts; } if (mViconClient.IsConnected().Connected) { // Enable all data streams mViconClient.EnableUnlabeledMarkerData(); mViconClient.EnableMarkerData(); mViconClient.EnableSegmentData(); Debug.Log("Connected to " + HostNameAndPort); return; } Debug.Log("Could not connect to " + HostNameAndPort); }
void Start() { print("Starting..."); // Make a new client Output_GetVersion OGV = MyClient.GetVersion(); print("GetVersion Major: " + OGV.Major); // Connect to a server string HostName = "192.168.1.119:801"; int noAttempts = 0; print("Connecting to " + HostName + "..."); while (!MyClient.IsConnected().Connected) { // Direct connection Output_Connect OC = MyClient.Connect(HostName); print("Connect result: " + OC.Result); noAttempts += 1; if (noAttempts == 3) { break; } System.Threading.Thread.Sleep(200); } MyClient.EnableSegmentData(); MyClient.EnableMarkerData(); MyClient.EnableUnlabeledMarkerData(); // get a frame from the data stream so we can inspect the list of subjects MyClient.GetFrame(); Output_GetSubjectCount OGSC = MyClient.GetSubjectCount(); print("GetSubjectCount: " + OGSC.Result + "|" + OGSC.SubjectCount); // the first subjects in the data stream will be the original subjects unmodified by pegasus Output_GetSubjectName OGSN = MyClient.GetSubjectName(OGSC.SubjectCount - 1); print("GetSubjectName: " + OGSN.Result + "|" + OGSN.SubjectName); SubjectName = OGSN.SubjectName; // get the position of the root and point the camera at it Output_GetSubjectRootSegmentName OGSRSN = MyClient.GetSubjectRootSegmentName(SubjectName); Output_GetSegmentGlobalTranslation RootPos = MyClient.GetSegmentGlobalTranslation(SubjectName, OGSRSN.SegmentName); Output_GetMarkerCount mcount = MyClient.GetMarkerCount(SubjectName); Output_GetUnlabeledMarkerGlobalTranslation OGSGT = MyClient.GetUnlabeledMarkerGlobalTranslation(0); Vector3 Target = new Vector3(-(float)OGSGT.Translation[0] / 1000f, (float)OGSGT.Translation[1] / 1000f, (float)OGSGT.Translation[2] / 1000f); Camera.main.transform.LookAt(Target); }
void Start() { Debug.Log("Starting Vicon"); mConnected = false; pClient = new ViconDataStreamSDK.DotNET.Client(); Debug.Log("Connecting to Vicon"); Output_Connect connect_result = pClient.Connect("localhost:801"); if (connect_result.Result == Result.Success) { Debug.Log("Connected"); mConnected = true; } else { Debug.Log("Not Connected"); } pClient.EnableSegmentData(); pClient.SetStreamMode(StreamMode.ClientPull); pClient.SetAxisMapping(Direction.Forward, Direction.Left, Direction.Up); }
private void ConnectClient() { bThreadRunning = true; // We have to handle the multi-route syntax, which is of the form HostName1:Port;Hostname2:Port String CombinedHostnameString = ""; String[] Hosts = HostName.Split(';'); foreach (String Host in Hosts) { String TrimmedString = Host.Trim(); String HostWithPort = null; // Check whether the hostname already contains a port and add if it doesn't if (TrimmedString.Contains(":")) { HostWithPort = TrimmedString; } else { HostWithPort = TrimmedString + ":" + Port; } if (!String.IsNullOrEmpty(CombinedHostnameString)) { CombinedHostnameString += ";"; } CombinedHostnameString += HostWithPort; } print("Connecting to " + CombinedHostnameString + "..."); if (IsRetimed) { while (bThreadRunning == true && !m_RetimingClient.IsConnected().Connected) { Output_Connect OC = m_RetimingClient.Connect(CombinedHostnameString); print("Connect result: " + OC.Result); System.Threading.Thread.Sleep(200); } if (UseLightweightData) { // Retiming client will have segment data enabled by default if (m_RetimingClient.EnableLightweightSegmentData().Result == Result.Success) { print("Using lightweight segment data"); } else { print("Unable to use lightweight segment data: Using standard segment data"); } } else { print("Using standard segment data"); } // get a frame from the data stream so we can inspect the list of subjects SetAxisMapping(Direction.Forward, Direction.Left, Direction.Up); //SetAxisMapping(Direction.Right, Direction.Up, Direction.Backward); ConnectionHandler(true); bThreadRunning = false; return; } while (bThreadRunning == true && !m_Client.IsConnected().Connected) { Output_Connect OC = m_Client.Connect(CombinedHostnameString); print("Connect result: " + OC.Result); System.Threading.Thread.Sleep(200); } if (UsePreFetch) { m_Client.SetStreamMode(StreamMode.ClientPullPreFetch); } else { m_Client.SetStreamMode(StreamMode.ServerPush); } // Get a frame first, to ensure we have received supported type data from the server before // trying to determine whether lightweight data can be used. GetNewFrame(); if (UseLightweightData) { if (m_Client.EnableLightweightSegmentData().Result != Result.Success) { print("Unable to use lightweight segment data: Using standard segment data"); m_Client.EnableSegmentData(); } else { print("Using lightweight segment data"); } } else { print("Using standard segment data"); m_Client.EnableSegmentData(); } SetAxisMapping(Direction.Forward, Direction.Left, Direction.Up); //SetAxisMapping(Direction.Right, Direction.Up, Direction.Backward); ConnectionHandler(true); // Get frames in this separate thread if we've asked for it. while (GetFrameThread && bThreadRunning) { GetNewFrame(); } bThreadRunning = false; }
private void ConnectClient() { bThreadRunning = true; String Host = HostName + ":" + Port; print("Connecting to " + Host + "..."); string res = ""; if (IsRetimed) { while (bThreadRunning == true && !m_RetimingClient.IsConnected().Connected) { Output_Connect OC = m_RetimingClient.Connect(Host); print("Connect result: " + OC.Result); System.Threading.Thread.Sleep(200); } if (UseLightweightData) { // Retiming client will have segment data enabled by default if (m_RetimingClient.EnableLightweightSegmentData().Result == Result.Success) { print("Using lightweight segment data"); } else { print("Unable to use lightweight segment data: Using standard segment data"); } } else { print("Using standard segment data"); } // get a frame from the data stream so we can inspect the list of subjects SetAxisMapping(Direction.Forward, Direction.Left, Direction.Up); //SetAxisMapping(Direction.Right, Direction.Up, Direction.Backward); ConnectionHandler(true); while (bThreadRunning == true) { print("getting new frame"); GetNewFrame(); } bThreadRunning = false; return; } while (bThreadRunning == true && !m_Client.IsConnected().Connected) { m_Client.EnableMarkerData(); m_Client.EnableSegmentData(); m_Client.EnableUnlabeledMarkerData(); m_Client.EnableDeviceData(); Output_Connect OC = m_Client.Connect(Host); print("Connect result: " + OC.Result); //data_UI.text = "Client connection success."; m_Client.EnableMarkerData(); m_Client.EnableSegmentData(); m_Client.EnableUnlabeledMarkerData(); m_Client.EnableDeviceData(); //m_Client.StartTransmittingMulticast(); System.Threading.Thread.Sleep(200); } if (UsePreFetch) { m_Client.SetStreamMode(StreamMode.ClientPullPreFetch); } else { m_Client.SetStreamMode(StreamMode.ServerPush); } if (UseLightweightData) { if (m_Client.EnableLightweightSegmentData().Result != Result.Success) { print("Unable to use lightweight segment data: Using standard segment data"); m_Client.EnableSegmentData(); } else { print("Using lightweight segment data"); } } else { print("Using standard segment data"); m_Client.EnableSegmentData(); } SetAxisMapping(Direction.Forward, Direction.Left, Direction.Up); //SetAxisMapping(Direction.Right, Direction.Up, Direction.Backward); ConnectionHandler(true); // Get frames in this separate thread if we've asked for it. while (GetFrameThread && bThreadRunning) { GetNewFrame(); } bThreadRunning = false; }