mirror of
https://github.com/CopterExpress/clover.git
synced 2026-05-26 11:43:25 +00:00
docs: update snippet flip code
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user