public void LoadFeedbackTransradialAvatar() { if (ip == null || ip == string.Empty || port == 0) { logManager.DisplayInformationOnLog(3.0f, "The provided sensor info is invalid."); } try { AvatarSystem.LoadPlayer(SaveSystem.ActiveUser.type, AvatarType.Transradial); AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.Transradial); //mainCamera.fieldOfView = 60; KeepPlayerGameObjects(); StartCoroutine(ResetCamera()); StartCoroutine(DisplayInformationAndReturn(2.0f, "Successfully loaded transradial avatar.")); // Initialize prosthesis feedback system GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); FakeEMGBoniHand prosthesisManager = prosthesisManagerGO.AddComponent <FakeEMGBoniHand>(); prosthesisManager.InitialiseFeedbackSystem(ip, port); } catch (System.Exception e) { StartCoroutine(DisplayInformationAndReturn(10.0f, e.Message)); } }
/// <summary> /// Add a new EMG sensor /// </summary> public void AddSensor() { // Create and add sensor ThalmicMyobandManager emgSensor = new ThalmicMyobandManager(); AvatarSystem.AddActiveSensor(emgSensor); // Get prosthesis and add sensor when tH if (AvatarSystem.AvatarType == AvatarType.Transhumeral) { GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); ConfigurableElbowManager elbowManager = prosthesisManagerGO.GetComponent <ConfigurableElbowManager>(); elbowManager.AddSensor(emgSensor); } else if (AvatarSystem.AvatarType == AvatarType.Transradial) { GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); FakeEMGBoniHand prosthesisManager = prosthesisManagerGO.GetComponent <FakeEMGBoniHand>(); prosthesisManager.InitialiseInputSystem(emgSensor); } // Return to settings menu. addSensorMenu.ReturnToSettingsMenu(); }
/// <summary> /// Add a new EMG sensor /// </summary> public void AddSensor() { if (ip == null || ip == string.Empty || port == 0 || channelSize <= 0) { StartCoroutine(DisplayInformationOnLog(3.0f, "The provided sensor info is invalid.")); } try { // Create and add sensor EMGWiFiManager emgSensor = new EMGWiFiManager(ip, port, channelSize, isRaw); AvatarSystem.AddActiveSensor(emgSensor); // Get prosthesis and add sensor when tH if (AvatarSystem.AvatarType == AvatarType.Transhumeral) { GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); ConfigurableElbowManager elbowManager = prosthesisManagerGO.GetComponent <ConfigurableElbowManager>(); elbowManager.AddSensor(emgSensor); } else if (AvatarSystem.AvatarType == AvatarType.Transradial) { GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); FakeEMGBoniHand prosthesisManager = prosthesisManagerGO.GetComponent <FakeEMGBoniHand>(); prosthesisManager.InitialiseInputSystem(emgSensor); } // Return to settings menu. addSensorMenu.ReturnToSettingsMenu(); } // 10048 address duplicate catch (SocketException e) when(e.ErrorCode == 10048) { StartCoroutine(DisplayInformationOnLog(3.0f, "IP address already in use.")); } // 10045 port duplicate catch (SocketException e) when(e.ErrorCode == 10045) { StartCoroutine(DisplayInformationOnLog(3.0f, "Port already in use.")); } catch (System.Exception e) { StartCoroutine(DisplayInformationOnLog(3.0f, "An error occured while adding the sensor.\nError message: " + e.Message)); } }
public void LoadNoFeedbackTransradialAvatar() { try { AvatarSystem.LoadPlayer(SaveSystem.ActiveUser.type, AvatarType.Transradial); AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.Transradial); //mainCamera.fieldOfView = 60; KeepPlayerGameObjects(); StartCoroutine(ResetCamera()); StartCoroutine(DisplayInformationAndReturn(2.0f, "Successfully loaded transradial avatar.")); // Initialize prosthesis GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); FakeEMGBoniHand prosthesisManager = prosthesisManagerGO.AddComponent <FakeEMGBoniHand>(); //prosthesisManager.InitializeProsthesis(); } catch (System.Exception e) { StartCoroutine(DisplayInformationAndReturn(10.0f, e.Message)); } }
/// <summary> /// Checks that all the required components have been loaded and starts experiment. /// </summary> public void InitialiseExperiment() { bool EMGAvailable = false; switch (experimentNumber) { case NONE: // Check that a valid experiment has been selected logManager.DisplayInformationOnLog(3.0f, "Please select a valid experiment."); break; // // Jacobian synergy experiment // case JACOBIAN_SYNERGY: // Able-bodied case if (optionNumber == 1 && AvatarSystem.AvatarType == AvatarType.AbleBodied) { KeepOnLoad(); // Load experiment. SteamVR_LoadLevel.Begin("JacobianSynergyExperiment"); } // EMG case else if (optionNumber == 2 && AvatarSystem.AvatarType == AvatarType.Transhumeral) { // Check that an EMG sensor is available EMGAvailable = false; foreach (ISensor sensor in AvatarSystem.GetActiveSensors()) { if (sensor.GetSensorType().Equals(SensorType.EMGWiFi)) { EMGAvailable = true; } else if (sensor.GetSensorType().Equals(SensorType.ThalmicMyo)) { EMGAvailable = true; } } // Load when EMG is available. if (EMGAvailable) { KeepOnLoad(); // Load experiment. //SteamVR_LoadLevel.Begin("JacobianSynergyExperiment"); // Load training SteamVR_LoadLevel.Begin("ProsthesisTraining"); } else { logManager.DisplayInformationOnLog(3.0f, "Please add and configure an EMG sensor."); } } // Synergy case else if ((optionNumber == 3 || optionNumber == 4) && AvatarSystem.AvatarType == AvatarType.Transhumeral) { KeepOnLoad(); // Load experiment. // SteamVR_LoadLevel.Begin("JacobianSynergyExperiment"); GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); ConfigurableElbowManager elbowManager = prosthesisManagerGO.GetComponent <ConfigurableElbowManager>(); if (optionNumber == 3) { // Set VIVE tracker and Jacobian synergy as active. // Get prosthesis prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); elbowManager = prosthesisManagerGO.GetComponent <ConfigurableElbowManager>(); // Set the reference generator to jacobian-based. elbowManager.ChangeSensor("VAL_SENSOR_VIVETRACKER"); elbowManager.ChangeReferenceGenerator("VAL_REFGEN_JACOBIANSYN"); } else if (optionNumber == 4) { // Set VIVE tracker and Linear synergy as active. // Get prosthesis prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); elbowManager = prosthesisManagerGO.GetComponent <ConfigurableElbowManager>(); // Set the reference generator to linear synergy. elbowManager.ChangeSensor("VAL_SENSOR_VIVETRACKER"); elbowManager.ChangeReferenceGenerator("VAL_REFGEN_LINKINSYN"); } // Load training SteamVR_LoadLevel.Begin("ProsthesisTraining"); // Load experiment. //SteamVR_LoadLevel.Begin("JacobianSynergyExperiment"); } else { logManager.DisplayInformationOnLog(3.0f, "Please configure the " + optionList[optionNumber] + " avatar."); } break; case FEEDBACK2019: // Check that a transradial prosthesis has been set. if (AvatarSystem.AvatarType != AvatarType.Transradial) { logManager.DisplayInformationOnLog(3.0f, "Please configure the Transradial avatar."); } else { // Initialise the prosthesis try { GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); FakeEMGBoniHand prosthesisManager = prosthesisManagerGO.GetComponent <FakeEMGBoniHand>(); prosthesisManager.InitializeProsthesis(); // Set the name from the selected dropdown! ExperimentSystem.SetActiveExperimentID("Feedback2019"); } catch (Exception e) { logManager.DisplayInformationOnLog(10.0f, "Error encountered: " + e.Message); } } break; // // // case EMG_DATA: // Check that an EMG sensor is available EMGAvailable = false; foreach (ISensor sensor in AvatarSystem.GetActiveSensors()) { if (sensor.GetSensorType().Equals(SensorType.EMGWiFi)) { EMGAvailable = true; } } // Load when EMG is available. if (EMGAvailable) { KeepOnLoad(); // Load experiment. SteamVR_LoadLevel.Begin("EMGShoulderData"); } else { logManager.DisplayInformationOnLog(3.0f, "Please add and configure an EMG sensor."); } break; } }