docs: update en

This commit is contained in:
Oleg Kalachev
2019-05-13 07:07:36 +03:00
parent 81c3d6d42b
commit 66e21443a9
9 changed files with 1156 additions and 0 deletions

View File

@@ -43,12 +43,15 @@
* [Working with a LED strip on Raspberry 3](leds.md)
* [Using rviz and rqt](rviz.md)
* [Working with the ultrasonic distance gage](sonar.md)
* [Working with a laser rangefinder](laser.md)
* [PX4 Simulation](sitl.md)
* [Software autorun](autolaunch.md)
* [Controlling the copter from Arduino](arduino.md)
* [Using an external 3G modem](3g.md)
* Clever-based projects
* [Copter spheric guard](shield.md)
* [Face recognition system](face_recognition.md)
* [An Android transmitter](android.md)
* [Copter Hack 2018](copterhack2018.md)
* [Copter Hack 2017](copterhack2017.md)
* Supplementary materials
@@ -56,5 +59,7 @@
* [Flashing ESCs using BLHeliSuite](esc_firmware.md)
* [MAVLink](mavlink.md)
* [PX4 Logs and Topics](flight_logs.md)
* [Camera calibration](calibration.md)
* [Working with IR sensors on Raspberry Pi 3](ir_sensors.md)
* Textbook
* [Theory and Videos](lessons.md)

141
docs/en/android.md Normal file
View File

