Skip to content

Debugging

Marco A. Gutiérrez edited this page Jul 21, 2022 · 1 revision
  1. Run the original MBARI LRAUV command-line simulation
  2. Using Debug Container to debug the simulator
  3. Unserializing and plotting values

Run the original MBARI LRAUV command-line simulation

The original simulation (SimDaemon) is the baseline comparison for the Ignition simulation.

For developers, it helps to troubleshoot the Ignition simulation by comparing its values to the original MBARI simulation, which is a pure command-line interface.

Do not run both Ignition and SimDaemon at the same time. Choose only one.

cd ~/lrauv_ws/src/lrauv-application

In the MBARI code base, open Config/sim/Simulator.cfg, change these lines to look like this:

   ExternalSim.loadAtStartup = 1 bool;
   ExternalSimIgnition.loadAtStartup = 0 bool;

This enables the original ExternalSim and disables the interface with Ignition.

Run the original command-line simulation:

bin/SimDaemon

The SimDaemon runs in the background by default.

Then run the Main Vehicle Application as usual:

bin/LRAUV

Speed up 100 times for a bit to finish loading, before returning to normal speed. This allows the commands to finish loading, before you overwrite them with control commands. Otherwise the preloaded commands can kick in after you issue control commands and make the vehicle go to unexpected places

>quick on
>quick off

Alternatively, if you have access to the config files, set SBIT.loadAtStartup to 0 bool in Config/BIT.cfg. This might already be set for you in the Docker image on MBARI DockerHub.

Load the circle mission, which will perform two circles:

load Engineering/circle_test.xml

Set some parameters as desired:

set circle_test.Depth01 10 meter;set circle_test.Depth02 15 meter;set circle_test.RudderAngle01 15 degree;set circle_test.RudderAngle02 10 degree;set circle_test.WaitDuration 10 minute
run;quick off

You can check variables like depth:

report touch depth
quick on

To clear the report and go back to normal speed:

report clear
quick off

To stop the mission and terminate:

stop
quit

Using Debug Container to debug the simulator

A simple dockerfile and tmux config exists that makes launching and debugging the different components of the project a lot easier. To use it simply run

$ docker/debug_integration.sh

This will build a new container with the source code and launch a tmux session. The tmux session has 2 windows: 0:simulation and 1:logging. In the simulation window you will see the top pane runs the ignition simulation while the bottom pane runs the actual bin/LRAUV controller. The logging pane on the other hand will automatically convert the sim slate and write it to the results directory on your computer one layer above the directory to where you checked out.

tmux_debug

Unserializing and plotting values

On the MBARI Main Vehicle Application side, all values during the run are stored to disk. They can be retrieved after the run and plotted for debugging purposes:

  1. Install dependencies
$ pip3 install matplotlib numpy
  1. Compile the prerquesities

Compile the unserialized target if you haven't done so:

cd ~/lrauv_ws/src/lrauv-application
make unserialize
  1. Use it Every time a mission is run in the LRAUV application, it generates some log files in lrauv-application/Logs/. For example, run a mission:
$ bin/LRAUV
> run RegressionTests/IgnitionTests/testYoYoCircle.xml
  • Generate the CSV

    Use a script to unserialize the relevant variables and output a csv file:

    ./unserialize_for_plotting.sh
    

    By default, it unserializes lrauv-application/Logs/latest directory, which is a symbolic link to the log directory from the last run. The output goes 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 on the top of unserialize_for_plotting.sh.

  • Generate the plots

    Run a script to 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 on the top of unserialize_for_plotting.sh.