Skip to content

Commit

Permalink
Add documentation of the log playback feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
lovettchris committed Apr 11, 2017
1 parent b4fc26b commit 839d891
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/custom_drone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Custom Drone

Parts of the AirSim stack can be used on a real drone. For example, you can run the MavlinkCom library and MavLinkTest app to test the connection
between your `big brain` and `little brain`. For our testing we mounted a Gigabyte Brix BXi7-5500 ultra compact PC on the drone connected to the Pixhawk flight controller over USB. The Gigabyte PC is running Ubuntu, so we are able to SSH into it over Wifi:

![Flamewheel](images/Flamewheel.png)

Once connected you can run MavLinkTest with this command line:
````
MavLinkTest -serial:/dev/ttyACM0,115200 -logdir:.
````
And this will produce a log file of the flight which can then be used for [playback in the simulator](playback.md).

You can also add `-proxy:192.168.1.100:14550` to connect MavLinkTest to a remote computer where you can run QGroundControl or our
[PX4 Log Viewer](log_viewer.md) which is another handy way to see what is going on with your drone.

MavLinkTest then has some simple commands for testing your drone, here's a simple example of some commands:

````
arm
takeoff 5
orbit 10 2
````

This will arm the drone, takeoff ot 5 meters, then do an orbit pattern radius 10 meters, at 2 m/s.
Type '?' to find all available commands.

# DroneServer and DroneShell

One the MavLinkConnection is working, you can also run DroneServer and DroneShell to control the drone that way.


Binary file added docs/images/Flamewheel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Playback.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/RealFlight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/logs/recording.mavlink
Binary file not shown.
56 changes: 56 additions & 0 deletions docs/playback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Playback

AirSim supports playing back the high level commands in a *.mavlink log file that was recorded using the MavLinkTest app
for the purpose of comparing real and simulated flight.
The [recording.mavlink](logs/recording.mavlink) is an example of a log file captured using a real drone using the following
command line:

````
MavLinkTest -serial:/dev/ttyACM0,115200 -logdir:.
````

Then the log file contains the commands performed, which included several "orbit" commands, the resulting GPS map of the flight
looks like this:

![real flight](images/RealFlight.png)

## Side-by-side comparison

Now we can copy the *.mavlink log file recorded by MavLinkTest to the PC running the Unreal simulator with AirSim plugin.
When the Simulator is running and the drone is parked in a place in a map that has room to do the same maneuvers we can run this
MavLinkTest command line:

````
MavLinkTest -server:127.0.0.1:14550
````

This should connect to the simulator. Now you can enter this command:

````
PlayLog recording.mavlink
````
The same commands you performed on the real drone will now play again in the simulator. You can then press 't' to see
the trace, and it will show you the trace of the real drone and the simulated drone. Every time you press 't' again
you can reset the lines so they are sync'd to the current position, this way I was able to capture a side-by-side trace of the
"orbit" command performed in this recording, which shows this side-by-side comparision:

![playback](images/Playback.png)

Note: I'm using the ';' key in the simulator to take control of camera position using keyboard to get this shot.

## Parameters

It may help to set the simulator up with some of the same flight parameters that your real drone is using, for example,
in my case I was using a lower than normal cruise speed, slow takeoff speed, and it helps to tell the simulator to
wait a long time before disarming (COM_DISARM_LAND) and to turn off the safety switches NAV_RCL_ACT and NAV_DLL_ACT
(`don't` do that on a real drone).

````
param MPC_XY_CRUISE 2d
param MPC_XY_VEL_MAX 2
param MPC_TKO_SPEED 1
param COM_DISARM_LAND 60
param NAV_RCL_ACT 0
param NAV_DLL_ACT 0
````

0 comments on commit 839d891

Please sign in to comment.