/// <summary> /// Initializes the ExperimentSystem and its components. /// Verifies that all components needed for the experiment are available. /// </summary> public override void InitialiseExperimentSystems() { // // Set the experiment type and ID // experimentType = ExperimentType.TypeOne; ExperimentSystem.SetActiveExperimentID("PhotoStage"); // // Create data loggers // // Restart EMG readings foreach (ISensor sensor in AvatarSystem.GetActiveSensors()) { if (sensor.GetSensorType().Equals(SensorType.EMGWiFi)) { UDPSensorManager udpSensor = (UDPSensorManager)sensor; //Debug.Log(wifiSensor.RunThread); udpSensor.StartSensorReading(); //Debug.Log(wifiSensor.RunThread); } } // Set EMG sensor and reference generator as active. // Get prosthesis GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); ConfigurableElbowManager elbowManager = prosthesisManagerGO.GetComponent <ConfigurableElbowManager>(); // Set active sensor and reference generator to EMG. elbowManager.ChangeSensor("VAL_SENSOR_SEMG"); elbowManager.ChangeReferenceGenerator("VAL_REFGEN_EMGPROP"); }
public void OnDestroy() { foreach (ISensor sensor in AvatarSystem.GetActiveSensors()) { // Stop all UDP sensors if (sensor.GetSensorType() == SensorType.EMGWiFi) { UDPSensorManager udpSensor = (UDPSensorManager)sensor; udpSensor.StopSensorReading(); } } }
private void OnApplicationQuit() { // Check if WiFi sensors are available foreach (ISensor sensor in AvatarSystem.GetActiveSensors()) { if (sensor.GetSensorType().Equals(SensorType.EMGWiFi)) { UDPSensorManager udpSensor = (UDPSensorManager)sensor; udpSensor.StopSensorReading(); } } // // Save and close all logs // ExperimentSystem.CloseAllExperimentLoggers(); }
/// <summary> /// Initializes the ExperimentSystem and its components. /// Verifies that all components needed for the experiment are available. /// </summary> public override void InitialiseExperimentSystems() { // // Set the experiment type and ID // if (AvatarSystem.AvatarType == AvatarType.AbleBodied) { experimentType = ExperimentType.TypeOne; MonitorManager.DisplayText("Wrong avatar used. Please use a Transhumeral avatar."); throw new System.Exception("Able-bodied avatar not suitable for prosthesis training."); } else if (AvatarSystem.AvatarType == AvatarType.Transhumeral) { // Check if EMG is available bool EMGAvailable = false; foreach (ISensor sensor in AvatarSystem.GetActiveSensors()) { if (sensor.GetSensorType().Equals(SensorType.EMGWiFi)) { EMGAvailable = true; UDPSensorManager udpSensor = (UDPSensorManager)sensor; udpSensor.StartSensorReading(); } else if (sensor.GetSensorType().Equals(SensorType.ThalmicMyo)) { EMGAvailable = true; } } // Set whether emg or synergy based if (EMGAvailable) { experimentType = ExperimentType.TypeTwo; instructionsText = emgInstructions; // Set EMG sensor and reference generator as active. // Get prosthesis GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); elbowManager = prosthesisManagerGO.GetComponent <ConfigurableElbowManager>(); // Set active sensor and reference generator to EMG. //elbowManager.ChangeSensor("VAL_SENSOR_SEMG"); elbowManager.ChangeSensor("VAL_SENSOR_THALMYO"); elbowManager.ChangeReferenceGenerator("VAL_REFGEN_EMGPROP"); } else { experimentType = ExperimentType.TypeThree; instructionsText = synergyInstructions; // Set VIVE tracker and Jacobian synergy as active. // Get prosthesis GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); elbowManager = prosthesisManagerGO.GetComponent <ConfigurableElbowManager>(); if (elbowManager.GetInterfaceType() == ReferenceGeneratorType.JacobianSynergy) { // Set the reference generator to jacobian-based. elbowManager.ChangeSensor("VAL_SENSOR_VIVETRACKER"); elbowManager.ChangeReferenceGenerator("VAL_REFGEN_JACOBIANSYN"); } else if (elbowManager.GetInterfaceType() == ReferenceGeneratorType.LinearKinematicSynergy) { // Set the reference generator to linear synergy. elbowManager.ChangeSensor("VAL_SENSOR_VIVETRACKER"); elbowManager.ChangeReferenceGenerator("VAL_REFGEN_LINKINSYN"); } else { throw new System.Exception("The prosthesis interface available is not supported."); } } if (!debug) { // Find the residual limb and change the follower residualLimbGO = GameObject.FindGameObjectWithTag("ResidualLimbAvatar"); limbFollower = residualLimbGO.GetComponent <LimbFollower>(); limbFollower.enabled = false; angleFollower = residualLimbGO.AddComponent <AngleFollower>(); angleFollower.fixedTransform = fixedProsthesisPosition; } } else { throw new System.NotImplementedException(); } // Get Raycast Debug info // handGO = GameObject.FindGameObjectWithTag("Hand"); // elbowGO = GameObject.FindGameObjectWithTag("Elbow_Upper"); // residualLimbGO = GameObject.FindGameObjectWithTag("ResidualLimbAvatar"); }
/// <summary> /// Initializes the ExperimentSystem and its components. /// Verifies that all components needed for the experiment are available. /// </summary> public override void InitialiseExperimentSystems() { // Check the experiment parameters if (startAngleList.Count <= 0 || endAngleList.Count <= 0 || movementTimeList.Count <= 0) { throw new System.Exception("An experiment configuration list is empty."); } if (startAngleList.Count != endAngleList.Count) { throw new System.Exception("The angle lists do not match in size."); } // // Set the experiment type and ID // if (AvatarSystem.AvatarType == AvatarType.AbleBodied) { // Check if EMG is available bool EMGAvailable = false; foreach (ISensor sensor in AvatarSystem.GetActiveSensors()) { if (sensor.GetSensorType().Equals(SensorType.EMGWiFi)) { EMGAvailable = true; UDPSensorManager udpSensor = (UDPSensorManager)sensor; //Debug.Log(wifiSensor.RunThread); udpSensor.StartSensorReading(); //Debug.Log(wifiSensor.RunThread); } } // Set whether emg or synergy based if (EMGAvailable) { experimentType = ExperimentType.TypeTwo; ExperimentSystem.SetActiveExperimentID("EMG_Data"); } else { if (debug) { // DEBUG ONLY experimentType = ExperimentType.TypeTwo; ExperimentSystem.SetActiveExperimentID("EMG_Data"); // DEBUG ONLY } else { throw new System.Exception("An EMG measurement device is required."); } } } else { throw new System.NotImplementedException(); } // // Create data loggers // motionLogger = new DataStreamLogger("Motion"); ExperimentSystem.AddExperimentLogger(motionLogger); // // Check and add experiment sensors // // // Add VIVE Trackers. // if (!debug) { GameObject motionTrackerGO = AvatarSystem.AddMotionTracker(); VIVETrackerManager upperArmTracker = new VIVETrackerManager(motionTrackerGO.transform); ExperimentSystem.AddSensor(upperArmTracker); // Shoulder acromium head tracker GameObject motionTrackerGO1 = AvatarSystem.AddMotionTracker(); VIVETrackerManager shoulderTracker = new VIVETrackerManager(motionTrackerGO1.transform); ExperimentSystem.AddSensor(shoulderTracker); // Set arm guide position tracking guideManager.shoulderLocationTransform = motionTrackerGO1.transform; } }