예제 #1
0
    public void LoadTranshumeralAvatar()
    {
        try
        {
            AvatarSystem.LoadPlayer(SaveSystem.ActiveUser.type, AvatarType.Transhumeral);
            AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.Transhumeral);

            //mainCamera.fieldOfView = 60;
            KeepPlayerGameObjects();

            StartCoroutine(ResetCamera());
            StartCoroutine(DisplayInformationAndReturn(2.0f, "Successfully loaded transhumeral avatar."));

            // 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");
        }
        catch (System.Exception e)
        {
            StartCoroutine(DisplayInformationAndReturn(10.0f, e.Message));
        }
    }
    public void LoadPlayground()
    {
        // Load player and able bodied avatar (without adaptive tracker).
        SaveSystem.LoadUserData("DB1942174");
        AvatarSystem.LoadPlayer(SaveSystem.ActiveUser.type, AvatarType.AbleBodied);
        AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.AbleBodied, false);
        // Change the number for the forearm tracker being used
        GameObject            faTrackerGO   = GameObject.FindGameObjectWithTag("ForearmTracker");
        SteamVR_TrackedObject steamvrConfig = faTrackerGO.GetComponent <SteamVR_TrackedObject>();

        steamvrConfig.index = SteamVR_TrackedObject.EIndex.Device5;
        //
        KeepOnLoad();
        // Load level.
        SteamVR_LoadLevel.Begin("DemoPlayground");

        /*
         * KeepOnLoad();
         * // Load level.
         * if (AvatarSystem.AvatarType == AvatarType.Transradial)
         * {
         *  GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager");
         *  FakeEMGBoniHand prosthesisManager = prosthesisManagerGO.GetComponent<FakeEMGBoniHand>();
         *  prosthesisManager.InitializeProsthesis();
         * }
         * SteamVR_LoadLevel.Begin("FantasyTemplate");
         */
        //SteamVR_LoadLevel.Begin("PhotoStage");
    }
예제 #3
0
    /// <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();
    }
    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));
        }
    }
    public void LoadAbleBodiedAvatar()
    {
        // Fade
        SteamVR_Fade.Start(Color.black, 0.0f);

        // Load
        avatarType = AvatarType.AbleBodied;
        AvatarSystem.LoadPlayer(SaveSystem.ActiveUser.type, AvatarType.AbleBodied);
        AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.AbleBodied, false);
        // Enable colliders
        StartCoroutine(EnableColliders());
        // Initialize UI.
        InitializeUI();
        // Fade
        SteamVR_Fade.Start(Color.black, 0.0f);

        // Change the number for the forearm tracker being used
        GameObject            faTrackerGO   = GameObject.FindGameObjectWithTag("ForearmTracker");
        SteamVR_TrackedObject steamvrConfig = faTrackerGO.GetComponent <SteamVR_TrackedObject>();

        steamvrConfig.index = SteamVR_TrackedObject.EIndex.Device5;

        // Teleport to the start position
        StartCoroutine(TeleportCoroutine());
    }
예제 #6
0
    public void LoadAbleBodiedAvatar()
    {
        // Load
        SaveSystem.LoadUserData("MD1942");
        AvatarSystem.LoadPlayer(SaveSystem.ActiveUser.type, AvatarType.AbleBodied);
        AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.AbleBodied, false);
        // Initialize UI.
        //InitializeUI();

        // Change the number for the forearm tracker being used
        GameObject            faTrackerGO   = GameObject.FindGameObjectWithTag("ForearmTracker");
        SteamVR_TrackedObject steamvrConfig = faTrackerGO.GetComponent <SteamVR_TrackedObject>();

        steamvrConfig.index = SteamVR_TrackedObject.EIndex.Device5;
        // Configure the grasp manager
        GameObject graspManagerGO = GameObject.FindGameObjectWithTag("GraspManager");

        if (graspManagerGO == null)
        {
            throw new System.Exception("Grasp Manager not found.");
        }
        GraspManager graspManager = graspManagerGO.GetComponent <GraspManager>();

        graspManager.managerType = GraspManager.GraspManagerType.Assisted;
        graspManager.managerMode = GraspManager.GraspManagerMode.Restriced;
    }
    public IEnumerator EnableColliders()
    {
        yield return(new WaitForSecondsRealtime(3.0f));

        // Enable colliders
        AvatarSystem.EnableAvatarColliders();
    }
예제 #8
0
    /// <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");
    }
