# LokomatControl
A collection of the control files used for the LokoFree target PC (controlling the Orthosis, and BWS) of the [Lokomat](https://hri-wiki.tudelft.nl/en/lokomat).
## How to use
To build and run this model on the LokoFree pc, perform the following steps:
**building**
1. Open ForceControl Model
2. run `setup/init.m`, to initialize all parameters.
> Note: this auto-navigates the working directory to the build folder
3. Click Build Model.
**running**
1. Make sure the LokoFree is enabled and connected to the network.
> FOLLOWING STEPS ON HOW TO RUN
## Folder Structure
- `bootconfig/`: a script you run to configure and create the boot file for the target PCs (to put on a bootable usb, see also [here](https://hri-wiki.tudelft.nl/en/lokomat/usb-xpc)).
- `build/`: build into this folder. These files will/should not be synced to git. (to prevent build files cluttering the workspace).
- `models/`: contains the simulink models for the LokoFree pc.
- `ForceControl/`: Force Control Simulink Models. For more info, see [here](https://hri-wiki.tudelft.nl/en/lokomat/models/force-control).
- `PositionControl/`: (Older) Position Control models.
- `scripts/`: All scripts used for debugging and other random purposes.
- `setup/`: this folder contains all the libraries and setup scripts needed to compile and run a model.
- `lowpassDiscrete.mdl`: submodel to do some filtering. TODO: Figure out if we need this or if we can just use some built-in block.
- `data/`: TODO: Add description for these files
> Note: This folder should always be sourced. (TODO: There is some pre-build command thing somewhere, don't remember where.)
- `utility/`: smaller testing models and submodels with more general usage.
- `XML`: Contains the ENI and ESI files for the EtherCAT setup. See also [here](https://hri-wiki.tudelft.nl/en/ethercat).
## Setup scripts
- `init.m`: Sets the sampling time (`Ts`) & runs several other scripts and creates a lot of variables to initialize the workspace for the LokoFree model. Then, it navigates to the build folder.
- `import_parameters.m`: Import calibration parameters (gains, offsets, filter parameters, & Scope parameters)
- `import_kalman_parameters.m`: Parameters related to the Kalman filter (camera offsets, sampling rates, led parameters, imu gain)
- `create2targets.m`: creates instances of the two target PC's in the Matlab workspace (*tgfree* and *tgbasis*)
# Experiment Data
The data for this project are collected and organized using [UXF](https://immersivecognition.com/unity-experiment-framework/).
## How to use
Simply extract the data and run the DataProcessing.Rmd R markdown script in R Studio. This should download all the dependencies and run the code. Rmd script is a markdown codebook which contains further information regarding the dataprocessing steps itself.
## Folder structure
The folder structure is as follows:
- `/<Participant ID>`: All data for a single participant
- `/<Session ID>`: (Used to split the experimental conditions)
- `/session_info`: The general data
- `log.csv`: The console log of the Unity instance (unused in this experiment)
- `participant_details.csv`: Demographics gathered at the start of the experiment (unused in this experiment)
- `settings.json`: The (UXF) settings file used for the experiment (unused in this experiment)
- `/trackers`: All tracker data
- `camera_movement_T001.csv`: Tracked position of the HMD (to which the player camera was attached)
- `controller_(left)_movement_T001.csv`: Tracked position of the left controller (held by the participant)
- `controller_(right)_movement_T001.csv`: Tracked position of the right controller (held by the participant)
- `hip_movement_T001.csv`: Tracked position of the hip tracker (attached to the participant)
- `left_foot_movement_T001.csv`: Tracked position of the left foot tracker (attached to the participant)
- `right_foot_movement_T001.csv`: Tracked position of the right foot tracker (attached to the participant)
- `trial_results.csv`: Not used in this experiment
- `questionnaires.xlsx`: All questionnaire data.
- `targetlocations.csv`: The locations of the targets in the Unity scene
## Data dictionary
In the datasets, the following variable names have been used:
- `time`: Timestamp of the recorded row in seconds
- `pos_x`: The x position in meters
- `pos_y`: The y position in meters
- `pos_z`: The z position in meters
- `rot_x`: The x (Euler) rotation in degrees
- `rot_y`: The y (Euler) rotation in degrees
- `rot_z`: The z (Euler) rotation in degrees