docs: add wait_arrival snippet

This commit is contained in:
Oleg Kalachev
2020-08-21 22:08:07 +03:00
parent 423490304b
commit a62107132d
2 changed files with 42 additions and 0 deletions

View File

@@ -13,6 +13,10 @@ Python
Flying towards a point and waiting for copter's arrival:
```python
import math
#...
def navigate_wait(x=0, y=0, z=0, yaw=float('nan'), speed=0.5, frame_id='', auto_arm=False, tolerance=0.2):
navigate(x=x, y=y, z=z, yaw=yaw, speed=speed, frame_id=frame_id, auto_arm=auto_arm)
@@ -55,6 +59,23 @@ Usage:
land_wait()
```
### # {#wait_arrival}
Wait for copter's arrival to the [navigate](simple_offboard.md#navigate) target:
```python
import math
# ...
def wait_arrival(tolerance=0.2):
while not rospy.is_shutdown():
telem = get_telemetry(frame_id='navigate_target')
if math.sqrt(telem.x ** 2 + telem.y ** 2 + telem.z ** 2) < tolerance:
break
rospy.sleep(0.2)
```
### # {#get_distance}
Calculating the distance between two points (**important**: the points are to be in the same [system of coordinates](frames.md)):

View File

@@ -22,6 +22,10 @@ Python
Полет в точку и ожидание окончания полета:
```python
import math
# ...
def navigate_wait(x=0, y=0, z=0, yaw=float('nan'), speed=0.5, frame_id='', auto_arm=False, tolerance=0.2):
navigate(x=x, y=y, z=z, yaw=yaw, speed=speed, frame_id=frame_id, auto_arm=auto_arm)
@@ -65,6 +69,23 @@ def land_wait():
land_wait()
```
### # {#wait_arrival}
Ожидание окончания прилета в [navigate](simple_offboard.md#navigate)-точку:
```python
import math
# ...
def wait_arrival(tolerance=0.2):
while not rospy.is_shutdown():
telem = get_telemetry(frame_id='navigate_target')
if math.sqrt(telem.x ** 2 + telem.y ** 2 + telem.z ** 2) < tolerance:
break
rospy.sleep(0.2)
```
### # {#get_distance}
Функция определения расстояния между двумя точками (**важно**: точки должны быть в одной [системе координат](frames.md)):