diff --git a/docs/en/aruco_marker.md b/docs/en/aruco_marker.md index f2208f25..4fec4958 100644 --- a/docs/en/aruco_marker.md +++ b/docs/en/aruco_marker.md @@ -72,12 +72,6 @@ Sample code to fly to a point 1 metre to the left and 2 metres above marker with navigate(frame_id='aruco_7', x=-1, y=0, z=2) ``` -Sample code to rotate counterclockwise while hovering 1.5 metres above marker id 10: - -```python -navigate(frame_id='aruco_10', x=0, y=0, z=1.5, yaw_rate=0.5) -``` - Note that if the required marker isn't detected for 0.5 seconds after the `navigate` command, the command will be ignored. These frames may also be used in other services that accept TF frames (like `get_telemetry`). The following code will get the drone's position relative to the marker with id 3: diff --git a/docs/en/simple_offboard.md b/docs/en/simple_offboard.md index de0a8186..4fcf855c 100644 --- a/docs/en/simple_offboard.md +++ b/docs/en/simple_offboard.md @@ -1,5 +1,7 @@ # Autonomous flight +> **Note** The following applies to [image versions](image.md) **0.24** and up. Older documentation is still available for [for version **0.23**](https://github.com/CopterExpress/clover/blob/v0.23/docs/en/simple_offboard.md). + The `simple_offboard` module of the `clover` package is intended for simplified programming of the autonomous drone flight (`OFFBOARD` [flight mode](modes.md)). It allows setting the desired flight tasks, and automatically transforms [coordinates between frames](frames.md). `simple_offboard` is a high level system for interacting with the flight controller. For a more low level system, see [mavros](mavros.md). @@ -20,6 +22,9 @@ rospy.init_node('flight') # 'flight' is name of your ROS node get_telemetry = rospy.ServiceProxy('get_telemetry', srv.GetTelemetry) navigate = rospy.ServiceProxy('navigate', srv.Navigate) navigate_global = rospy.ServiceProxy('navigate_global', srv.NavigateGlobal) +set_altitude = rospy.ServiceProxy('set_altitude', srv.SetAltitude) +set_yaw = rospy.ServiceProxy('set_yaw', srv.SetYaw) +set_yaw_rate = rospy.ServiceProxy('set_yaw_rate', srv.SetYawRate) set_position = rospy.ServiceProxy('set_position', srv.SetPosition) set_velocity = rospy.ServiceProxy('set_velocity', srv.SetVelocity) set_attitude = rospy.ServiceProxy('set_attitude', srv.SetAttitude) @@ -100,7 +105,6 @@ Parameters: * `x`, `y`, `z` — coordinates *(m)*; * `yaw` — yaw angle *(radians)*; -* `yaw_rate` – angular yaw velocity (will be used if yaw is set to `NaN`) *(rad/s)*; * `speed` – flight speed (setpoint speed) *(m/s)*; * `auto_arm` – switch the drone to `OFFBOARD` mode and arm automatically (**the drone will take off**); * `frame_id` – [coordinate system](frames.md) for values `x`, `y`, `z` and `yaw`. Example: `map`, `body`, `aruco_map`. Default value: `map`. @@ -119,7 +123,7 @@ Flying in a straight line to point 5:0 (altitude 2) in the local system of coord navigate(x=5, y=0, z=3, speed=0.8) ``` -Flying to point 5:0 without changing the yaw angle (`yaw` = `NaN`, `yaw_rate` = 0): +Flying to point 5:0 without changing the yaw angle: ```python navigate(x=5, y=0, z=3, speed=0.8, yaw=float('nan')) @@ -149,22 +153,10 @@ Flying to point 3:2 (with the altitude of 2 m) in the [ArUco map](aruco.md) coor navigate(x=3, y=2, z=2, speed=1, frame_id='aruco_map') ``` -Rotating on the spot at the speed of 0.5 rad/s (counterclockwise): - -```python -navigate(x=0, y=0, z=0, yaw=float('nan'), yaw_rate=0.5, frame_id='body') -``` - -Flying 3 meters forwards at the speed of 0.5 m/s, yaw-rotating at the speed of 0.2 rad/s: - -```python -navigate(x=3, y=0, z=0, speed=0.5, yaw=float('nan'), yaw_rate=0.2, frame_id='body') -``` - Ascending to the altitude of 2 m (command line): ```(bash) -rosservice call /navigate "{x: 0.0, y: 0.0, z: 2, yaw: 0.0, yaw_rate: 0.0, speed: 0.5, frame_id: 'body', auto_arm: true}" +rosservice call /navigate "{x: 0.0, y: 0.0, z: 2, yaw: 0.0, speed: 0.5, frame_id: 'body', auto_arm: true}" ``` > **Note** Consider using the `navigate_target` frame instead of `body` for missions that primarily use relative movements forward/back/left/right. This negates inaccuracies in relative point calculations. @@ -178,7 +170,6 @@ Parameters: * `lat`, `lon` — latitude and longitude *(degrees)*; * `z` — altitude *(m)*; * `yaw` — yaw angle *(radians)*; -* `yaw_rate` – angular yaw velocity (used for setting the yaw to `NaN`) *(rad/s)*; * `speed` – flight speed (setpoint speed) *(m/s)*; * `auto_arm` – switch the drone to `OFFBOARD` and arm automatically (**the drone will take off**); * `frame_id` – [coordinate system](frames.md) for `z` and `yaw` (Default value: `map`). @@ -191,7 +182,7 @@ Flying to a global point at the speed of 5 m/s, while maintaining current altitu navigate_global(lat=55.707033, lon=37.725010, z=0, speed=5, frame_id='body') ``` -Flying to a global point without changing the yaw angle (`yaw` = `NaN`, `yaw_rate` = 0): +Flying to a global point without changing the yaw angle: ```python navigate_global(lat=55.707033, lon=37.725010, z=0, speed=5, yaw=float('nan'), frame_id='body') @@ -200,7 +191,71 @@ navigate_global(lat=55.707033, lon=37.725010, z=0, speed=5, yaw=float('nan'), fr Flying to a global point (command line): ```bash -rosservice call /navigate_global "{lat: 55.707033, lon: 37.725010, z: 0.0, yaw: 0.0, yaw_rate: 0.0, speed: 5.0, frame_id: 'body', auto_arm: false}" +rosservice call /navigate_global "{lat: 55.707033, lon: 37.725010, z: 0.0, yaw: 0.0, speed: 5.0, frame_id: 'body', auto_arm: false}" +``` + +### set_altitude + +Change the desired flight altitude. The service is used to set the altitude and its coordinate system independently, after calling [`navigate`](#navigate) or [`set_position`](#setposition). + +Parameters: + +* `z` – flight altitude *(m)*; +* `frame_id` – [coordinate system](frames.md) for computing the altitude. + +Set the desired altitude to 2 m relative to the floor: + +```python +set_altitude(z=2, frame_id='terrain') +``` + +Set the desired altitude to 1 m relative to [the ArUco map](aruco.md): + +```python +set_altitude(z=1, frame_id='aruco_map') +``` + +### set_yaw + +Change the desired yaw angle (and its coordinate system), keeping the previous command in effect. + +Parameters: + +* `yaw` — yaw angle *(radians)*; +* `frame_id` – [coordinate system](frames.md) for computing the yaw. + +Rotate by 90 degrees clockwise (the previous command continues): + +```python +set_yaw(yaw=math.radians(-90), frame_id='body') +``` + +Set the desired yaw angle to zero relative to [the ArUco map](aruco.md): + +```python +set_yaw(yaw=0, frame_id='aruco_map') +``` + +Stop yaw rotation (caused by [`set_yaw_rate`](#setyawrate) call): + +```python +set_yaw(yaw=float('nan')) +``` + +### set_yaw_rate + +The the desired angular yaw velocity, keeping the previous command in effect. + +Parameters: + +* `yaw_rate` – angular yaw velocity *(rad/s)*; + +The positive direction of `yaw_rate` rotation (when viewed from the top) is counterclockwise. + +Start yaw rotation at 0.5 rad/s (the previous command continues): + +```python +set_yaw_rate(yaw_rate=0.5) ``` ### set_position @@ -213,7 +268,6 @@ Parameters: * `x`, `y`, `z` — point coordinates *(m)*; * `yaw` — yaw angle *(radians)*; -* `yaw_rate` – angular yaw velocity (used for setting the yaw to NaN) *(rad/s)*; * `auto_arm` – switch the drone to `OFFBOARD` and arm automatically (**the drone will take off**); * `frame_id` – [coordinate system](frames.md) for `x`, `y`, `z` and `yaw` parameters (Default value: `map`). @@ -235,19 +289,12 @@ Assigning the target point 1 m ahead of the current position: set_position(x=1, y=0, z=0, frame_id='body') ``` -Rotating on the spot at the speed of 0.5 rad/s: - -```python -set_position(x=0, y=0, z=0, frame_id='body', yaw=float('nan'), yaw_rate=0.5) -``` - ### set_velocity Set speed and yaw setpoints. * `vx`, `vy`, `vz` – flight speed *(m/s)*; * `yaw` — yaw angle *(radians)*; -* `yaw_rate` – angular yaw velocity (used for setting the yaw to NaN) *(rad/s)*; * `auto_arm` – switch the drone to `OFFBOARD` and arm automatically (**the drone will take off**); * `frame_id` – [coordinate system](frames.md) for `vx`, `vy`, `vz` and `yaw` (Default value: `map`). @@ -280,7 +327,7 @@ Parameters: * `thrust` — throttle level, ranges from 0 (no throttle, propellers are stopped) to 1 (full throttle). * `auto_arm` – switch the drone to `OFFBOARD` and arm automatically (**the drone will take off**); -The positive direction of `yaw_rate` rotation (when viewed from the top) is counterclockwise,`pitch_rate` rotation is forward, `roll_rate` rotation is to the left. +The positive direction of `yaw_rate` rotation (when viewed from the top) is counterclockwise, `pitch_rate` rotation is forward, `roll_rate` rotation is to the left. ### land diff --git a/docs/ru/aruco_marker.md b/docs/ru/aruco_marker.md index d7599544..d8f7d5cd 100644 --- a/docs/ru/aruco_marker.md +++ b/docs/ru/aruco_marker.md @@ -84,12 +84,6 @@ navigate(frame_id='aruco_5', x=0, y=0, z=1) navigate(frame_id='aruco_7', x=-1, y=0, z=2) ``` -Вращаться против часовой стрелки на высоте 1.5 метра над маркером 10: - -```python -navigate(frame_id='aruco_10', x=0, y=0, z=1.5, yaw_rate=0.5) -``` - Если необходимый маркер не появится в поле зрения в течение полусекунды, дрон продолжит выполнять предыдущую команду. Подобные значения `frame_id` можно использовать и в других сервисах, например `get_telemetry`. Получение расположения дрона относительно маркера 3: diff --git a/docs/ru/simple_offboard.md b/docs/ru/simple_offboard.md index 36a948d9..e48fc5e9 100644 --- a/docs/ru/simple_offboard.md +++ b/docs/ru/simple_offboard.md @@ -1,5 +1,7 @@ # Автономный полет +> **Note** Документация для версий [образа](image.md), начиная с версии **0.24**. Для более ранних версий см. [документацию для версии **0.23**](https://github.com/CopterExpress/clover/blob/v0.23/docs/ru/simple_offboard.md). + Модуль `simple_offboard` пакета `clover` предназначен для упрощенного программирования автономного полета дрона ([режим](modes.md) `OFFBOARD`). Он позволяет устанавливать желаемые полетные задачи и автоматически трансформирует [систему координат](frames.md). `simple_offboard` является высокоуровневым способом взаимодействия с полетным контроллером. Для более низкоуровневой работы см. [mavros](mavros.md). @@ -20,6 +22,9 @@ rospy.init_node('flight') get_telemetry = rospy.ServiceProxy('get_telemetry', srv.GetTelemetry) navigate = rospy.ServiceProxy('navigate', srv.Navigate) navigate_global = rospy.ServiceProxy('navigate_global', srv.NavigateGlobal) +set_altitude = rospy.ServiceProxy('set_altitude', srv.SetAltitude) +set_yaw = rospy.ServiceProxy('set_yaw', srv.SetYaw) +set_yaw_rate = rospy.ServiceProxy('set_yaw_rate', srv.SetYawRate) set_position = rospy.ServiceProxy('set_position', srv.SetPosition) set_velocity = rospy.ServiceProxy('set_velocity', srv.SetVelocity) set_attitude = rospy.ServiceProxy('set_attitude', srv.SetAttitude) @@ -100,7 +105,6 @@ rosservice call /get_telemetry "{frame_id: ''}" * `x`, `y`, `z` – координаты *(м)*; * `yaw` – угол по рысканью *(радианы)*; -* `yaw_rate` – угловая скорость по рысканью (применяется при установке yaw в `NaN`) *(рад/с)*; * `speed` – скорость полета (скорость движения setpoint) *(м/с)*; * `auto_arm` – перевести коптер в `OFFBOARD` и заармить автоматически (**коптер взлетит**); * `frame_id` – [система координат](frames.md), в которой заданы `x`, `y`, `z` и `yaw` (по умолчанию: `map`). @@ -119,7 +123,7 @@ navigate(x=0, y=0, z=1.5, speed=0.5, frame_id='body', auto_arm=True) navigate(x=5, y=0, z=3, speed=0.8) ``` -Полет в точку 5:0 без изменения угла по рысканью (`yaw` = `NaN`, `yaw_rate` = 0): +Полет в точку 5:0 без изменения угла по рысканью: ```python navigate(x=5, y=0, z=3, speed=0.8, yaw=float('nan')) @@ -149,22 +153,10 @@ navigate(yaw=math.radians(-90), frame_id='body') navigate(x=3, y=2, z=2, speed=1, frame_id='aruco_map') ``` -Вращение на месте со скоростью 0.5 рад/c (против часовой): - -```python -navigate(x=0, y=0, z=0, yaw=float('nan'), yaw_rate=0.5, frame_id='body') -``` - -Полет вперед 3 метра со скоростью 0.5 м/с, вращаясь по рысканью со скоростью 0.2 рад/с: - -```python -navigate(x=3, y=0, z=0, speed=0.5, yaw=float('nan'), yaw_rate=0.2, frame_id='body') -``` - Взлет на высоту 2 м (командная строка): ```bash -rosservice call /navigate "{x: 0.0, y: 0.0, z: 2, yaw: 0.0, yaw_rate: 0.0, speed: 0.5, frame_id: 'body', auto_arm: true}" +rosservice call /navigate "{x: 0.0, y: 0.0, z: 2, yaw: 0.0, speed: 0.5, frame_id: 'body', auto_arm: true}" ``` > **Note** При программировании миссии дрона в терминах "вперед-назад-влево-вправо" рекомендуется использовать систему координат `navigate_target` вместо `body`, чтобы не учитывать неточность прилета дрона в предыдущую целевую точку при вычислении следующей. @@ -178,12 +170,11 @@ rosservice call /navigate "{x: 0.0, y: 0.0, z: 2, yaw: 0.0, yaw_rate: 0.0, speed * `lat`, `lon` – широта и долгота *(градусы)*; * `z` – высота *(м)*; * `yaw` – угол по рысканью *(радианы)*; -* `yaw_rate` – угловая скорость по рысканью (при установке yaw в `NaN`) *(рад/с)*; * `speed` – скорость полета (скорость движения setpoint) *(м/с)*; * `auto_arm` – перевести коптер в `OFFBOARD` и заармить автоматически (**коптер взлетит**); * `frame_id` – [система координат](frames.md), в которой заданы `z` и `yaw` (по умолчанию: `map`). -> **Note** Для полета без изменения угла по рысканью достаточно установить `yaw` в `NaN` (значение угловой скорости по умолчанию – 0). +> **Note** Для полета без изменения угла по рысканью достаточно установить `yaw` в `NaN`. Полет в глобальную точку со скоростью 5 м/с, оставаясь на текущей высоте (`yaw` установится в 0, коптер сориентируется передом на восток): @@ -191,7 +182,7 @@ rosservice call /navigate "{x: 0.0, y: 0.0, z: 2, yaw: 0.0, yaw_rate: 0.0, speed navigate_global(lat=55.707033, lon=37.725010, z=0, speed=5, frame_id='body') ``` -Полет в глобальную точку без изменения угла по рысканью (`yaw` = `NaN`, `yaw_rate` = 0): +Полет в глобальную точку без изменения угла по рысканью: ```python navigate_global(lat=55.707033, lon=37.725010, z=0, speed=5, yaw=float('nan'), frame_id='body') @@ -200,7 +191,71 @@ navigate_global(lat=55.707033, lon=37.725010, z=0, speed=5, yaw=float('nan'), fr Полет в глобальную точку (командная строка): ```bash -rosservice call /navigate_global "{lat: 55.707033, lon: 37.725010, z: 0.0, yaw: 0.0, yaw_rate: 0.0, speed: 5.0, frame_id: 'body', auto_arm: false}" +rosservice call /navigate_global "{lat: 55.707033, lon: 37.725010, z: 0.0, yaw: 0.0, speed: 5.0, frame_id: 'body', auto_arm: false}" +``` + +### set_altitude + +Изменить целевую высоту полета. Сервис используется для независимой установки высоты (и системы координат для расчета высота) в режимах полета [`navigate`](#navigate) и [`set_position`](#setposition). + +Параметры: + +* `z` – высота полета *(м)*; +* `frame_id` – [система координат](frames.md) для расчета высоты полета. + +Установить высоту полета в 2 м относительно пола: + +```python +set_altitude(z=2, frame_id='terrain') +``` + +Установить высоту полета в 1 м относительно [маркерного поля](aruco.md): + +```python +set_altitude(z=1, frame_id='aruco_map') +``` + +### set_yaw + +Изменить целевой угол по рысканью (и систему координат для его расчета), оставив предыдущую команду в силе. + +Параметры: + +* yaw – угол по рысканью *(радианы)*; +* frame_id – [система координат](frames.md) для расчета угла по рысканью. + +Повернуться на 90 градусов по часовой (продолжая выполнять предыдущую команду): + +```python +set_yaw(yaw=math.radians(-90), frame_id='body') +``` + +Установить угол по рысканью в ноль в системе координат [маркерного поля](aruco.md): + +```python +set_yaw(yaw=0, frame_id='aruco_map') +``` + +Остановить вращение по рысканью (при использовании [`set_yaw_rate`](#setyawrate)): + +```python +set_yaw(yaw=float('nan')) +``` + +### set_yaw_rate + +Изменить целевую угловую скорость по рысканью, оставив предыдущую команду в силе. + +Параметры: + +* yaw_rate – угловая скорость по рысканью *(рад/с)*. + +Положительное направление вращения (при виде сверху) – против часовой. + +Начать вращение на месте со скоростью 0.5 рад/c против часовой (продолжая выполнять предыдущую команду): + +```python +set_yaw_rate(yaw_rate=0.5) ``` ### set_position @@ -213,7 +268,6 @@ rosservice call /navigate_global "{lat: 55.707033, lon: 37.725010, z: 0.0, yaw: * `x`, `y`, `z` – координаты точки *(м)*; * `yaw` – угол по рысканью *(радианы)*; -* `yaw_rate` – угловая скорость по рысканью (при установке yaw в NaN) *(рад/с)*; * `auto_arm` – перевести коптер в `OFFBOARD` и заармить автоматически (**коптер взлетит**); * `frame_id` – [система координат](frames.md), в которой заданы `x`, `y`, `z` и `yaw` (по умолчанию: `map`). @@ -235,19 +289,12 @@ set_position(x=0, y=0, z=3, frame_id='body') set_position(x=1, y=0, z=0, frame_id='body') ``` -Вращение на месте со скоростью 0.5 рад/c: - -```python -set_position(x=0, y=0, z=0, frame_id='body', yaw=float('nan'), yaw_rate=0.5) -``` - ### set_velocity Установить скорости и рысканье. * `vx`, `vy`, `vz` – требуемая скорость полета *(м/с)*; * `yaw` – угол по рысканью *(радианы)*; -* `yaw_rate` – угловая скорость по рысканью (при установке yaw в NaN) *(рад/с)*; * `auto_arm` – перевести коптер в `OFFBOARD` и заармить автоматически (**коптер взлетит**); * `frame_id` – [система координат](frames.md), в которой заданы `vx`, `vy`, `vz` и `yaw` (по умолчанию: `map`).