docs: update snippet flip code

This commit is contained in:
Alamoris
2020-01-10 19:34:47 +03:00
parent d8d7839e0e
commit 6739a685d8
2 changed files with 15 additions and 9 deletions

View File

@@ -299,25 +299,28 @@ set_mode(custom_mode='STABILIZED')
### # {#flip}
Flip on roll:
Universal flip:
```python
import math
# ...
PI_2 = math.pi / 2
def flip():
start = get_telemetry() # saving starting position
start = get_telemetry() # memorize starting position
set_rates(thrust=1) # bump up
rospy.sleep(0.2)
set_rates(roll_rate=30, thrust=0.2) # maximum roll rate
set_rates(pitch_rate=30, thrust=0.2) # pitch flip
# set_rates(roll_rate=30, thrust=0.2) # roll flip
while True:
telem = get_telemetry()
if -math.pi + 0.1 < telem.roll < -0.2:
flipped = abs(telem.pitch) > PI_2 or abs(telem.roll) > PI_2
if flipped:
break
rospy.loginfo('finish flip')

View File

@@ -343,25 +343,28 @@ set_mode(custom_mode='STABILIZED')
### # {#flip}
Флип по крену:
Универсальный флип:
```python
import math
# ...
PI_2 = math.pi / 2
def flip():
start = get_telemetry() # memorize starting position
set_rates(thrust=1) # bump up
rospy.sleep(0.2)
set_rates(roll_rate=30, thrust=0.2) # maximum roll rate
set_rates(pitch_rate=30, thrust=0.2) # pitch flip
# set_rates(roll_rate=30, thrust=0.2) # roll flip
while True:
telem = get_telemetry()
if abs(telem.roll) > math.pi/2:
flipped = abs(telem.pitch) > PI_2 or abs(telem.roll) > PI_2
if flipped:
break
rospy.loginfo('finish flip')