예제 #9
0
    public void LoadTHAvatar()
    {
        SaveSystem.LoadUserData("MD1942");
        AvatarSystem.LoadPlayer(UserType.Ablebodied, AvatarType.Transhumeral);
        AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.Transhumeral);

        // Initialize prosthesis
        GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager");

        elbowManager = prosthesisManagerGO.AddComponent <ConfigurableElbowManager>();
        elbowManager.InitializeProsthesis(SaveSystem.ActiveUser.upperArmLength, (SaveSystem.ActiveUser.forearmLength + SaveSystem.ActiveUser.handLength / 2.0f), 1.5f);
        // Set the reference generator to jacobian-based.
        elbowManager.ChangeReferenceGenerator("VAL_REFGEN_LINKINSYN");
        //elbowManager.ChangeReferenceGenerator("VAL_REFGEN_JACOBIANSYN");

        // Initialize UI.
        //InitializeUI();
        // Configure the grasp manager
        GameObject graspManagerGO = GameObject.FindGameObjectWithTag("GraspManager");

        if (graspManagerGO == null)
        {
            throw new System.Exception("Grasp Manager not found.");
        }
        GraspManager graspManager = graspManagerGO.GetComponent <GraspManager>();

        graspManager.managerType = GraspManager.GraspManagerType.Assisted;
        graspManager.managerMode = GraspManager.GraspManagerMode.Restriced;

        // set syn
        elbowManager.SetSynergy(theta);
    }
    public void LoadTHAvatar()
    {
        // Fade
        SteamVR_Fade.Start(Color.black, 0.0f);
        // Load
        avatarType = AvatarType.Transhumeral;

        AvatarSystem.LoadPlayer(UserType.Ablebodied, AvatarType.Transhumeral);
        AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.Transhumeral);
        // Fade
        SteamVR_Fade.Start(Color.black, 0.0f);

        // Initialize prosthesis
        GameObject prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager");

        elbowManager = prosthesisManagerGO.AddComponent <ConfigurableElbowManager>();
        elbowManager.InitializeProsthesis(SaveSystem.ActiveUser.upperArmLength, (SaveSystem.ActiveUser.forearmLength + SaveSystem.ActiveUser.handLength / 2.0f), 1.5f);
        // Set the reference generator to jacobian-based.
        elbowManager.ChangeReferenceGenerator("VAL_REFGEN_LINKINSYN");

        StartCoroutine(EnableColliders());
        // Initialize UI.
        InitializeUI();

        // Teleport to the start position
        StartCoroutine(TeleportCoroutine());
    }
예제 #11
0
 // Start is called before the first frame update
 void Start()
 {
     // Load player
     SaveSystem.LoadUserData("MD1942");
     AvatarSystem.LoadPlayer(SaveSystem.ActiveUser.type, avatarType);
     InitialiseExperimentSystems();
     InitializeUI();
 }
 // Start is called before the first frame update
 void Awake()
 {
     // Load player
     if (debug)
     {
         SaveSystem.LoadUserData("MD1942");
         AvatarSystem.LoadPlayer(SaveSystem.ActiveUser.type, AvatarType.AbleBodied);
         AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.AbleBodied);
     }
 }
예제 #13
0
    public void OnEnable()
    {
        //Debug.Log(Application.persistentDataPath);
        if (createdUser)
        {
            logManager.DisplayInformationOnLog(3.0f, "Created new user with ID " + SaveSystem.ActiveUser.id);
            createdUser = false;
        }

        if (loadedUser)
        {
            logManager.DisplayInformationOnLog(3.0f, "Loaded user with ID " + SaveSystem.ActiveUser.id);
            createdUser = false;
        }

        // Display active user name.
        if (SaveSystem.IsUserAvailable)
        {
            activeUserTMP.text = "Active User: \n" + SaveSystem.ActiveUser.name + " " + SaveSystem.ActiveUser.familyName;
        }

        // Display available user sensors name.
        if (AvatarSystem.GetActiveSensors().Count > 0)
        {
            sensorTMP.text = "Sensors: \n";
            foreach (ISensor sensor in AvatarSystem.GetActiveSensors())
            {
                sensorTMP.text = sensorTMP.text + sensor.GetSensorType().ToString() + "\n";
            }
        }

        // Display available experiment sensors name.
        if (ExperimentSystem.GetActiveSensors().Count > 0)
        {
            experimentSensorsTMP.text = "Experiment Sensors: \n";
            foreach (ISensor sensor in ExperimentSystem.GetActiveSensors())
            {
                experimentSensorsTMP.text = experimentSensorsTMP.text + sensor.GetSensorType().ToString() + "\n";
            }
        }

        // Conditional menus
        // Show avatar menu when there is an available user.
        if (SaveSystem.IsUserAvailable)
        {
            avatarOptionsButton.SetActive(true);
        }

        // Show sensors menu when there is an available avatar.
        if (AvatarSystem.IsPlayerAvailable && AvatarSystem.IsAvatarAvaiable)
        {
            sensorOptionsButton.SetActive(true);
            modeSelectionButton.SetActive(true);
        }
    }
