English-language article on connecting a copter using a 4g network (#200)

* docs: Add en version about 4g

* docs/4g: proofreading (en)

Co-authored-by: Alexey Rogachevskiy <sfalexrog@gmail.com>
This commit is contained in:
Alamoris
2020-01-12 16:32:15 +03:00
committed by GitHub
parent 49b436b505
commit 20a29c3dd6
3 changed files with 136 additions and 0 deletions

133
docs/en/4g.md Normal file
View File

@@ -0,0 +1,133 @@
# Multi-copter control with 4G communication
The fourth generation mobile communication is a convenient tool for transmitting and receiving information at high speed. Nowadays, the coverage area of mobile operators allows to connect to the Internet at high speed from almost any point.
> **Hint** To transfer any data from your drone to the ground control station (e.g., QGroundControl) and back, you need to set up your own VPN network.
## Connecting Raspberry Pi to the VPN
Connect a 4G modem with SIM card to the USB port of your Raspberry Pi.
> **Hint** We suggest using the UDP transfer protocol to control the drone, which provides less delay, at the cost of no guarantee of receiving the package, which is very important during the flight.
Create the VPN network keys to connect Raspberry Pi and the ground station.
To connect Raspberry Pi to your network, install the *openvpn* package:
```bash
sudo apt-get install openvpn
```
Move your keys to the */etc/openvpn/client* directory. For convenience, use the graphical SFTP data transfer interface, for example: WinSCP, FileZilla, etc.
To enable the client mode, you must activate the keys you have transmitted. Keys can be generated in various formats, for example: *.ovpn*, *.conf*. The key or configuration used on your copter should be strictly in *.conf* format.
Initialize the service that uses your keys to connect in client mode:
```bash
sudo systemctl enable openvpn-client@config-name
```
where *config-name* is the name of your configuration file.
If everything is done correctly, every time the system restarts, the service client will automatically connect to your network.
> **Hint** Before starting work, do not forget to set up and enable VPN connection on your PC.
## Copter control via QGroundControl
Make sure your copter and ground station are connected to your network.
To do this, you can use the command `ip addr`. The result will be a numbered list of the active networks enabled on your device. Note the connection with the prefix *tun* and the IP address you specify; if it is present in your list, your copter is connected to the network.
Set up the GCS connection to your drone using the same protocol that is used for your VPN network. The steps are the same as in the [Wi-Fi connection article](gcs_bridge.md). We recommend using *UDP* due to lower latency.
If you have a connection to your drone, connect some joystick to your PC. You may use an RC transmitter with a USB port, such as FlySky-i6X, Taranis x7, etc., as well as any analog joystick that is recognized by the system.
When the joystick is recognized by the system, the *Joystick* item will appear in the *Vehicle Setup* column. If it is highlighted in red, then calibration is required.
To calibrate the joystick, press the *Calibrate* button in the *Joystick* tab and follow the instructions for the sticks position on the left side of the window.
<div class="image-group">
<img src="../assets/4g/calibrate.png" width=300 class="zoom border">
<img src="../assets/4g/calibration_instruction.png" width=300 class="zoom border">
</div>
After successful calibration, flight modes must be set up. To do this, switch the required toggle switches several times. During switching, you will see the virtual channels on which the toggle switches operate. One of the channels will be highlighted in the active position.
<img src="../assets/4g/fly_modes.png" width=300 class="zoom center border">
> **Info** When selecting the joystick, check the number of working channels and its support in QGroundControl (which uses SDL2, so any joystick supported there should be fine). There are joysticks that support only 4 channels, which are not convenient for this type of control.
If changes to stick positions are reflected in the QGroundControl window, all you have to do is apply a parameter that specifies that the drone is controlled by the joystick, not by the RC:
`COM_RC_IN_MODE` - Joystick/No RC Checks
Since mobile communication is not always stable, it is recommended to increase the timeout for control signal loss to 5 seconds.
<img src="../assets/4g/failsafe.png" width=300 class="zoom center border">
The drone is ready to fly!
> **Hint** If the copter does not arm when you move the left stick to the bottom right corner, set the Arm/Disarm command to one of the switches.
## Streaming video from the camera to QGroundControl
You can stream video from almost any camera connected to your Raspberry Pi. You will need to install or [build](https://github.com/sfalexrog/gst-rtsp-launch) the *gst-rtsp-launch* package:
```bash
sudo apt-get install gst-rtsp-launch
```
To start the transfer of images, you must enter the appropriate command line:
<a id="command_line"></a>
```bash
gst-rtsp-launch "( v4l2src device=/dev/video0 ! video/x-raw,framerate=30/1,width=320,height=240 ! v4l2h264enc output-io-mode=4 extra-controls=\"encode,frame_level_rate_control_enable=1,h264_profile=4,h264_level=13,video_bitrate=300000,h264_i_frame_period=5;\" ! rtph264pay name=pay0 pt=96 )"
```
This command line contains the parameters of the video stream, such as the source video device, framerate, image height/width, encoding, etc. You can see more examples [in the `gst-rtsp-launch` repository](https://github.com/sfalexrog/gst-rtsp-launch/blob/master/README.md).
Make sure the stream is received and shown in QGroundControl.
<img src="../assets/4g/video_stream.png" width=300 class="zoom center border">
## Starting video stream automatically
Create a file and add your video stream [command line](#command_line):
```bash
nano script_name.sh
```
In order to run the file, you have to mark it as executable.
```bash
chmod a+x script_name.sh
```
You can use systemd to launch this script every time on system startup. Create the *qgc_video.service* file in the */etc/systemd/system* directory:
```bash
sudo nano /etc/systemd/system/qgc_video.service
```
Put the following in this file:
```
[Unit]
Description=VideoStream
[Service]
ExecStart=/bin/bash /home/pi/script_name.sh
[Install]
WantedBy=multi-user.target
```
Enable the script at startup.
```bash
sudo systemctl enable qgc_video.service
```

View File

@@ -51,6 +51,7 @@
* [PID Setup](calibratePID.md)
* [Model files for parts](models.md)
* [ROS Melodic installation](ros-install.md)
* [Quadcopter control with 4G communication](4g.md)
* [Clever and Jetson Nano](jetson_nano.md)
* [Remote control app](rc.md)
* [Wi-Fi Configuration](network.md)

View File

@@ -8,6 +8,8 @@
Подключите 4G модем с сим-картой в USB порт вашей Raspberry Pi.
Обратите внимание, что при подключении, модем должен распознаваться в системе как сетевая карта, без каких либо дополнительных настроек.
> **Hint** Для управления коптером предлагается использовать UDP протокол передачи, обеспечивающий меньшую задержку, ценой отсутствия гарантии получения пакета, что очень важно во время пилотирования коптера.
Сформируйте необходимые ключи VPN сети, для подключения Raspberry Pi и наземной станции.