@@ -0,0 +1,141 @@
# An Android transmitter
As early as in the frosty January 2018, all owners of Apple mobile devices got a nice Wi-Fi piloting app for iOS. And now, a year later, such an application is available for another operating system. The latest version may be downloaded [**here**](https://vk.com/away.php?to=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dexpress.copter.cleverrc&cc_key=).
## Introduction
In this article, I will tell you how to write your own or modify an existing transmitter for Android yourself. We will use the popular language *Kotlin*, and we will use *Android Studio* for an IDE. For those who never used it, I recommend reading the following [*materials*](https://www.google.com/search?ei=xQxDXMH0C8OOmgW4mYigDQ&q=%D0%A7%D1%82%D0%BE+%D0%B4%D0%B5%D0%BB%D0%B0%D1%82%D1%8C+%D0%B5%D1%81%D0%BB%D0%B8+%D1%8F+%D0%BD%D0%B5+%D1%83%D0%BC%D0%B5%D1%8E+%D0%BF%D0%B8%D1%81%D0%B0%D1%82%D1%8C+%D0%BF%D0%BE%D0%B4+%D0%B0%D0%BD%D0%B4%D1%80%D0%BE%D0%B8%D0%B4%3F&oq=%D0%A7%D1%82%D0%BE+%D0%B4%D0%B5%D0%BB%D0%B0%D1%82%D1%8C+%D0%B5%D1%81%D0%BB%D0%B8+%D1%8F+%D0%BD%D0%B5+%D1%83%D0%BC%D0%B5%D1%8E+%D0%BF%D0%B8%D1%81%D0%B0%D1%82%D1%8C+%D0%BF%D0%BE%D0%B4+%D0%B0%D0%BD%D0%B4%D1%80%D0%BE%D0%B8%D0%B4%3F&gs_l=psy-ab.3...4413.17423..17726...9.0..2.442.4577.45j5j1j0j1....2..0....1..gws-wiz.....6..0i71j35i39j0i131j0j0i67j0i131i67j0i22i30j33i22i29i30j33i21j33i160.0bZz-WGxoHY). The entire application code can be found [**here**](https://github.com/Tennessium/android). If you want to immediately get an app to further tuning, run the following command:
```Bash
git clone https://github.com/Tennessium/android
```
However, to make you fully understand the application, I will tell you about each stage of the project, as if you were building it from scratch.
## Wrapper
Let's start with the simplest thing — the appearance of our application. At [**GitHub**](https://github.com/CopterExpress/clever/tree/master/apps/android/app/src/main/assets), you can find *HTML*, *CSS* and *JavaScript* files, which make up the web page to be used for controlling the copter. To have this page displayed in our application, do the following:
1. Create folder **assets** in the main folder of the app named **app**
2. Add to it all files from [here](https://github.com/CopterExpress/clever/tree/master/apps/android/app/src/main/assets)
If you reached this stage, you already have the web page you want, congratulations! Now we have to display it somehow in the app. To do this, in class *activity* in method **onCreate**, write the following code:
```Kotlin
main_web.loadUrl("file:///android_asset/index.html")
```
Where *main_web* is the ID of your *WebView*, which is in the *xml* file of the *activity* selected by you.
Unfortunately, the quadcopter transmitter requires the entire screen of the device, while the interface elements of the system interfere with full-fledged use of the program. For this purpose, at the beginning of method **onCreate**, call the following function:
```Kotlin
private fun fullScreenCall() {
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
if (Build.VERSION.SDK_INT < 19) {
val v = this.window.decorView
v.systemUiVisibility = View.GONE
} else {
//for higher API versions.
val decorView = window.decorView
val uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
decorView.systemUiVisibility = uiOptions
}
}
```
This feature allows getting rid of the system interface elements. Let's go ahead.
This is how the transmitter looks at this stage:
<img src="../assets/IMG_4397.PNG" width="50%">
If you run your application, you will see that the sticks are not functioning. This is due to the fact that *JavaScript* is disabled in our page. To enable it, write the following code:
```Kotlin
main_web.settings.apply {
domStorageEnabled = true
javaScriptEnabled = true
loadWithOverviewMode = true
useWideViewPort = true
setSupportZoom(false)
}
```
This piece of code allows the page to use *JavaScript* and at the same time prepares for the next stage - **logics**.
## Receiving data from the web page
To let your phone receive data from the *HTML page*, create a class for interacting with the web interface
```Kotlin
class WebAppInterface(c: Context) {
@JavascriptInterface
public fun postMessage(message: String) {
val data = JSONObject(message)
send("255.255.255.255", 35602, pack(
data.getInt("x").toShort(),
data.getInt("y").toShort(),
data.getInt("z").toShort(),
data.getInt("r").toShort()))
}
}
```
This class will receive messages from the web page sent by the *postMessage* where argument *message* is the message from the page.
Now we have to link classes **WebAppInterface** and **MainActivity**. For this you have to add just one line to method **onCreate**:
```Kotlin
main_web.addJavascriptInterface(WebAppInterface(this), "appInterface")
```
## Sending data to the copter
**Important!**
For working in Internet in the *Android* platform, add the following line to tag *manifest* in file **AndroidManifest.xml**:
```XML
<uses-permission android:name="android.permission.INTERNET"/>
```
It will grant your application access to the Internet, and the ability to send data via **Wi-Fi**. And you will now learn how to do that. Let's go ahead.
You have probably noticed function *send* in class **WebAppInterface**. It is this function that sends data to the copter. Let's declare it **outside classes**:
```Kotlin
fun send(host: String, port: Int, data: ByteArray, senderPort: Int = 0): Boolean {
var ret = false
var socket: DatagramSocket? = null
try {
socket = DatagramSocket(senderPort)
val address = InetAddress.getByName(host)
val packet = DatagramPacket(data, data.size, address, port)
socket.send(packet)
ret = true
} catch (e: Exception) {
e.printStackTrace()
} finally {
socket?.close()
}
return ret
}
```
This function sends data via the [*user datagram protocol*](https://www.google.com/search?q=udp+%D0%BF%D1%80%D0%BE%D1%82%D0%BE%D0%BA%D0%BE%D0%BB&oq=udp+&aqs=chrome.0.69i59j69i57j35i39j0l3.1434j1j7&sourceid=chrome&ie=UTF-8) to the copter. The program sends **bytes**, so it would be a good idea to declare the function for creating an array of **bytes** from four variables:
```Kotlin
fun pack(x: Short, y: Short, z: Short, r: Short): ByteArray {
val pump_on_buf: ByteBuffer = ByteBuffer.allocate(8)
pump_on_buf.putShort(r)
pump_on_buf.putShort(z)
pump_on_buf.putShort(y)
pump_on_buf.putShort(x)
return pump_on_buf.array().reversedArray()
}
```
## Summary
Now your app has the full functionality of its analog for **iOS**. You can customize it as you wish. For any questions about the app, contact us in Telegram @Tenessinum.

228
docs/en/calibration.md Normal file
View File

@@ -0,0 +1,228 @@
# Camera calibration
Computer vision is becoming more and more widespread. Often, computer vision algorithms are not precise and obtain distorted images from the camera, which is especially true for fisheye cameras.
![img](../assets/img1.jpg)
> The image is "rounded" closer to the edge.
Any computer vision algorithm will perceive the picture incorrectly. To remove such distortion, the camera that receives the image is to be calibrated in accordance with its own peculiarities.
## Script installation
First, you have to install the necessary libraries:
```
pip install numpy
pip install opencv-python
pip install glob
pip install pyyaml
pip install urllib.request
```
Then download the script from the repository:
```(bash)
git clone https://github.com/tinderad/clever_cam_calibration.git
```
Go to the downloaded folder and install the script:
```(bash)
cd clever_cam_calibration
sudo python setup.py build
sudo python setup.py install
```
If you are using Windows, download the archive from the [repository](https://github.com/tinderad/clever_cam_calibration/archive/master.zip), unzip it and install:
```(bash)
cd path\to\archive\clever_cam_calibration\
python setup.py build
python setup.py install
```
> path\to\archive path to unpacked archive.
## Preparing for calibration
You will have to prepare a calibration target. It looks like a chessboard. The file is available for downloading [here](https://www.oreilly.com/library/view/learning-opencv-3/9781491937983/assets/lcv3_ac01.png).
Glue a printed target to any solid surface. Count the number of intersections on the board lengthwise and widthwise, measure the size of a cell (mm).
![img](../assets/chessboard.jpg)
Turn on Clever and connect to its Wi-Fi.
> Navigate to 192.168.11.1:8080 and check whether the computer receives images from the image_raw topic.
## Calibration
Run script **_calibrate_cam_**:
**Windows:**
```(bash)
>path\to\python\Scripts\calibrate_cam.exe
```
> path\to\Python path to the Python folder
**Linux:**
```(bash)
>calibrate_cam
```
Specify board parameters:
```(bash)
>calibrate_cam
Chessboard width: # Intersections widthwise
Chessboard height: # Intersections heightwise
Square size: # Length of cell edge (mm)
Saving mode (YES - on): # Save mode
```
> Save mode: if enabled, all received pictures will be saved in the current folder.
The script will start running:
```
Calibration started!
Commands:
help, catch (key: Enter), delete, restart, stop, finish
```
To calibrate the camera, make at least 25 photos of the chessboard at various angles.
![img](../assets/calibration.jpg)
To make a photo, enter command **_catch_**.
```(bash)
>catch
```
The program will inform you about the calibration status.
```(bash)
...
Chessboard not found, now 0 (25 required)
> # Enter
---
Image added, now 1 (25 required)
```
> Instead of entering command **_catch_** each time, you can just press **_Enter_** (enter a blank line).
After you have made a sufficient number of images, enter command **_finish_**.
```(bash)
...
>finish
Calibration successful!
```
### Calibration by the existing images
If you already have images, you can calibrate the camera by them with the help of script **_calibrate_cam_ex_**.
```(bash)
>calibrate_cam_ex
```
Specify target characteristics and the path to the folder with images:
```(bash)
>calibrate_cam_ex
Chessboard width: # Intersections widthwise
Chessboard height: # Intersections heightwise
Square size: # Length of cell edge (mm)
Path: # Path to the folder with images
```
Apart from that, this script works similarly to **_calibrate_cam_**.
The program will process all received pictures, and create file **_camera_info_****_._****_yaml_** in the current folder. Using this file, you can equalize distortions in the images obtained from this camera.
> If you change the resolution of the received image, you will have to re-calibrate the camera.
## Correcting distortions
Function **_get_undistorted_image(cv2_image, camera_info)_** is responsible for obtaining a corrected image:
* **_cv2_image_**: An image encoded into a cv2 array.
* **_camera_****___****_info_**: The path to the calibration file.¬
The function returns a cv2 array, into which the corrected image is coded.
> If you are using a fisheye camera provided with Clever, for processing images with resolution 320x240 or 640x480, you can use the existing calibration settings. To do this, pass parameters **_clever_cam_calibration.clevercamcalib.CLEVER_FISHEYE_CAM_320_** or **_clever_cam_calibration.clevercamcalib.CLEVER_FISHEYE_CAM_640_** as argument **_camera_info_**, respectively.
## Examples of operation
Source images:
![img](../assets/img1.jpg)
![img](../assets/img2.jpg)
Corrected images:
![img](../assets/calibresult.jpg)
![img](../assets/calibresult1.jpg)
## An example of usage
**Processing image stream from the camera**.
This program receives images from the camera on Clever and displays them on the screen in corrected for, using the existing calibration file.
```python
import clevercamcalib.clevercamcalib as ccc
import cv2
import urllib.request
import numpy as np
while True:
req = urllib.request.urlopen('http://192.168.11.1:8080/snapshot?topic=/main_camera/image_raw')
arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
image = cv2.imdecode(arr, -1)
undistorted_img = ccc.get_undistorted_image(image, ccc.CLEVER_FISHEYE_CAM_640)
cv2.imshow("undistort", undistorted_img)
cv2.waitKey(33)
cv2.destroyAllWindows()
```
## The usage for ArUco
To apply the calibration parameters to the ArUco navigation system, move the calibration .yaml file to Raspberry Pi of Clever, and initialize it.
> Don't forget to connect to Wi-Fi of Clever.
The SFTP protocol is used for transferring the file. This example, WinSCP program is used.
Connect to Raspberry Pi via SFTP:
> Password: _**raspberry**_
![img](../assets/wcp1.png)
Press “Enter”. Go to _**/home/pi/catkin_ws/src/clever/clever/camera_info/**_, and copy the calibration .yaml file to this folder:
![img](../assets/wcp2.jpg)
Now we have to select this file in ArUco configuration. Connection via SSH is used for this purpose. This example, PuTTY program is used.
Connect to Raspberry Pi via SSH:
![img](../assets/pty1.jpg)
Log in with username _**pi**_ and password _**raspberry**_, go to directory _**/home/pi/catkin_ws/src/clever/clever/launch**_ and start editing configuration _**main_camera.launch**_:
![img](../assets/pty2.jpg)
In line _**camera node**_, change parameter _**camera_info**_ to _**camera_info.yaml**_:
![img](../assets/pty3.jpg)
> Don't forget to change camera resolution.

163
docs/en/face_recognition.md Normal file
View File

@@ -0,0 +1,163 @@
# Face recognition system
## Introduction
Recently, face recognition systems have been getting a wider use, the application scope of this technology is really expansive: from regular selfie drones to police drones. Everywhere it is being integrated into various devices. The recognition process itself is really fascinating, and that's what inspired me to create a project associated with it. The purpose of my internship project was to create a simple open source system for face recognition with a Clever quadcopter. The program takes images from the quadcopter's camera and processes it on a PC. Therefore, all other instructions are executed on a PC.
## Development
The first task was finding a recognition algorithm. As a solution to the problem, [a ready API for Python](https://github.com/ageitgey/face_recognition) was chosen. This API combines several advantages: recognition speed and accuracy, and ease of use.
## Installation
First, you have to install all the necessary libraries:
```(bash)
pip install face_recognition
pip install opencv-python
```
Then download the script from the repository:
```(bash)
git clone https://github.com/mmkuznecov/face_recognition_from_clever.git
```
## Code explanation
Enable libraries:
```python
import face_recognition
import cv2
import os
import urllib.request
import numpy as np
```
***This part of the code is intended for Python 3. In Python 2.7, enable urllib2 instead of urllib:***
```python
import urllib2
```
Create a list of encodings for images and a list of names:
```python
faces_images=[]
for i in os.listdir('faces/'):
faces_images.append(face_recognition.load_image_file('faces/'+i))
known_face_encodings=[]
for i in faces_images:
known_face_encodings.append(face_recognition.face_encodings(i)[0])
known_face_names=[]url
for i in os.listdir('faces/'):
i=i.split('.')[0]
known_face_names.append(i)
```
***Addition: all images are stored in folder faces in format name.jpg***
<img src="../assets/screen.jpg" width="50%">
<img src="../assets/Mikhail.jpg" width="30%">
<img src="../assets/Timofey.jpg" width="30%">
Initialize some variables:
```python
face_locations = []
face_encodings = []
face_names = []
process_this_frame = True
```
Get the image from the server, and convert it to format cv2:
```python
req = urllib.request.urlopen('http://192.168.11.1:8080/snapshot?topic=/main_camera/image_raw')
arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
frame = cv2.imdecode(arr, -1)
```
***For Python 2.7:***
```python
req = urllib2.urlopen('http://192.168.11.1:8080/snapshot?topic=/main_camera/image_raw')
arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
frame = cv2.imdecode(arr, -1)
```
Further explanation of the code is available at GitHub of the used API in the comments to [the next script](https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py)
## Using
It is enough to connect to "Clever" via Wi-Fi and check whether the video stream from the camera is working correctly.
Then just run the script:
```(bash)
python recog.py
```
And the output:
<img src="../assets/Mikhail_output.jpg" width="50%">
<img src="../assets/Timofey_output.jpg" width="50%">
## Possible difficulties
When the script is started, the following error may pop up:
```python
known_face_encodings.append(face_recognition.face_encodings(i)[0])
IndexError: list index out of range
```
In this case, try to edit the images in folder faces, perhaps the program cannot recognize faces in the images due to poor quality.
## Using the calibration
To improve recognition accuracy, you can use camera calibration. The calibration module may be installed using [a special package](https://github.com/tinderad/clever_cam_calibration). Instructions for installation and use are available in file calibration.md. The program that uses the calibration package is named recog_undist.py
**Code brief explanation:**
Enable installed package:
```python
import clever_cam_calibration.clevercamcalib as ccc
```
Add the following lines:
```python
height_or, width_or, depth_or = frame.shape
```
This way, you will obtain information about image size, where height_or is the height of the initial image in pixels, and width_or is the width of the initial image.
Then correct distortions in the initial image, and get its parameters:
```python
if height_or==240 and width_or==320:
frame=ccc.get_undistorted_image(frame,ccc.CLEVER_FISHEYE_CAM_320)
elif height_or==480 and width_or==640:
frame=ccc.get_undistorted_image(frame,ccc.CLEVER_FISHEYE_CAM_640)
else:
frame=ccc.get_undistorted_image(frame,input("Input your path to the .yaml file: "))
height_unz, width_unz, depth_unz = frame.shape
```
***In this case, we pass argument ссс.CLEVER_FISHEYE_CAM_640, since the resolution of the image in this example, is 640x480; you can also use ссс.CLEVER_FISHEYE_CAM_320 for resolution 320x240, otherwise you will have to send the path to the .yaml calibration file as the second argument.***
Finally, return the image to its initial size:
```python
frame=cv2.resize(frame,(0,0), fx=(width_or/width_unz),fy=(height_or/height_unz))
```
This was, you can significantly improve recognition accuracy since the image processed will not be so badly distorted.
<img src="../assets/misha_calib.jpg" width="50%">
<img src="../assets/tim_calib.jpg" width="50%">

232
docs/en/ir_sensors.md Normal file
View File

@@ -0,0 +1,232 @@
# Working with IR sensors on Raspberry Pi 3
Infrared sensors are a convenient tool for transmitting any commands to the copter. They are flexible in configuration, and interaction with them is possible in Python.
## Connecting the IR receiver
Most IR receivers operate and are connected the same way. Such receivers have 3 pins for connecting: G/GND — ground V/VCC — 5V power, S/OUT — signal.
<img src="../assets/IR_reciver_connection.png" height="500px" alt="ir reciver connection to raspberry">
> **Hint** The signal port doesn't have to be connected to port GPIO 17; this pin may be changed during the [in/out port settings](#in/out).
## Configuring the IR receiver to work with the LIRC module
LIRC (Linux Infrared Remote Control) is a stable and time-proven open source library, which allows sending and receiving commands via an infrared port. LIRC is supported by Raspbian.
To install LIRC and related modules, connect your Raspberry Pi to the Internet and run the console command:
```(bash)
sudo apt-get update
sudo apt-get install lirc
sudo apt-get install python-lirc
pip install py-irsend
```
> **Hint** To correctly edit the system files, superuser privileges are required; when calling a text editor, use `sudo`.
<a name="in/out"></a>
After installing the module, edit file `/etc/modules` and add line:
```
lirc_dev
lirc_rpi gpio_in_pin=18 gpio_out_pin=17
```
Where:
+ `gpio_in_pin` is the input pin from the receiver
+ `gpio_out_pin` is the transmitter output pin
Update the following line in file `/boot/config.txt`:
```
dtoverlay=lirc-rpi,gpio_in_pin=18,gpio_out_pin=17
```
Add the following lines to file `/etc/lirc/hardware.conf`. Is this file does not exist, create it yourself.
```
LIRCD_ARGS="--uinput --listen"
LOAD_MODULES=true
DRIVER="default"
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"
```
Update the following lines in file `/etc/lirc/lirc_options.conf`
```
driver = default
device = /dev/lirc0
```
All required settings are made, you now have to restart your Raspberry Pi device to complete the installation. To do so, run:
```(bash)
sudo reboot
```
After rebooting, check its status by calling command:
```(bash)
sudo /etc/init.d/lircd status
```
If everything has been done correctly, the status should be `active`.
To check whether the installed module LIRC is running, disable daemon `lircd`, and call the appropriate command:
```(bash)
sudo /etc/init.d/lircd stop
mode2 -d /dev/lirc0
```
Now point the IR transmitter on your device and tap a few keys. You should see something like this:
```
space 402351
pulse 135
space 7085
pulse 85
space 2903
pulse 560
space 1706
pulse 535
```
> **Hint** If you are using an IR transmitter (a TV remote, an air conditioner remote, etc. and you are not getting the signal when checking, your remote is evidently using another signal frequency. When using receivers such as TSOP 22XX, the operating frequency of the signal reception will be in the range between 30 and 50 kHz.
## Write your configuration of the IR transmitter
<a name="remote_control"></a>
If you want to use your own IR transmitter, you will have to write its specific settings using the supplied module `irrecord`. For this purpose, disable daemon `lircd`, and call the appropriate command. During transmitter calibration, stick to all written instructions.
> **Hint** Please note that the last step of the calibration will be specifying the names of the keys that you will want to decode programmatically. To view the list of available names, call command `irrecord --list-namespace`.
```(bash)
irrecord -d /dev/lirc0 ~/lircd.conf
```
If you have managed to successfully write the configuration of your transmitter, file `your-name.lircd.conf` should appear in folder `/home/pi/`. Now you need to move the written configuration file to working folder `lirc`, and restart the daemon:
```
sudo cp ~/your-name.lircd.conf /etc/lirc/lircd.conf
sudo /etc/init.d/lircd restart
```
To check whether the written configuration is recognized, call the appropriate module. Now when you tap the keys that you have specified in the previously created configuration, the terminal will show debug information about which key has been pressed.
```
irw
```
> **Caution** when working with some transmitters, there are situations where the bit descriptions of keys are redundant; in this case, command `irw` may fail. To correct this error, open file `etc/lirc/lircd.conf` and check what the description of your keys looks like; if it looks like `KEY_1 0x00FF6897 0x7EE0CF2C` and in all lines the second digits match, you have to remove it, so that lines with keys assignment looks like `KEY_1 0x00FF6897` and all digits in them are unique. After completing these steps, close the file and restart the daemon.
If you did everything correctly, upon tapping a key, you will see the output similar to:
```
0000000000ff6897 00 KEY_1 pult
0000000000ff6897 01 KEY_1 pult
0000000000ff9867 00 KEY_2 pult
0000000000ff9867 01 KEY_2 pult
```
This means that your configuration is correctly detected by the program, and now you can program the desired action for tapping appropriate keys.
## Working with IR sensors in Python
To be able to use signals from the IR receiver in Python programs, you'll need package `python-lirc`. [Install it](#install), if necessary.
For correct obtaining information, create file `lircrc` in your own script, which will store settings of your keys and the program response upon calling.
This file is created in the folder from which your script will be called, `/home/pi/` by default.
To create the required file, use any text editor:
```(bash)
sudo nano .lircrc
```
The format of this file should be something like this:
```
begin
prog = myprogram
button = KEY_1
config = one
end
begin
prog = myprogram
button = KEY_2
config = two
end
```
Where:
+ `prog` is the name of the program that you will call from your script
+ `key` is the name of the key that you entered during transmitter setup
+ `config` is the information to be passed to your program upon tapping a specified key
All settings are now made, and you can proceed directly to programming IR signals.
For this purpose, create a Python script that will accept the values of the keys pressed and perform required action s accordingly.
An example of such a script:
```python
import lirc
import fly_module
# ...
sockid = lirc.init('myprogram')
inf = lirc.nextcode()
if inf[0] == 1:
print('You pressed key 1')
elif inf[0] == 2:
print('You pressed key 2')
lirc.deinit()
```
## Working with the IR transmitter
To work with the IR transmitter, connect it to the ports specified [during setup](#in/out).
<img src="../assets/IR_transmitter_connection.png" height="500px" alt="IR transmitter connection to raspberry">
<img src="../assets/IR_transmitter.png" height="200px" alt="IR transmitter scheme">
> **Hint** if you are using a ready IR transmitter board, connect it to required pins of Raspberry in accordance with pins marking, in the same way as with the receiver.
If everything has been properly connected, you will be able to send signals specified in [transmitter settings](#remote_control) using the command:
```(bash)
irsend SEND_ONCE deviceName keyName
```
Where:
+ SEND_ONCE is the parameter responsible for sending a single signal, or sending a signal from a depressed and held down key
+ deviceName is the name of the transmitter specified during [setup](#remote_control)
+ keyName is the name of one of the keys specified during transmitter configuration
To work with `irsend` inside your script, you'll need module `python-irsend`; if necessary, [install it](#install).
To use `irsend`, import the library and call the appropriate command:
```python
from py_irsend import irsend
irsend.send_once('YourRemote', ['YourKey'])
```
Where:
+ YourRemote is the name of your transmitter specified during setup
+ YourKey is the name of one of the buttons specified during setup

89
docs/en/laser.md Normal file
View File

@@ -0,0 +1,89 @@
# Working with a laser rangefinder
## Rangefinder VL53L1X
The rangefinder model recommended for Clever is STM VL53L1X. This rangefinder can measure distances from 0 to 4 m while ensuring high measurement accuracy.
The [image for Raspberry Pi](microsd_images.md) contains pre-installed corresponding ROS driver.
### Connecting to Raspberry Pi
> **Note** For correct operation of a laser rangefinder with a flight countroller <a id="download-firmware" href="https://github.com/CopterExpress/Firmware/releases">custom PX4 firmware</a> is needed. See more about firmware in [corresponding article](firmware.md).
<script type="text/javascript">
fetch('https://api.github.com/repos/CopterExpress/Firmware/releases').then(res => res.json()).then(function(data) {
for (let release of data) {
if (!release.prerelease && !release.draft && release.tag_name.includes('-clever.')) {
document.querySelector('#download-firmware').href = release.html_url;
return;
}
}
});
</script>
Connect the rangefinder to pins 3V, GND, SCL and SDA via the I²C interface:
<img src="../assets/raspberry-vl53l1x.png" alt="Connecting VL53L1X" height=600>
If the pin marked GND is occupied, you can use another free one using the [pinout](https://pinout.xyz).
> **Hint** Via the I²C interface, you can connect several peripheral devices simultaneously. For this purpose, use a parallel connection.
### Enabling
[Connect via SSH](ssh.md) and edit file `~/catkin_ws/src/clever/clever/launch/clever.launch` so that driver VL53L1X is enabled:
```xml
<arg name="rangefinder_vl53l1x" default="true"/>
```
By default, the rangefinder driver sends the data to Pixhawk (via topic `/mavros/distance_sensor/rangefinder_sub`). To view data from the topic, use command:
```(bash)
rostopic echo mavros/distance_sensor/rangefinder_sub
```
### PX4 settings
To use the rangefinder data in [PX4 must be configured](px4_parameters.md).
When using EKF2 (`SYS_MC_EST_GROUP` = `ekf2`):
* `EKF2_HGT_MODE` = `2` (Range sensor) when flying over horizontal floor;
* `EKF2_RNG_AID` = `1` (Range aid enabled) in other cases.
When using LPE (`SYS_MC_EST_GROUP` = `local_position_estimator, attitude_estimator_q`):
* The "pub agl as lpos down" flag is ticked in the `LPE_FUSION` parameter when flying over horizontal floor.
### Obtaining data from Python
To obtain data from the topic, create a subscriber:
```python
from sensor_msgs.msg import Range
# ...
def range_callback(msg):
# Processing new data from the rangefinder
print 'Rangefinder distance:', msg.range
rospy.Subscriber('mavros/distance_sensor/rangefinder_sub', Range, range_callback)
```
### Data visualization
To build a chart using the data from the rangefinder, one can use rqt_multiplot.
rviz may be used for data visualization. To do this, add a topic of the `sensor_msgs/Range` type to visualization:
<img src="../assets/rviz-range.png" alt="Range in rviz">
See [read more about rviz and rqt](rviz.md).
<!--
### Connecting to Pixhawk / Pixracer
Support for rangefinder VL53L1X is not yet implemented in the PX4 firmware (in version *1.8.2*).
-->

115
docs/en/lesson3.md Normal file
View File

@@ -0,0 +1,115 @@
Lesson # 3 "Theory of soldering"
======================
Soldering metal is a rather complex physicochemical process; however, it boils down to fairly simple techniques and operations. To solder properly without wandering in the wilds of the theory, one should exactly follow the rules of soldering. This especially applies to the choice of the soldering method, the solder and the flux, depending on the kind of items connected and the requirements to the soldered joint.
What is soldering?
----------------
Soldering at home includes the following technological operations:
1. The surfaces to be soldered are to be cleaned from dirt, corrosion, etc. They are to be sanded until shine is seen, i.e., until no visible traces of oxides are to be visible;
2. Apply flux, i.e., a substance that removes oxide residues and does not allow oxidation of the surfaces during the further process. For applying to surfaces to be tinned, solid or liquid fluxes and flux pastes are recommended;
3. Then the surfaces are tinned — melted solder (an alloy specially intended for soldering) is applied to them, it spreads in a thin film and chemically combines with the base metal;
4. The items to be soldered are mechanically connected with a cable, or using forceps, pliers, vise, clamps, etc. More flux is applied to prevent oxidation of heated solder;
5. More heated solder (maybe another one) is applied, until a seam of desired quality is obtained;
6. If a soldering iron with a tinned tip was used for soldering, after work, it should be cleaned and coated with an inactive flux. To ensure high quality of soldering, a conventional soldering iron should be kept with its tip fluxed!
Cleanup
--------
Cleanup after cleaning is the first tricky soldering operation. Never use abrasives for this purpose! The smallest abrasive particles get embedded in the metal, and it is impossible to completely remove them. Subsequently, they become the foci of the processes that destroy the seam. The surface are cleaned up for soldering using files, grinders (various types of scrapers), or just with a knife. But best way, especially if current-carrying wires are being prepared for soldering, is covering them with activated flux, which should be carefully removed after soldering. It is easily done with a toothbrush moistened with alcohol.
How to tin/solder, and what to use?
-----------------------
For the following operations, you will need a special electric-heating tool: a soldering iron or a blowtorch. At home, an electric soldering iron with a tin-plated copper tip is most often used for soldering.
![scheme](../assets/4_1.png)
Tinning should be done as follows:
* Thin wires should be tinned easily, without pressure, by moving the tin on the bare ends of the wire at one and the opposite end until the solder melts. The wire is held with its end down. The excessive drop of the solder that collects at the end is removed with the soldering iron.
* Thick wires are tinned by moving the tip in a spiral back and forth.
* To flat slim long items, the solder is to be applied to the end of the tip, and the top is moved along. When un-tinned edges of the item are seen after the tip, more flux is applied to the untinned part, and another drop of tin is used for tinning.
* A long wider item — same as above, but the tip is moved in S-turns.
* A wide item — the tip moves in a spiral from the center to the edges.
Special aspects of soldering wires
--------------------------
Is the preliminary joint of soldered items, most problems occur with wires: one has to touch them with hands, which results in fouling of the surface of the metal; besides, seams between wires have to withstand mechanical loads more frequently than other soldered joints.
### Twisted wires
Before wires are soldered, they should be properly twisted. The main methods of twisting wires for soldering are shown in the Figure. Each of them has its own purpose:
* Band twisting is used for rigid (thick, one core) current carrying wires, i.e., the wires that transmit electric power, especially outside wires. Band twisting ensures sufficient electric contact even with insufficient soldering, or overheating of oxidized seam.
* Groove twists are used for wires with easily-melting insulation (common PVC, polyethylene) when complete spread of the solder with minimal heating is required. Groove twists are only heated along the groove.
* Simple twists may be used to connect both single core and multicore wires immediately after insulation stripping (shiny).
* Simple consecutive twisting, the so-called British twisting, is used for connecting current-carrying wires of flexible cables with the cross-section up to 1.4 sq. mm not subjected to regular high mechanical loads, e.g., electrical extension cords or temporary connections.
![scheme](../assets/4_2.png)
Electrical wires subjected to regular and/or constant mechanical loads are to be stranded. They are to be twisted as shown in the Figure below: the ends are spread apart, the "brooms" are slid into each other and twisted the British way. Soldering is performed with the use of a fusible solder with high tensile strength, e.g. POSK-50 (see below) with activated flux that does not require residue removal, also see below. Parallel (dead end) twists of wires with the cross section greater than 0.7 sq. mm should be soldered preferably by dipping into molten solder, see below. Otherwise, the wires re to be either heated for a long time, or with a too powerful soldering iron, which results in damaged insulation, and the flux boiling away prematurely.
What can be soldered, but should not be soldered
Flexible coaxial cables and cables for computer networks such as twisted pair, are not intended for soldering. An experienced cableman that has a good idea about electrodynamics of signal lines can in exceptional cases make a coupling with them. But when made by a layman, even if he is otherwise a qualified electronic engineer and installer, the throughput and noise immunity of the line will fall below the permissible level, down to total loss.
How to clean and preserve the soldering tip
The soldering tip is to be cleaned of excess solder by rubbing on soft porous or fibrous lining. Polyurethane foam is used most frequently, but it is not the best choice: it burns and sticks to the tip. The best material for cleaning is natural felt or basalt cardboard. But still better is two-stage cleaning, first with a sponge made of a metal strip, and with felt afterwards. After cleaning, the soldering iron is to be turned off, the tip is immersed into hard colophony, and some time is waited until it stops bubbling. After that, the tip is taken out, and the soldering iron is held tip down for the excess colophony to drain. Upon complete cooling, the soldering iron may be sent for storage.
Solders and fluxes
--------------
Solders from POS-90 to Avia-2 are soft solders for low temperature soldering. They guarantee only electrical contact. POS-30 and POS-40 are used for soldering copper, brass, bronze with inactive fluxes, and the same with steel and steel to steel with active fluxes. POSSR-15 may be used for soldering dipped galvanized steel with inactive fluxes; other solders in this corrode the zinc down to the steel and the soldering falls off soon. 34A, MF-1 and RSr-25 are solid solders for high temperature brazing. Solder 34A nay be used for soldering aluminum in the flame (see further about soldering aluminum) with special fluxes, see further, too. Solder MF1 is used for soldering copper to steel with activated flux. "Low strength requirements" in this case means that the strength of the joint will be closer to that of copper than of steel. When used with a dry soldering iron, PSr-25 is suitable for soldering jewelry, Tiffany stained glass, etc.
### Fluxes
Soldering fluxes are divided into neutral (inactive, acid-free) that do not interact chemically with the base metal, or interact to a negligible extent, activated fluxes that chemically interact with the base metal upon heating, and active (acid) that interact with cold base metal. As far as fluxes are concerned, our age has brought the largest number of advances which are mostly good, but let's start with the unpleasant ones. The first one is the fact that there is not technically pure acetone for washing soldering, since it is used it is used in the clandestine production of drugs, and has a narcotic action by itself. Substitutes for technical acetone are solvents 646 and 647.
The second one is that zinc chloride in activated flux pastes is often replaced with borax. Hydrochloric acid is a highly toxic volatile chemically aggressive substance; zinc chloride is also toxic and when heated, sublimates, i.e., it evaporates without melting. Borax is safe, but when heated, produces a large amount of crystallization water, which slightly affects soldering quality.
![flux](../assets/4_3.png)
Soldering joints made with the spirit-colophony flux are to be washed: colophony contains succinic acid, which destroys metal upon prolonged contact. In addition, accidentally spilled spirit-colophony flux instantaneously spreads over a large area and turns into an extremely sticky stuff that takes very long to dry, and its stains cannot be removed from clothes, furniture, or floor and walls. In general, spirit-colophony is a good soldering flux, but not for rubbernecks and butterfingers. A full-fledged substitute for the spirit-colophony flux, but not so nasty if handled carelessly, is the flux named TAGS. If steel parts are more massive than allowed for soldering with soldering acid and the soldering should be stronger, flux F38 is used for soldering. It is a universal flux that can be used with virtually any metals in any combination, including aluminum, but the strength of the joint with it has not been standardized. We'll yet return to soldering aluminum.
### Other types of soldering
Tinkerers also often use a dry soldering iron with an untinned tip, the so-called soldering pencil, pos. 1 in the Figure. It is good where solder spreading outside the area of soldering is unacceptable: in jewelry, stained glass, soldered items of applied art. Dry soldering is sometimes used for soldering surface mounted chips, with the distance between pins of 1.25 or 0.625 mm, but it is risky even for experienced professionals: the poor thermal contact requires excessive power of the soldering iron and prolonged heating, while it is impossible to ensure heating stability during manual soldering. White resin POSK-40, 45, or 50, and flux pastes that do not require residue removal are used for dry soldering.
![scheme](../assets/4_4.png)
### Small-scale soldering
Soldering of printed circuit boards has its own peculiarities. Wires are not tinned, as pins of the components and chips are already tinned. In the amateur conditions, first, tinning current-carrying paths makes little sense, if the device operates at frequencies up to 40 50 MHz. In industrial production, circuit-board are tinned using low-temperature methods, e.g., by sputtering or electroplating. Heating with a soldering iron tracks along the entire length deteriorates their adhesion with the substrate and increases the probability of delamination. After installation of components, it is best to have the circuit-board covered with varnish Copper will immediately darken, but the efficiency of the device will not be affected, if only we are not talking about the microwave frequencies.
### Soldering electronic components on a printed circuit board
Then, take a look at something ugly on the left in the next Figure. Such poor quality could, even in the Ministry of electronics industry could be the reason for transferring fitters to movers or helpers. The reason was not even appearance or overuse of expensive solder, but, firstly, the fact that the mount pads and the components overheated while these drops of solder cooled down. Large and heavy drops of solder are pretty inert weights for the already weakened paths. Radio enthusiasts are well familiar with the effect: when one, two or more paths peel off from a circuit board that has fallen on the floor. Even without waiting for the first re-soldering
![soldering](../assets/4_5.png)
Soldering drops on circuit boards should have around shape, be smooth, and have the height not exceeding 0.7 of the mounting pad diameter, see right in the Figure. The ends of pins should slightly protrude from the drops. By the way, the circuit-board is completely self-made. There is a way to make a homemade circuit board as crisp and precise as a factory-made one, and place whatever inscriptions on it. White sports are glares from the varnish during under the flashlight. The drops are sagged in and shrunk - it is also a defect. A sagged in drop means that the soldier was not enough, and shrunk drop also means that air has penetrated the solder. If the device is not working or there are suspected dry joints, check these locations first.
### Chips, soldering
Chips in DIP-packages re soldered like other electronic components. Soldering iron power should be up to 25 watts. The solder should be POS-61; the flux should be TAGS or spirit colophony. Is remainders should be washed away with acetone or its substitute: alcohol poorly washes away colophony, and it cannot be removed between the pins even with a brush or cloth. As to chips and microchips, soldering them manually is highly not recommended by professionals of any level: it is a lottery that is very unlikely to win and very likely to lose. If it comes to repairing phones and tablets, you will have to buy a soldering station. Using it is not much harder than using a hand soldering iron, see video below, the price of a decent soldering station is quite affordable today
### What else?
Oh yeah, stands for soldering irons. A classic stand is shown in the figure in the left; it is suitable for any soldering irons with rod tips. It's up to you where to place trays for the solder and colophony - it is not regulated. For low-power soldering irons with a skirt, simplified stands with a bracket in the center are suitable.
![soldering](../assets/4_6.png)
Soldering stations are equipped with mainly spring or tubular socket cradles for soldering irons. The hot part of the tool is inaccessible in them, however it is easy to miss when soldering small components. But one should never, and it is expressly forbidden in the safety rules, make a stand of materials at hand, where the soldering iron rests on trays with consumables, as shown in the Figure on the right.
### Reference questions
1. What substance prevents oxidation?
2. List the main steps of soldering.
3. What is tinning?
4. In what cases soldering should not be used?
5. Which flux is better for soldering chips.

71
docs/en/lesson4.md Normal file
View File

@@ -0,0 +1,71 @@
Lesson # 4 "Aerodynamics of the flight. Propeller"
========================================
Aerodynamics of the propeller
-----------------------
A propeller is a blade unit rotated by the motor and used for converting the torque of the motor into the thrust.
The screw (propeller) rotates in place. With that, the air flows vertically downwards. This is one of the modes of the so-called axial screw airflow. On one of the blades, two small sections are marked: one (A) — closer to the rotation axis, the other (B) — at the end of the blade. During screw rotation, both sections will circumscribe concentric circles. It is clear that the length of the circle circumscribed by the element "B", and hence its speed relative to the air are greater than those of element "A". In other words, the speed of the blade element relative to the air depends on the distance to the rotation axis. The longer the distance, the greater the speed of the element. It is clear that at the axis of rotation, the speed will be zero, and at the end of the blade, it will be the maximum.
![rotation](../assets/7_1.png)
The blade cross section in this area has the shape of a streamlined profile. When air flows past this profile at the angle of incidence, the lifting force Y and the drag force X appear, which are calculated using special formulas. By breaking the blade into many small sections, one can determine their lifting forces and the drag forces, and by adding the appropriate forces of all sections, one can determine the lifting force and the drag force of one blade. (From the mathematical point of view, this operation is called integrating along the span of the blade). The lifting force (or the thrust) of the entire screw is obtained by multiplying the lifting force of one blade by the number of blades.
The edge effect. The magnitude of the screw thrust is calculated by the method described above with a certain error, which is determined by several reasons. One of them is not considering the so-called edge effect. The edge effect is manifested in the fact that the air tends to equalize the pressure above the blade and under the blade by flowing over the edge of the blade.
![rotation](../assets/7_2.png)
In this case, flowing over occurs on both on outer and inner edges of the blade. And since the lifting force occurs due to the pressure difference on the top and the bottom surfaces of the blade, any equalization of these pressures causes the loss of the lifting force.
Parameters of propellers
---------------------
There are many types of airscrews which may be used with varying degree of success.
One should consider the following parameters:
1. **Propeller diameter.** Larger propellers require more power of the motor for spinning. Make sure that the motor can develop the required power. Large and heavy propeller cells to have more inertia, therefore they cannot accelerate instantly, which will affect the copter's maneuverability.
2. **Prop pitch.** It is indicated by the second digit after "x" in the propeller brand; it may also be indicated by the third and the fourth digits of the brand - e.g., 1260 are propellers with the pitch of 6.0 inches. Physically, it is the air column that the propeller moves downwards in one revolution. The larger the pitch, the greater the lifting force. Naturally, there are reasonable limits: for example, 14х7 propellers have greater lifting force than 14х5 propellers. By the way, for the ideal case, the pitch of the propeller multiplied by the number of revolutions per second gives the speed of the air flow from the propeller.
3. **The number of blades.** In the classic case, there are two blades. However, propellers with three blades have greater lifting force - roughly equivalent to that of a two-blade propeller with the diameter 1 inch larger and the pitch 1 inch greater.
4. **Propeller constant**, the so-called Prop-Const, strongly affects the lifting force and the power of the motor required to spin the propeller, because physically this constant indicates the magnitude of the losses for air resistance during propeller rotation: the thinner the material the propeller is made of, the smaller this constant, and the smaller the power of the motor required for spinning the prop.
### Screws layout
Building a quadcopter requires two pairs of bidirectional screws, building a hexacopter requires 3 pairs, etc.
![rotation](../assets/7_3.png)
5\. **Direction of screws rotation** - classic - two screws counterclockwise, the other two screws clockwise in quadcopters.
6\. **Propellers workmanship quality** is also important. In the practice, it means that you should always balance the propellers to minimize vibration, which gradually destructs mechanical parts and drives periscopes crazy, deteriorating the flight properties of the quadcopter.
Building a quadcopter requires two pairs of bidirectional screws, building a hexacopter requires 3 pairs, etc.
Choosing the propeller
----------------
It is hard to imagine a propulsion source that would be more versatile than the propeller.
However, not everybody clearly understands how to correctly calculate the parameters of the propeller. Using the -and-see method, we sometimes lose a lot of time and effort on picking up dozens of various propellers in the hope of finding the one that would provide optimal thrust with specific motor and vehicle.
Calculating and choosing an air screw for the motor and a specific copter is a complex and a delicate task.
The source data for choosing the screws for DIY drone kits are usually the power of the motor Nmot (W), the airscrew rotation speed NS (rpm), and the maximum (flight) speed Vmax (m/s).
One should face the fact that no calculation will let you immediately and accurately determine all parameters of a fixed-pitch propeller. Exact calculation of such screws is a very difficult task. Even the most careful calculations do not allow getting an ideal propulsion unit for a specific vehicle. It is only during testing that it becomes clear how the crew should be modified, whether the pitch should be increased or decreased. The methods provided here allow choosing the initial screw if one can say so, a first approximation screw. And it is only the testing that will show, whether further modification of the screw will be required to fit your vehicle.
If the screw diameter should be decreased, it is sometimes recommended increasing the pitch or the width of the blades. Indeed, this helps take all the power from the motor, however efficiency of the propulsion unit inevitably drops.
it is very important to remember that a high-speed copter or requires a small-diameter high-speed propeller, and a low-speed one requires a large-diameter low-speed one.
The following method of choosing a screw for an amateur copter would seem to be reasonable: First, in accordance with the layout, choose the maximum possible diameter of the screw: consider all permissible gaps between the ends of the blades and the structure and other parameters. Then choose the motors according to the requirements of the model. There are also situations where the propeller is chosen for the motor.
So, we have to choose a motor and a propeller. How can one do it without using cumbersome formulas and complex calculations? Below, the choice of propellers is shown based on the motors chosen. However, this method is also suitable for choosing a motor for a propeller, if performed in reverse order.
For example, let's take motor X2204S 2300kv from the SunnySky company. Go to the manufacturer's website, and find the motor. The description contains a table for choosing the propeller (prop).
![rotation](../assets/7_4.png)
### Reference questions
1. How is thrust formed in a propeller?
2. How can one determine the prop pitch from the name of its brand?
3. What is propeller constant?
4. What is the purpose of using propellers rotating clockwise and counterclockwise in a copter?
5. What are the source data for choosing a screw for a copter?
6. What characteristics of the propeller are required for a high-speed and a low-speed copter?
7. Using a table for motor X2204S 2300kv, find the propeller that would develop the maximum speed.

112
docs/en/lesson6.md Normal file
View File

@@ -0,0 +1,112 @@
Lesson 6 "Fundamentals of electromagnetism. Types of motors"
===================================================
Basic laws of electromagnetism
---------------------------------
### Ampere's law
**Ampere's law** — the law of electric currents interaction. It was first discovered by Andre Marie Ampere in 1820 for direct current. From the Ampere's law it follows that parallel conductors with electric currents flowing in the same direction attract, and with electric currents flowing in the opposite direction, repel.
![low](../assets/8_1.png)
Ohm's Law
---------
**Ohm's law** is a physical law that determines the relationship between the electromotive force of a source (or electric voltage) with the current flowing in the conductor, and the resistance of the conductor. It was discovered by Georg Ohm in 1826, and named in his honor.
Coulomb's Law
------------
**Coulomb's law** is the law that describes the force between stationary point-like electric charges.
"The force of interaction of two point-like charges in the vacuum is directed along the straight line that connects these charges, proportionally to their magnitudes and inversely proportionally to the distance squared between them. It is the force of attraction if the charges are different, and the force of repulsion if the charges are the same."
Types of motors
---------------
Each motor has certain distinctive properties, which determine the scope of use, where it would be most appropriate. Synchronous, asynchronous, direct current, brush-type, brushless, valve-inductor, stepper ones...
![engine](../assets/8_2.png)
### A DC motor (DCM)
Motors of this type used in most old toys. A battery and two wires to the contacts. Such a motor contains a commutator installed on the shaft, which switches the windings depending on the rotor position. Direct current applied to the motor runs alternatively in some and other parts of the winding thus creating torque.
![engine](../assets/8_3.png)
DC motors may be both small (a vibro in your telephone), and rather large — usually up to a megawatt. For example, the photo below shows a traction motor of an electric locomotive with the power of 810 kW and voltage of 1,500 V.
### A universal commutator motor
Oddly enough, this is the most common motor in the household use, the name of which is the least known. Why did this happen? Its design and features are the same as those of a DC motor, therefore it is mentioned in textbooks usually in the very end of the chapter.
![engine](../assets/8_4.png)
This type of engine is more widely available in household appliances where it is required to adjust the rotation speed: drills, washing machines (not with "direct drive"), vacuum cleaners, etc. Why is it so popular? Due to the simplicity of regulation. Like in an AC motor, it can be adjusted by voltage, through a symistor (bidirectional thyristor) for AC power. The control circuit may be so simple, which is placed, for example, directly in the "trigger" of the power tool, and requires neither microcontroller, nor a PWM, nor a rotor positioning sensor.
### Asynchronous motor
Asynchronous motors are used in the household: in the devices where there is no need to adjust the rotation speed. Most often it is the so-called "capacitor" engines, or, equivalently, "single-phase" asynchronous engines. But actually, from the point of view of the motor, it is correct to say "two-phase", simply one phase of the motor is connected to the AC network directly, and the other — through a capacitor. The capacitor causes a voltage phase shift in the other winding, which allows creating a rotating elliptical magnetic field. Usually such motors are used in exhaust fans, refrigerators, small pumps, etc.
### Synchronous motor
There are several subtypes of synchronous motors — with magnets (PMSM) and without magnets (with an excitation winding and slip rings), with sinusoidal or trapezoidal EMF (brushless DC motors, BLDC). Some step motors may also be included here. Before the era of power semiconductor electronics, the destiny of synchronous machines was being used as alternators (almost all alternators in all power plants are synchronous machines), as well as powerful drives for any serious load in the industry.
![engine](../assets/8_5.png)
### Comparison of brushed and brushless motors
In radio controlled models with electric motors, brush and brushless motors are used.
A brief comparison of the types of engines: brush-type motors develop lower speed. Brushless motors can develop more speed, and are also more durable.
![engine](../assets/8_6.png)
### Brush-type motors
These have brush-collector units, which ensure movement of radio-controlled models. The collector is essentially a set of contacts on the rotor and brushes — sliding contacts, which are located outside the rotor.
How it works: Works from DC. I.e., by applying voltage from a DC source (a battery) one makes it move. To change the direction, simply reverse current polarity. This is a fairly simple mechanism, and therefore, motors of the brush type are cheaper. This type of motors belongs to the earlier type with the **efficiency** of **60 %**, as calculated by specialists.
**Advantages of brush-type motors in radio-controlled models** include:
* Light weight of the motor
* Small size of the motor
* Lover cost of the motor
* Repairability
**Disadvantages of brush-type motors:**
* Lower efficiency of the motor
* Lower maximum developed speed
* Mechanical work of brushes and collector may result in sparkling if overheated
* Rapid wear
Brushless motors, in which the moving part is the stator, are more efficient than brush-type motors. This is achieved due to the absence of brushes. However, since motor design is much more complicated, they are more expensive.
**Advantages:**
* High motor efficiency — up to 92 %
* Higher maximum developed speed
* More wear resistant due to the closed type of the motor
* Better protected from moisture, dust and dirt
**Disadvantages:**
* High cost
* More complicated repair
### Reference questions
1. What behavior of conductors with electric currents follows from the Ampere's law?
2. According to Coulomb's law, how do two point charges interact in vacuum?
3. What is the main difference between brush-type and brushless motors?
4. What are the characteristics of brushless motors that make them suitable to be used in quadcopters?