예제 #14
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(this);
     }
     else
     {
         instance = this;
     }
 }
    // Here are all the methods you need to write for your experiment.
    #region GameMaster Inherited Methods

    // Place debug stuff here, for when you want to test the experiment directly from the world without
    // having to load it from the menus.
    private void Awake()
    {
        if (debug)
        {
            SaveSystem.LoadUserData("DB1942174"); // Load the test/demo user (Mr Demo)
            //
            // Debug using able-bodied configuration
            //
            AvatarSystem.LoadPlayer(SaveSystem.ActiveUser.type, AvatarType.AbleBodied);
            AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.AbleBodied);
        }
    }
    /// <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
        //

        //
        // Create data loggers
        //

        AvatarSystem.EnableAvatarColliders();
    }
예제 #17
0
 public void OnDestroy()
 {
     foreach (ISensor sensor in AvatarSystem.GetActiveSensors())
     {
         // Stop all UDP sensors
         if (sensor.GetSensorType() == SensorType.EMGWiFi)
         {
             UDPSensorManager udpSensor = (UDPSensorManager)sensor;
             udpSensor.StopSensorReading();
         }
     }
 }
예제 #18
0
 private void Awake()
 {
     if (debug)
     {
         SaveSystem.LoadUserData("MD1942");
         //SaveSystem.LoadUserData("RG1988");
         //
         // Debug Able
         //
         AvatarSystem.LoadPlayer(SaveSystem.ActiveUser.type, AvatarType.AbleBodied);
         AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.AbleBodied);
     }
 }
    // Debug
    // private GameObject handGO;
    // private GameObject elbowGO;

    // Start is called before the first frame update
    protected override void Start()
    {
        TrainingCamera.enabled = false;
        if (debug)
        {
            // Load player
            SaveSystem.LoadUserData("MD1942");
            AvatarSystem.LoadPlayer(SaveSystem.ActiveUser.type, avatarType);
        }
        else
        {
            InitialiseExperimentSystems();
            InitializeUI();
        }
    }
예제 #20
0
 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();
 }
예제 #21
0
    public void LoadAbleBodiedAvatar()
    {
        try
        {
            AvatarSystem.LoadPlayer(SaveSystem.ActiveUser.type, AvatarType.AbleBodied);
            AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.AbleBodied);

            KeepPlayerGameObjects();

            StartCoroutine(ResetCamera());
            StartCoroutine(DisplayInformationAndReturn(2.0f, "Successfully loaded able-bodied avatar."));
        }
        catch (System.Exception e)
        {
            StartCoroutine(DisplayInformationAndReturn(10.0f, e.Message));
        }
    }
    /// <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));
        }
    }
    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();
        }
    }
    public void OnEnable()
    {
        // Clear list
        sensorList.Clear();
        // Add an empty one as default to force selection.
        sensorList.Add(string.Empty);

        // Display available sensors name.
        foreach (ISensor sensor in AvatarSystem.GetActiveSensors())
        {
            sensorList.Add(sensor.GetSensorType().ToString());
        }
        // Add the options to the dropdown
        sensorDropdown.AddOptions(sensorList);
        // And select the last choice.
        UpdatedSelectedSensor(selectedSensor);
    }
예제 #25
0
    // Start is called before the first frame update
    void Start()
    {
        if (debug)
        {
            SaveSystem.LoadUserData("MD1942");
            AvatarSystem.LoadPlayer(UserType.Ablebodied, AvatarType.AbleBodied);
            AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.AbleBodied);
        }
        // Initialize ExperimentSystem
        InitialiseExperimentSystems();

        // Initialize UI.
        InitializeUI();

        // Initialize iteration management.
        timeIterationLimit  = iterationsPerAngle * startAngleList.Count;
        totalIterationLimit = iterationsPerAngle * startAngleList.Count * movementTimeList.Count;

        //
        SetWaitFlag(5.0f);
    }
