示例#1
0
    void OnApplicationQuit()
    {
        // shut down communication to Xsens
        if (_masterDevice != null)
        {
            _masterDevice.clearCallbackHandlers();
        }

        _measuringMts.Clear();

        UnityEngine.Debug.Log("Disable radio");
        if (_masterDevice != null)
        {
            if (_masterDevice.isRadioEnabled())
            {
                _masterDevice.disableRadio();
            }
        }

        UnityEngine.Debug.Log("closing connection to MTws");
        _xda.Dispose();
        _xda = null;

        // shut down connection to server
        _client.Close();
    }
        private void disposeDevices()
        {
            if (_measuringDevice != null)
            {
                _measuringDevice.clearCallbackHandlers();
            }

            _measuringMts.Clear();

            _xda.Dispose();
            _xda = null;
        }
示例#3
0
    void Start()
    {
        _currentMesh  = new Mesh();
        _meshRenderer = GetComponent <SkinnedMeshRenderer>();
        _poseUpdater  = new SMPLPoseUpdater(this.transform);
        _client       = new Client();

        // must match the name of the object in the scene
        _imuIdToName.Add(_rArmId, "r_arm");
        _imuIdToName.Add(_rLegId, "r_leg");
        _imuIdToName.Add(_lArmId, "l_arm");
        _imuIdToName.Add(_lLegId, "l_leg");
        _imuIdToName.Add(_pelvisId, "pelvis");
        _imuIdToName.Add(_headId, "head");

        // must match name in definition of SMPL model
        _imuIdToBoneName.Add(_rArmId, "R_Elbow");
        _imuIdToBoneName.Add(_rLegId, "R_Knee");
        _imuIdToBoneName.Add(_lArmId, "L_Elbow");
        _imuIdToBoneName.Add(_lLegId, "L_Knee");
        _imuIdToBoneName.Add(_pelvisId, "Pelvis");
        _imuIdToBoneName.Add(_headId, "Head");

        // to determine location where to display IMU sensors
        _imuIdToVertex.Add(_rArmId, 5431);   // right arm
        _imuIdToVertex.Add(_rLegId, 4583);   // right leg
        _imuIdToVertex.Add(_lArmId, 1962);   // left arm
        _imuIdToVertex.Add(_lLegId, 1096);   // left leg
        _imuIdToVertex.Add(_pelvisId, 3021); // pelvis
        _imuIdToVertex.Add(_headId, 412);

        // intialize control object that handles communication to XSens device
        _xda = new MyXda();

        // scan for devices
        ScanForStations();

        // enable radio for master device found when scanning for stations
        EnableRadio();
        _totalConnectedMTWs = _masterDevice.childCount();

        UnityEngine.Debug.Log("Waiting for MTWs to connect to the master.");

        // connect to inference server
        _client.ConnectToTcpServer();

        // load the model into a TensorFlow session
        LoadModel();
    }
        private static bool scanMeasuringDevices()
        {
            var retries = 0;

            _xda = new MyXda();
            while (retries < scanRetries)
            {
                _xda.scanPorts();
                if (_xda._DetectedDevices.Any())
                {
                    logger.Log($"{_xda._DetectedDevices.Count()} Devics Detected after {retries} retries.");
                    logger.Log($"IDs: { string.Join(", ", _xda._DetectedDevices.Select(d => d.deviceId().toInt().ToString())) }");
                    return(true);
                }

                retries++;
            }

            return(false);
        }