diff --git a/docs/en/snippets.md b/docs/en/snippets.md index 53173020..236b40bf 100644 --- a/docs/en/snippets.md +++ b/docs/en/snippets.md @@ -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') diff --git a/docs/ru/snippets.md b/docs/ru/snippets.md index f10de819..39a59f0a 100644 --- a/docs/ru/snippets.md +++ b/docs/ru/snippets.md @@ -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')