예제 #26
0
    // Here are all the methods you need to write for your experiment.
    #region GameMaster Inherited Methods

    // Place debug stuff here, for when you want to test the experiment directly from the world without
    // having to load it from the menus.
    private void Awake()
    {
        if (debug)
        {
            //// Save some test config data
            //string configFilePath = Application.dataPath + "/Resources/Experiments/GridReaching2020.json";
            //Debug.Log(configFilePath);
            //configurator = new GridReachingConfigurator();
            //string configuratorAsJson = JsonUtility.ToJson(configurator);
            //File.WriteAllText(configFilePath, configuratorAsJson);

            //
            // Debug able
            //
            SaveSystem.LoadUserData("TB1995175"); // Load the test/demo user (Mr Demo)
            //
            // Debug using able-bodied configuration
            //

            /*
             * AvatarSystem.LoadPlayer(SaveSystem.ActiveUser.type, AvatarType.AbleBodied);
             * AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.AbleBodied);
             */

            //
            // Debug prosthetic
            //

            AvatarSystem.LoadPlayer(UserType.Ablebodied, AvatarType.Transhumeral);
            AvatarSystem.LoadAvatar(SaveSystem.ActiveUser, AvatarType.Transhumeral);
            // 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");
            // Set the reference generator to linear synergy.
            elbowManager.ChangeReferenceGenerator("VAL_REFGEN_LINKINSYN");
        }
    }
    //private ISensor sensorDebug;

    public void OnEnable()
    {
        // Display available user sensors name.
        if (AvatarSystem.GetActiveSensors().Count > 0)
        {
            userSensorsTMP.text = "User Sensors: \n";
            foreach (ISensor sensor in AvatarSystem.GetActiveSensors())
            {
                userSensorsTMP.text = userSensorsTMP.text + sensor.GetSensorType().ToString() + "\n";
            }
        }

        // Display available experiment sensors name.
        if (ExperimentSystem.GetActiveSensors().Count > 0)
        {
            experimentSensorsTMP.text = "Experiment Sensors: \n";
            foreach (ISensor sensor in ExperimentSystem.GetActiveSensors())
            {
                experimentSensorsTMP.text = experimentSensorsTMP.text + sensor.GetSensorType().ToString() + "\n";
            }
        }
    }
    public void CreateUser()
    {
        // Check that all data has been set.
        if (dataSet < 13)
        {
            logManager.DisplayInformationOnLog(3.0f, "Not all user information has been set.");
        }
        else if (!userTypeSet)
        {
            logManager.DisplayInformationOnLog(3.0f, "Choose a valid user type.");
        }
        else
        {
            // Generate user ID
            //string userID = userData.name.ToCharArray()[0].ToString() + userData.familyName.ToCharArray()[0].ToString() + userData.yearOfBirth.ToString();
            //userData.id = userID;
            userData.GenerateUserID();

            // Create new user.
            try
            {
                SaveSystem.CreateNewUser(userData);

                // Create a all avatars.
                AvatarSystem.CreateAvatarCustomizationData(userData.id, AvatarType.AbleBodied, "ResidualLimbUpperDefault", "UpperSocketDefault", "ElbowCustom", "ForearmCustom", "ACESHand");
                AvatarSystem.CreateAvatarCustomizationData(userData.id, AvatarType.Transhumeral, "ResidualLimbUpperDefault", "UpperSocketDefault", "ElbowCustom", "ForearmCustom", "ACESHand");
                AvatarSystem.CreateAvatarCustomizationData(userData.id, AvatarType.Transradial, "ResidualLimbLowerDefault", "LowerSocketDefault", "ElbowCustom", "ForearmCustom", "ACESHand");

                // Return to main menu
                experimentMenu.GetComponent <MainMenu>().createdUser = true;
                ReturnToExperimentMenu();
            }
            catch (Exception e)
            {
                logManager.DisplayInformationOnLog(3.0f, 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>
    /// Handles when the sensor selection has been updated.
    /// </summary>
    /// <param name="selectedSensor"></param>
    public void UpdatedSelectedSensor(int selectedSensor)
    {
        this.selectedSensor = selectedSensor;
        ISensor sensor;

        // If selected a sensor extract it.
        if (selectedSensor > 0)
        {
            sensor = AvatarSystem.GetActiveSensors()[selectedSensor - 1];
        }
        else
        {
            // Deactivate all
            EMGWiFiConfig.SetActive(false);
            return;
        }

        // Select the sensor config menu.
        if (sensor.GetSensorType() == SensorType.EMGWiFi)
        {
            EMGWiFiConfig.SetActive(true);
            EMGWiFiConfig.GetComponent <ConfigEMGWiFi>().SetSensorToConfigure((EMGWiFiManager)sensor);
        }
    }