docs: reflect camera frame configuration changes

This commit is contained in:
Oleg Kalachev
2020-04-30 05:03:29 +03:00
parent ddee29a0e8
commit 2a3efa2908
2 changed files with 136 additions and 94 deletions

View File

@@ -1,10 +1,10 @@
# Camera setup
> **Note** The following applies to [image version](image.md) **0.15** and up. See [previous version of the article](https://github.com/CopterExpress/clover/blob/v0.14/docs/ru/camera_frame.md) (Russian only) for older images.
> **Note** The following applies to [image version](image.md) **0.20** and up. See [previous version of the article](https://github.com/CopterExpress/clover/blob/v0.19/docs/en/camera_frame.md) for older images.
Computer vision modules (like [ArUco markers](aruco.md) and [Optical Flow](optical_flow.md)) require adjusting the camera focus and set up camera position and orientation relative to the drone body.
Computer vision modules (like [ArUco markers](aruco.md) and [Optical Flow](optical_flow.md)) require adjusting the camera focus and set up camera position and orientation relative to the drone body. Optional camera calibration can improve their quality of performance.
## Focusing the camera lens
## Focusing the camera lens {#focus}
In order to focus the camera lens, do the following:
@@ -19,10 +19,71 @@ In order to focus the camera lens, do the following:
## Setting the camera position {#frame}
Position and orientation of the main camera is [set in the](cli.md#editing) `~/catkin_ws/src/clever/clever/launch/main_camera.launch` file:
Position and orientation of the main camera is [set in the](cli.md#editing) `~/catkin_ws/src/clover/clover/launch/main_camera.launch` file:
```xml
<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0 0 -0.07 -1.5707963 0 3.1415926 base_link main_camera_optical"/>
<arg name="direction_z" default="down"/> <!-- direction the camera points: down, up -->
<arg name="direction_y" default="backward"/> <!-- direction the camera cable points: backward, forward -->
```
To set the orientation, define:
* direction the camera lens points `direction_z`: `down` or `up`;
* direction the camera cable points `direction_y`: `backward` or `forward`.
### Examples
### Camera faces downward, cable goes backward
```xml
<arg name="direction_z" default="down"/>
<arg name="direction_y" default="backward"/>
```
<img src="../assets/camera_option_1_rviz.png" width=300>
<img src="../assets/camera_option_1_clever.jpg" width=300>
### Camera faces downward, cable goes forward
```xml
<arg name="direction_z" default="down"/>
<arg name="direction_y" default="forward"/>
```
<img src="../assets/camera_option_2_rviz.png" width=300>
<img src="../assets/camera_option_2_clever.jpg" width=300>
### Camera faces upward, cable goes backward
```xml
<arg name="direction_z" default="up"/>
<arg name="direction_y" default="backward"/>
```
<img src="../assets/camera_option_3_rviz.png" width=300>
<img src="../assets/camera_option_3_clever.jpg" width=300>
### Camera faces upward, cable goes forward
```xml
<arg name="direction_z" default="up"/>
<arg name="direction_y" default="forward"/>
```
<img src="../assets/camera_option_4_rviz.png" width=300>
<img src="../assets/camera_option_4_clever.jpg" width=300>
> **Hint** The [`selfcheck.py` utility](selfcheck.md) will describe your current camera setup in a human-readable fashion. Be sure to check whether this description corresponds to your actual camera position.
### Custom camera position
It's possible to set arbitrary camera position and orientation. In order to do that uncomment node, marked as `Template for custom camera orientation`:
```xml
<!-- Template for custom camera orientation -->
<!-- Camera position and orientation are represented by base_link -> main_camera_optical transform -->
<!-- static_transform_publisher arguments: x y z yaw pitch roll frame_id child_frame_id -->
<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0.05 0 -0.07 -1.5707963 0 3.1415926 base_link main_camera_optical"/>
```
This line describes how the camera is positioned relative to the drone body. Technically, it creates a static transform between the `base_link` frame ( which [corresponds to the flight controller housing](frames.md)) and the camera (`main_camera_optical`) in the following format:
@@ -39,44 +100,6 @@ Camera frame (that is, [frame of reference](frames.md)) is aligned as follows:
Shifts are set in meters, angles are in radians. You can check the transform for correctness using [rviz](rviz.md).
## Presets for Clover
## Calibration {#calibration}
The presets for usual camera orientations are available in the `main_camera.launch` file. The images should help you choose the one that is right for you: the first one is how your drone will be displayed in [rviz](rviz.md), the second is how the camera is actually mounted on the drone.
### 1. Camera faces downward, cable goes backward
```xml
<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0.05 0 -0.07 -1.5707963 0 3.1415926 base_link main_camera_optical"/>
```
<img src="../assets/camera_option_1_rviz.png" width=400>
<img src="../assets/camera_option_1_clever.jpg" width=400>
### 2. Camera faces downward, cable goes forward
```xml
<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0.05 0 -0.07 1.5707963 0 3.1415926 base_link main_camera_optical"/>
```
<img src="../assets/camera_option_2_rviz.png" width=400>
<img src="../assets/camera_option_2_clever.jpg" width=400>
### 3. Camera faces upward, cable goes backward
```xml
<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0.05 0 0.07 1.5707963 0 0 base_link main_camera_optical"/>
```
<img src="../assets/camera_option_3_rviz.png" width=400>
<img src="../assets/camera_option_3_clever.jpg" width=400>
### 4. Camera faces upward, cable goes forward
```xml
<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0.05 0 0.07 -1.5707963 0 0 base_link main_camera_optical"/>
```
<img src="../assets/camera_option_4_rviz.png" width=400>
<img src="../assets/camera_option_4_clever.jpg" width=400>
> **Hint** The [`selfcheck.py` utility](selfcheck.md) will describe your current camera setup in a human-readable fashion. Be sure to check whether this description corresponds to your actual camera position.
To improve the quality of computer vision related algorithms it's recommended to perform camera calibration, which is described in the [appropriate article](camera_calibration.md).

View File

@@ -1,10 +1,10 @@
# Настройка камеры
> **Note** Документация для версий [образа](image.md), начиная с **0.15**. Для более ранних версий см. [документацию для версии **0.14**](https://github.com/CopterExpress/clover/blob/v0.14/docs/ru/camera_frame.md).
> **Note** Документация для версий [образа](image.md), начиная с **0.20**. Для более ранних версий см. [документацию для версии **0.19**](https://github.com/CopterExpress/clover/blob/v0.19/docs/ru/camera_frame.md).
Для корректной работы всех модулей, связанных с компьютерным зрением (в том числе [полет по ArUco-маркерам](aruco.md) и [Optical Flow](optical_flow.md)) необходимо сфокусировать основную камеру, а также выставить ее расположение и ориентацию.
Для корректной работы всех функций, связанных с компьютерным зрением (в том числе [полета по ArUco-маркерам](aruco.md) и [Optical Flow](optical_flow.md)) необходимо сфокусировать основную камеру, а также выставить ее расположение и ориентацию. Улучшить качество работы также может опциональная калибровка камеры.
## Настройка фокуса камеры
## Настройка фокуса камеры {#focus}
Для успешного осуществления полетов с использованием камеры, необходимо настроить фокус камеры.
@@ -19,10 +19,71 @@
## Настройка расположения камеры {#frame}
Расположение и ориентация камеры [задается в файле](cli.md#editing) `~/catkin_ws/src/clever/clever/launch/main_camera.launch`:
Расположение и ориентация камеры [задается в файле](cli.md#editing) `~/catkin_ws/src/clover/clover/launch/main_camera.launch`:
```xml
<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0 0 -0.07 -1.5707963 0 3.1415926 base_link main_camera_optical"/>
<arg name="direction_z" default="down"/> <!-- direction the camera points: down, up -->
<arg name="direction_y" default="backward"/> <!-- direction the camera cable points: backward, forward -->
```
Для того, чтобы задать ориентацию, необходимо установить:
* направление обзора камеры `direction_z`: вниз (`down`) или вверх (`up`);
* направление, в которое указывает шлейф камеры `direction_y`: назад (`backward`) или вперед (`forward`).
### Примеры
#### Камера направлена вниз, шлейф назад
```xml
<arg name="direction_z" default="down"/>
<arg name="direction_y" default="backward"/>
```
<img src="../assets/camera_option_1_rviz.png" width=300>
<img src="../assets/camera_option_1_clever.jpg" width=300>
#### Камера направлена вниз, шлейф вперёд
```xml
<arg name="direction_z" default="down"/>
<arg name="direction_y" default="forward"/>
```
<img src="../assets/camera_option_2_rviz.png" width=300>
<img src="../assets/camera_option_2_clever.jpg" width=300>
#### Камера направлена вверх, шлейф назад
```xml
<arg name="direction_z" default="up"/>
<arg name="direction_y" default="backward"/>
```
<img src="../assets/camera_option_3_rviz.png" width=300>
<img src="../assets/camera_option_3_clever.jpg" width=300>
#### Камера направлена вверх, шлейф вперёд
```xml
<arg name="direction_z" default="down"/>
<arg name="direction_y" default="forward"/>
```
<img src="../assets/camera_option_4_rviz.png" width=300>
<img src="../assets/camera_option_4_clever.jpg" width=300>
> **Hint** [Утилита `selfcheck.py`](selfcheck.md) выдает словесное описание установленной в данной момент ориентации основной камеры.
### Произвольное расположение камеры
Также возможно произвольное расположение и ориентации камеры. Для этого раскомментируйте запуск ноды, подписанной как `Template for custom camera orientation`:
```xml
<!-- Template for custom camera orientation -->
<!-- Camera position and orientation are represented by base_link -> main_camera_optical transform -->
<!-- static_transform_publisher arguments: x y z yaw pitch roll frame_id child_frame_id -->
<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0.05 0 -0.07 -1.5707963 0 3.1415926 base_link main_camera_optical"/>
```
Эта строка задает статическую трансформацию между фреймом `base_link` ([соответствует корпусу полетного контроллера](frames.md)) и камерой (`main_camera_optical`) в формате:
@@ -39,48 +100,6 @@
Сдвиги задаются в метрах, углы задаются в радианах. Корректность установленной трансформации может быть проверена с использованием [rviz](rviz.md).
### Настройки для Клевера
## Калибровка {#calibration}
Первое изображение как выглядит модель коптера в rviz при указанных настройках, второе как выглядит Клевер при тех же настройках.
#### 1. Камера направлена вниз, шлейф назад
```xml
<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0.05 0 -0.07 -1.5707963 0 3.1415926 base_link main_camera_optical"/>
```
<img src="../assets/camera_option_1_rviz.png" width=400>
<img src="../assets/camera_option_1_clever.jpg" width=400>
#### 2. Камера направлена вниз, шлейф вперёд
```xml
<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0.05 0 -0.07 1.5707963 0 3.1415926 base_link main_camera_optical"/>
```
<img src="../assets/camera_option_2_rviz.png" width=400>
<img src="../assets/camera_option_2_clever.jpg" width=400>
#### 3. Камера направлена вверх, шлейф назад
```xml
<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0.05 0 0.07 1.5707963 0 0 base_link main_camera_optical"/>
```
<img src="../assets/camera_option_3_rviz.png" width=400>
<img src="../assets/camera_option_3_clever.jpg" width=400>
#### 4. Камера направлена вверх, шлейф вперёд
```xml
<node pkg="tf2_ros" type="static_transform_publisher" name="main_camera_frame" args="0.05 0 0.07 -1.5707963 0 0 base_link main_camera_optical"/>
```
<img src="../assets/camera_option_4_rviz.png" width=400>
<img src="../assets/camera_option_4_clever.jpg" width=400>
> **Hint** [Утилита `selfcheck.py`](selfcheck.md) выдает словесное описание установленной в данной момент ориентации основной камеры.
## Калибровка
Для улучшение качества работы алгоритмов также рекомендуется произвести калибровку камеры, процесс которой описан [в отдельной статье](camera_calibration.md).
Для улучшения качества работы алгоритмов также рекомендуется произвести калибровку камеры, процесс которой описан [в отдельной статье](camera_calibration.md).