> For the complete documentation index, see [llms.txt](https://theiotlearninginitiative.gitbook.io/bitol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://theiotlearninginitiative.gitbook.io/bitol/virtual-drone-solution/uses-cases.md).

# Uses Cases

## Use Cases

* [Open Drone Map](http://opendronemap.org/)
* [Plot in Maps](https://github.com/vgm64/gmplot)
* [Transport Tracker Map](https://codelabs.developers.google.com/codelabs/transport-tracker-map/#0)
  * [1](https://github.com/googlemaps/transport-tracker)
* [Avoidance](https://github.com/xe1gyq/dronekit-python)
* [PubNub](https://www.pubnub.com/tutorials/javascript/mapping-javascript-tracking/#google-maps-api)
* [Temp](https://github.com/SpyGuyIan/DroneTrack/tree/bac7f12d6b5185a47a3ad183d8e2404dc97ce895)

Options

1. [Maps JavaScript API](https://developers.google.com/maps/documentation/javascript/tutorial)
2. [NYC Subway Station Locator](https://github.com/googlemaps/nyc-subway-station-locator)
3. [How Do Drpones Work](https://github.com/tizianofiorenzani/how_do_drones_work)

Steps

* Execution Environment
  * Docker
    * Ubuntu
      * sudo docker run -it xe1gyq/xardupilot "2" "20.6546009" "-103.3915602" "30"
      * 172.17.0.2:5762
      * python Telemetry.py --connect=tcp:172.17.0.2:5763
    * Alpine
      * <https://github.com/gmyoungblood-parc/docker-alpine-ardupilot/blob/master/Dockerfile>
  * Virtual Machine
    * bash Ardupilot.sh
    * 172.24.4.3:5762
    * python Telemetry.py --connect=tcp:172.24.4.3:5763
    * 10.0.0.6 Floating IPs: 172.24.4.3
* Autopilot
  * DroneKit SITL
    * MavProxy&#x20;
  * Ardupilot SITL
    * export PATH=$PATH:$HOME/ardupilot/Tools/autotest
    * export PATH=/usr/lib/ccache:$PATH
    * sim\_vehicle.py -v ArduCopter -l 20.6546009,-103.3915602,30,0
    * ToDo
      * Add Ardupilot Start Point
* Implementation Details Each UAV
  * Vehicle ID
    * PX4 SYSID\_THISMAV
    * Ardupilot MAV\_SYS\_ID
    * Obtain, Assign, Modify, Report Back
      * param show SYSID\_THISMAV
      * param set SYSID\_THISMAV 2
  * Ports
    * Internals 14550 14551
    * Assign
* Map
  * MapMoveDemo
* Missions
  * GoTo.py
    * python GoTo.py --connect="127.0.0.1:14551" --lat=20.6546009 --long=-103.3915602 --alt=10
  * Telemetry.py
    * python Telemetry.py --connect="127.0.0.1:14551" --id=2
  * Network
    * <https://docs.docker.com/network/>
  * Arguments
    * FROM ubuntu
    * ARG CONT\_IMG\_VER
    * ENV CONT\_IMG\_VER v1.0.0
    * RUN echo $CONT\_IMG\_VER
    * docker build --build-arg CONT\_IMG\_VER=v2.0.1 .
    * <http://goinbigdata.com/docker-run-vs-cmd-vs-entrypoint/>
    * <https://www.ctl.io/developers/blog/post/dockerfile-entrypoint-vs-cmd/>
  * Volume
    * sudo docker cp b91d2d9c892b:/home/user/ardupilot ardupilot
    * [Volume Logs](http://crosbymichael.com/advanced-docker-volumes.html)
  * Webpage
    * TomCat Alpine

## Demo

> Containers should do one thing and do that well.

* Setup
  * cd Bitol/VirtualDroneSolution/UseCases/XunanKab/Ardupilot
  * sudo docker build -t xe1gyq/ardupilot .
  * sudo docker ps -a
  * sudo docker commit -m "Ardupilot" -a "Abraham Arce" c398fc22eeba xe1gyq/ardupilot
* Unnmaned Aerial vehicle
  * ip addr
  * run
    * sudo docker run -it xe1gyq/xardupilot "2" "20.6546009" "-103.3915602" "30"
    * sudo docker run -it -v ardupilot:/home/user/ardupilot xe1gyq/ardupilot bash
      * 172.17.0.2/16
        * export PATH=$PATH:$HOME/ardupilot/Tools/autotest
        * export PATH=/usr/lib/ccache:$PATH
        * sim\_vehicle.py -v ArduCopter -l 20.6546009,-103.3915602,30,0
      * 172.17.0.3/16
        * export PATH=$PATH:$HOME/ardupilot/Tools/autotest
        * export PATH=/usr/lib/ccache:$PATH
        * sim\_vehicle.py -v ArduCopter -l 20.6546009,-103.3915602,30,0
    * sudo docker run -it -p 14550:15001 -p 14551:16001 -v ardupilot:/home/user/ardupilot xe1gyq/ardupilot bash
* Ground Control Station
  * ./QGroundControl.AppImage
    * 172.17.0.2:5762
* Developer API
  * python Telemetry.py --connect=tcp:172.17.0.2:5763

```bash
sudo docker run -it xe1gyq/xardupilot "2" "20.6546009" "-103.3915602" "5"
sudo docker run -it xe1gyq/xardupilot "3" "20.6546030" "-103.3915603" "10"
sudo docker run -it xe1gyq/xardupilot "4" "20.6546009" "-103.3915602" "10"
python Telemetry.py --connect=tcp:172.17.0.2:5763
python GoTo.py --connect=tcp:172.17.0.2:5763 --lat=20.6595009 --long=-103.3964602 --alt=5
python Triangle.py --connect=tcp:172.17.0.2:5763
python Square.py --connect=tcp:172.17.0.2:5763
```

* [1](https://forums.docker.com/t/how-to-expose-port-on-running-container/3252/8)

## One

```bash
user@workstation:~/Bitol/VirtualDroneSolution/UseCases/XunanKab/One$ sudo apt install npm
user@workstation:~/Bitol/VirtualDroneSolution/UseCases/XunanKab/One$ npm install csv-parse/home/user/Bitol/VirtualDroneSolution/UseCases/XunanKab/One
└── csv-parse@2.1.0 

npm WARN enoent ENOENT: no such file or directory, open '/home/user/Bitol/VirtualDroneSolution/UseCases/XunanKab/One/package.json'
npm WARN One No description
npm WARN One No repository field.
npm WARN One No README data
npm WARN One No license field.
user@workstation:~/Bitol/VirtualDroneSolution/UseCases/XunanKab/One$
```

```bash
user@workstation:~$ cd Bitol/VirtualDroneSolution/UseCases/XunanKab
user@workstation:~/Bitol/VirtualDroneSolution/UseCases/XunanKab$ ls
Dockerfile
user@workstation:~/Bitol/VirtualDroneSolution/UseCases/XunanKab$
```

```bash
user@workstation:~/Bitol/VirtualDroneSolution/UseCases/XunanKab$ sudo docker build -t xe1gyq/xunankab .
```

```bash
user@workstation:~/Bitol/VirtualDroneSolution/UseCases/XunanKab$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
xe1gyq/xunankab     latest              3f38626133a0        2 minutes ago       692MB
ubuntu              16.04               f975c5035748        3 weeks ago         112MB
user@workstation:~/Bitol/VirtualDroneSolution/UseCases/XunanKab$
```

```bash
user@workstation:~/Bitol/VirtualDroneSolution/UseCases/XunanKab$ sudo docker run -it xe1gyq/xunankab bash
user@6440be9e8eaa:~$
```

```bash
^Cuser@6440be9e8eaa:~$ ip addr 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
130: eth0@if131: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
       valid_lft forever preferred_lft forever
user@6440be9e8eaa:~$
```

```bash
user@6440be9e8eaa:~$ dronekit-sitl --list
solo-1.2.0
solo-2.0.18
solo-2.0.20
plane-3.3.0
copter-3.3
rover-2.50
user@6440be9e8eaa:~$ dronekit-sitl copter --home=20.654544,-103.3930971,30,0 --instance 0
os: linux, apm: copter, release: stable
Downloading SITL from http://dronekit-assets.s3.amazonaws.com/sitl/copter/sitl-linux-copter-3.3.tar.gz
Download Complete.
Payload Extracted.
Ready to boot.
Execute: /home/user/.dronekit/sitl/copter-3.3/apm --home=20.654544,-103.3930971,30,0 --instance 0 --model=quad
Started model quad at 20.654544,-103.3930971,30,0 at speed 1.0
bind port 5760 for 0
Starting sketch 'ArduCopter'
Serial port 0 on TCP port 5760
Starting SITL input
Waiting for connection ....
```

## DJI Tello

```
user@workstation:~/TelloPy$ git clone https://github.com/hanyazou/TelloPy 
user@workstation:~/TelloPy$ sudo sudo apt-get install -y     libavformat-dev libavcodec-dev libavdevice-dev     libavutil-dev libswscale-dev libavresample-dev
user@workstation:~/TelloPy$ sudo pip install av
```

<https://mikeboers.github.io/PyAV/installation.html>

##
