private void LoadDebugAvatar() { // Load avatar if (avatarType == AvatarType.Transhumeral) { AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.Transhumeral); // Find the residual limb and change the follower GameObject residualLimbGO = GameObject.FindGameObjectWithTag("ResidualLimbAvatar"); LimbFollower limbFollower = residualLimbGO.GetComponent <LimbFollower>(); Destroy(limbFollower); AngleFollower angleFollower = residualLimbGO.AddComponent <AngleFollower>(); angleFollower.fixedTransform = fixedProsthesisPosition; // Initialize prosthesis GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager"); ConfigurableElbowManager elbowManager = prosthesisManagerGO.AddComponent <ConfigurableElbowManager>(); elbowManager.InitializeProsthesis(SaveSystem.ActiveUser.upperArmLength, (SaveSystem.ActiveUser.forearmLength + SaveSystem.ActiveUser.handLength / 2.0f)); // Set the reference generator to jacobian-based. elbowManager.ChangeReferenceGenerator("VAL_REFGEN_JACOBIANSYN"); instructionsText = synergyInstructions; // Enable & configure EMG if (emgEnable) { // Create and add sensor //EMGWiFiManager emgSensor = new EMGWiFiManager(ip, port, channelSize); ThalmicMyobandManager emgSensor = new ThalmicMyobandManager(); //emgSensor.ConfigureLimits(0, 1023, 0); //emgSensor.ConfigureLimits(1, 1023, 0); AvatarSystem.AddActiveSensor(emgSensor); elbowManager.AddSensor(emgSensor); //emgSensor.StartSensorReading(); // Set active sensor and reference generator to EMG. elbowManager.ChangeSensor("VAL_SENSOR_SEMG"); elbowManager.ChangeReferenceGenerator("VAL_REFGEN_EMGPROP"); instructionsText = emgInstructions; } } else { throw new System.NotImplementedException(); } }
/// <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"); }