# MAVLink

## MAVLink

> *Micro Air Vehicle Communication Protocol. MAVLink or Micro Air Vehicle Link is a protocol for communicating with small unmanned vehicle. It is designed as a header-only message marshaling library. MAVLink was first released early 2009 by Lorenz Meier under LGPL license.* [Wikipedia](https://en.wikipedia.org/wiki/MAVLink)

* [Erle Robotics: MAV Tools](https://www.gitbook.com/book/erlerobotics/erle-robotics-mav-tools-free/details)

```bash
user@workstation:~/src/Firmware$ find . -name "mavlink"
./Tools/jMAVSim/out/production/jMAVSim/me/drton/jmavlib/mavlink
./Tools/jMAVSim/out/production/mavlink
./Tools/jMAVSim/mavlink
./Tools/jMAVSim/jMAVlib/src/me/drton/jmavlib/mavlink
./.git/modules/mavlink
./.git/modules/mavlink/include/mavlink
./build/posix_sitl_default/src/modules/mavlink
./mavlink
./mavlink/include/mavlink
./src/platforms/ros/nodes/mavlink
./src/modules/mavlink
user@workstation:~/src/Firmware$
```

## MAVLink :: DroneKit SITL

```bash
user@workstation:~$ dronekit-sitl copter --home=20.654544,-103.3930971,30,0
```

```bash
user@workstation:~$ sudo nmap -p 5700-5800 127.0.0.1

Starting Nmap 7.01 ( https://nmap.org ) at 2018-03-17 15:22 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000028s latency).
Not shown: 100 closed ports
PORT     STATE SERVICE
5760/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 1.51 seconds
user@workstation:~$
```

```bash
user@workstation:~/src/Firmware$ telnet 127.0.0.1 5760
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.



Init APM:Copter V3.3 (d6053245)

Free RAM: 4096
FW Ver: 120
----------------------------------------
```

## MAVLink :: JMAVSim

```bash
user@workstation:~$ cd src/Firmware/
user@workstation:~/src/Firmware$ 
user@workstation:~/src/Firmware$ make posix jmavsim
```

```bash
user@workstation:~/src/Firmware$ sudo nmap -sU -p 14500-14600 127.0.0.1
[sudo] password for user: 

Starting Nmap 7.01 ( https://nmap.org ) at 2018-03-17 15:28 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000067s latency).
Not shown: 97 closed ports
PORT      STATE         SERVICE
14550/udp open|filtered unknown
14556/udp open|filtered unknown
14557/udp open          unknown
14560/udp open|filtered unknown

Nmap done: 1 IP address (1 host up) scanned in 10.57 seconds
user@workstation:~/src/Firmware$
```

## MAVLink :: Ardupilot SITL

```bash
user@workstation:~$ cd src/ardupilot
user@workstation:~/src/ardupilot$ 
user@workstation:~/src/ardupilot$ sim_vehicle.py -v ArduCopter -l 20.654544,-103.3930971,30,0
```

```bash
SIM_VEHICLE: Run MavProxy
SIM_VEHICLE: "mavproxy.py" "--master" "tcp:127.0.0.1:5760" "--sitl" "127.0.0.1:5501" "--out" "127.0.0.1:14550" "--out" "127.0.0.1:14551"
```

```bash
user@workstation:~$ sudo nmap -p 5700-5800 127.0.0.1
[sudo] password for user: 

Starting Nmap 7.01 ( https://nmap.org ) at 2018-03-17 15:17 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000015s latency).
Not shown: 98 closed ports
PORT     STATE SERVICE
5760/tcp open  unknown
5762/tcp open  unknown
5763/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 1.41 seconds
user@workstation:~$
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://theiotlearninginitiative.gitbook.io/bitol/virtual-drone-solution/communication/mavlink.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
