---
# System prepended metadata

title: Nvidia Xavier NX connect to Pixhawk MavSDK Dronekit Mavlink
tags: [Jetson Xavier NX, Drone]

---

# Nvidia Xavier NX connect to Pixhawk MavSDK Dronekit Mavlink
###### tags: `Drone` `Jetson Xavier NX`
[TOC]



## Introduction
Nvidia Xavier NX 連接到 Pixhawk 的初始設定與安裝，首先要先開放連接埠，由於Jetpack系統與樹梅派等不一樣沒辦法直接簡單的從設定更改連接埠權限，所以需要透過==Minicom==工具幫助打開權限，再安裝任一可控制Pixhawk的工具如以下Mavlink、Pymavlink、MavSDK、Dronekit。


## Serial Access

```command
sudo apt-get install minicom
```

```command
sudo minicom
```

`Ctrl + A` :arrow_right: `Z`

Type `O` : configuration

Select `Serial device`.

change tty to ==ttyUSB0==.

* https://www.jetsonhacks.com/2017/03/24/serial-console-nvidia-jetson-tx2/

## Opencv
* [Opencv install with CUDA](https://hackmd.io/@willy541222/opencv_Jetson_Xavier_NX)

## Mavlink

```command
sudo apt-get install python3-dev python3-wxgtk4.0 python3-pip python3-matplotlib python3-lxml python3-pygame
pip3 install PyYAML mavproxy --user
echo "export PATH=$PATH:$HOME/.local/bin" >> ~/.bashrc
```

:::warning
Ignore the fail install pygame.
:::

### Test
```
python3 mavproxy.py --master=/dev/serial0 --baudrate 921600 --aircraft MyCopter
```

## pymavlink

```
sudo pip3 install pymavlink
```

## MavSDK-Python

```
pip3 install mavsdk
```

```python=
import asyncio
from mavsdk import System

...

drone = System()
await drone.connect(system_address="udp://:14540")
```

## Dronekit

```
sudo pip3 install dronekit
```

## Issue

1. Please make sure the libxml2 and libxslt development packages are installed.
```
sudo apt-get install libxslt-dev
```

2. /dev/ttyUSB0 permission denied.

The Solution is type the script below in terminal :arrow_down_small: 
```command
sudo chmod 777 /dev/ttyUSB0
```

* https://blog.csdn.net/w383117613/article/details/44216653

## Reference
* http://brisbaneroboticsclub.id.au/connect-nvidia-nano-to-pixhawk/
* https://ardupilot.org/mavproxy/docs/getting_started/download_and_installation.html#mavproxy-downloadinstalllinux
* https://www.jetsonhacks.com/2017/03/24/serial-console-nvidia-jetson-tx2/
* https://dronekit-python.readthedocs.io/en/latest/guide/connecting_vehicle.html
* https://mavsdk.mavlink.io/main/en/index.html
* https://github.com/mavlink/MAVSDK-Python
* https://github.com/ArduPilot/pymavlink