# Plotting tools for validation

## Pre-requisites

Install Python dependencies:

```sh
$ pip3 install matplotlib numpy
```

Compile the `unserialized` target:

```sh
cd ~/lrauv_ws/src/lrauv-application
make unserialize
```

**Note**: this is taken care of in most Docker containers automatically.

## Usage

1. Run a mission

    Every time you run a mission with the LRAUV application, it generates
    some log files in `lrauv-application/Logs/`. For example:

    ```sh
    $ bin/LRAUV
    > run RegressionTests/GazeboTests/testYoYoCircle.xml
    ```

1. Generate CSV

    Unserialize the relevant variables and output a CSV file:

    ```sh
    ./unserialize_for_plotting.sh
    ```

    By default, it unserializes the `lrauv-application/Logs/latest` directory, which
    is a symbolic link to the log directory from the last run. The output will go
    to `./missions/tmp/tmp.csv`.

    To specify a different input log directory and a different output directory,
    you can pass in the specific log directory under `lrauv-application/Logs/`
    and the mission name, like so:

    ```
    ./unserialize_for_plotting.sh 20210811T002224 testYoYoCircle
    ```

    The unserialized output will go to `./missions/<missionName>`.

    See more information at the top of `unserialize_for_plotting.sh`.

1. Generate plots

    Plot the relevant variables in appropriate subplots:

    ```
    python3 plot_missions.py <mission_name> <tmp>
    ```

    Where `<mission_name>` is the name of the mission, and `<tmp>` is the `tmp`
    string, which if present, will plot values from `missions/tmp/tmp.csv`.

    See more information at the top of `unserialize_for_plotting.sh`.
