diff --git a/docs/en/snippets.md b/docs/en/snippets.md index 4d0ba842..ef3e2078 100644 --- a/docs/en/snippets.md +++ b/docs/en/snippets.md @@ -45,6 +45,20 @@ while True: rospy.sleep(0.2) ``` +This code can be wrapped in a function: + +```python +def takeoff_wait(alt, speed=0.5, tolerance=0.2): + start = get_telemetry() + print navigate(z=alt, speed=speed, frame_id='body', auto_arm=True) + + while True: + if get_telemetry().z - start.z + z < tolerance: + break + + rospy.sleep(0.2) +``` + ### # {#block-nav} Flying towards a point and waiting for copter's arrival: diff --git a/docs/ru/snippets.md b/docs/ru/snippets.md index bf8f3b75..5dc42700 100644 --- a/docs/ru/snippets.md +++ b/docs/ru/snippets.md @@ -62,6 +62,20 @@ while True: rospy.sleep(0.2) ``` +Вышеприведенный код может быть обернут в функцию: + +```python +def takeoff_wait(alt, speed=0.5, tolerance=0.2): + start = get_telemetry() + print navigate(z=alt, speed=speed, frame_id='body', auto_arm=True) + + while True: + if get_telemetry().z - start.z + z < tolerance: + break + + rospy.sleep(0.2) +``` + ### # {#block-nav} Лететь в точку и ждать пока коптер долетит в нее: