Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,46 @@ When you load the MAVCesium module a single [tornado server](http://www.tornadow

The display is updated only as new data is received via the telemetry stream, so the faster the telemetry stream the 'smoother' the display update will be.

### Getting it running
### Getting it running (through MAVProxy's module loader)

*The following assumes that you have already installed the requirements for MAVProxy*

* Install the python dependencies for MAVCesium located in [requirements.txt](https://github.com/SamuelDudley/MAVCesium/blob/master/requirements.txt) via pip

* MAVCesium is avalable as a git submodule of [MAVProxy](https://github.com/ArduPilot/MAVProxy). If you already have an existing [MAVProxy](https://github.com/ArduPilot/MAVProxy) repository setup, you can initialise the MAVCesium module by running the following in your MAVProxy base directory:
```
git submodule init
git submodule update
git submodule update --init --recursive
```

**Otherwise** if you would like to clone MAVProxy and get the MAVCesium module at the same time you can run the following command:
```
git clone --recursive https://github.com/ArduPilot/MAVProxy.git
git clone --recurse-submodules https://github.com/ArduPilot/MAVProxy.git
```
You can then install MAVProxy as per the [developer guide](http://ardupilot.github.io/MAVProxy/html/development/index.html):
```
cd MAVProxy
python setup.py build install --user
```

* Run [MAVProxy](https://github.com/ArduPilot/MAVProxy) and load the MAVCesium module with the `module load cesium` command in the MAVProxy console
* Point your webgl enabled browser to http://127.0.0.1:5000/mavcesium/ and once you start receiving valid mavlink messages from the vehicle connected to the MAVProxy ground station you will see the vehicle model in the center of your screen with a HUD overlay

* If you have other computers / tablets / ipads on your network you can also open webgl capable browsers on them and point it to the network facing IP address of the computer that MAVProxy is running on.
* For bonus points replace the [Griffon Aerospace MQM-170 Outlaw gltf model](https://github.com/SamuelDudley/MAVCesium/blob/master/mavproxy_cesium/app/static/DST/models/rat.gltf) with something that resembles your air vehicle! You can convert .dae models to .gltf using [this](https://cesiumjs.org/convertmodel.html) online tool
### Getting it running (standalone)

You can also run it standalone.

In ArduPilot, run SITL.
```bash
./Tools/autotest/sim_vehicle.py -v Plane
```

Then, start the cesium_web_server.

```bash
cd app
python3 cesium_web_server.py
```

Each time you change code, you must kill the Tornado server, restart it, and refresh the web page.


### Module usage
The top bar of the MAVCesium display contains similar data to the MAVProxy map. Here you will find the cursor lat, lon, alt and information on left click positions.
Expand Down
35 changes: 30 additions & 5 deletions app/cesium_web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@
lock = threading.Lock()
live_web_sockets = set()

signal_received = False

# Importing from system packages first can override the use of locally edited code.
try: # try to use pkg_resources to allow for zipped python eggs
import pkg_resources
APP_ROOT = pkg_resources.resource_filename('MAVProxy.modules.mavproxy_cesium','app')
APP_STATIC = pkg_resources.resource_filename('MAVProxy.modules.mavproxy_cesium.app','static')
APP_TEMPLATES = pkg_resources.resource_filename('MAVProxy.modules.mavproxy_cesium.app','templates')
raise Exception("Don't use this")
except: # otherwise fall back to the standard file system
APP_ROOT = os.path.dirname(os.path.abspath(__file__))
APP_STATIC = os.path.join(APP_ROOT, 'static')
Expand Down Expand Up @@ -103,7 +107,7 @@ def start_app(config, module_callback):
server = tornado.httpserver.HTTPServer(application)
server.listen(port = int(config.SERVER_PORT), address = str(config.SERVER_INTERFACE))
if config.APP_DEBUG:
print("Starting Tornado server: {0}".format(config.SERVER_INTERFACE+":"+config.SERVER_PORT+"/"+config.APP_PREFIX))
print("Starting Tornado server: http://{0}".format(config.SERVER_INTERFACE+":"+config.SERVER_PORT+"/"+config.APP_PREFIX))
return server

def close_all_websockets():
Expand All @@ -114,14 +118,35 @@ def close_all_websockets():
for ws in removable:
live_web_sockets.remove(ws)
lock.release()

def stop_tornado(config):
close_all_websockets()
ioloop = tornado.ioloop.IOLoop.current()
ioloop.add_callback(ioloop.stop)

if config.APP_DEBUG:
print("Asked Tornado to exit")

# Tornado doesn't stop well with the current architecture.
# Try this approach so we don't have to result to sigterm in CLI.
# https://github.com/tornadoweb/tornado/issues/1791#issuecomment-238214198

ioloop = tornado.ioloop.IOLoop.instance()
def register_signal(sig, frame):
global signal_received
print("%s received, stopping server" % sig)
close_all_websockets()
ioloop.add_callback(ioloop.stop)
signal_received = True

def stop_on_signal():
global signal_received
if signal_received and not ioloop._callbacks:
ioloop.stop()
print("IOLoop stopped")

tornado.ioloop.PeriodicCallback(stop_on_signal, 1000).start()
signal.signal(signal.SIGTERM, register_signal)
logging.info("Starting server")
ioloop.start()

def websocket_send_message(message):
removable = set()
lock.acquire()
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<TileMap version="1.0.0" tilemapservice="http://tms.osgeo.org/1.0.0">
<Title>NE2_HR_LC_SR_W_DR_recolored.tif</Title>
<Abstract></Abstract>
<SRS>EPSG:4326</SRS>
<BoundingBox miny="-90.00000000000000" minx="-180.00000000000000" maxy="90.00000000000000" maxx="180.00000000000000"/>
<Origin y="-90.00000000000000" x="-180.00000000000000"/>
<TileFormat width="256" height="256" mime-type="image/jpg" extension="jpg"/>
<TileSets profile="geodetic">
<TileSet href="0" units-per-pixel="0.70312500000000" order="0"/>
<TileSet href="1" units-per-pixel="0.35156250000000" order="1"/>
<TileSet href="2" units-per-pixel="0.17578125000000" order="2"/>
</TileSets>
</TileMap>
<?xml version="1.0" encoding="utf-8"?>
<TileMap version="1.0.0" tilemapservice="http://tms.osgeo.org/1.0.0">
<Title>NE2_HR_LC_SR_W_DR_recolored.tif</Title>
<Abstract></Abstract>
<SRS>EPSG:4326</SRS>
<BoundingBox miny="-90.00000000000000" minx="-180.00000000000000" maxy="90.00000000000000" maxx="180.00000000000000"/>
<Origin y="-90.00000000000000" x="-180.00000000000000"/>
<TileFormat width="256" height="256" mime-type="image/jpg" extension="jpg"/>
<TileSets profile="geodetic">
<TileSet href="0" units-per-pixel="0.70312500000000" order="0"/>
<TileSet href="1" units-per-pixel="0.35156250000000" order="1"/>
<TileSet href="2" units-per-pixel="0.17578125000000" order="2"/>
</TileSets>
</TileMap>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Loading