Skip to content

Commit 29146f6

Browse files
committed
Manually arm Crazyflies in all examples
Disarming is automatic after flight.
1 parent 6b4d3ba commit 29146f6

26 files changed

+137
-1
lines changed

examples/aideck/fpv.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import struct
4949
import sys
5050
import threading
51+
from time import time
5152

5253
import numpy as np
5354

@@ -185,6 +186,10 @@ def __init__(self, URI):
185186

186187
self.hover = {'x': 0.0, 'y': 0.0, 'z': 0.0, 'yaw': 0.0, 'height': 0.3}
187188

189+
# Arm the Crazyflie
190+
self.cf.platform.send_arming_request(True)
191+
time.sleep(1.0)
192+
188193
self.hoverTimer = QtCore.QTimer()
189194
self.hoverTimer.timeout.connect(self.sendHoverCommand)
190195
self.hoverTimer.setInterval(100)

examples/autonomy/autonomousSequence.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ def start_position_printing(scf):
127127
def run_sequence(scf, sequence):
128128
cf = scf.cf
129129

130+
# Arm the Crazyflie
131+
cf.platform.send_arming_request(True)
132+
time.sleep(1.0)
133+
130134
for position in sequence:
131135
print('Setting position {}'.format(position))
132136
for i in range(50):

examples/autonomy/autonomous_sequence_high_level.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ def upload_trajectory(cf, trajectory_id, trajectory):
140140
def run_sequence(cf, trajectory_id, duration):
141141
commander = cf.high_level_commander
142142

143+
# Arm the Crazyflie
144+
cf.platform.send_arming_request(True)
145+
time.sleep(1.0)
146+
143147
commander.takeoff(1.0, 2.0)
144148
time.sleep(3.0)
145149
relative = True

examples/autonomy/autonomous_sequence_high_level_compressed.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ def upload_trajectory(cf, trajectory_id, trajectory):
137137
def run_sequence(cf, trajectory_id, duration):
138138
commander = cf.high_level_commander
139139

140+
# Arm the Crazyflie
141+
cf.platform.send_arming_request(True)
142+
time.sleep(1.0)
143+
140144
commander.takeoff(1.0, 2.0)
141145
time.sleep(3.0)
142146
relative = True

examples/autonomy/circling_square_demo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ def turn_off_leds(scf):
162162

163163

164164
def run_sequence(scf, alpha, r):
165+
# Arm the Crazyflie
166+
scf.cf.platform.send_arming_request(True)
167+
time.sleep(1.0)
168+
165169
commander = scf.cf.high_level_commander
166170
trajectory_id = 1
167171
duration = 4*t

examples/autonomy/full_state_setpoint_demo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ def run_sequence(scf):
134134
# Set to mellinger controller
135135
# cf.param.set_value('stabilizer.controller', '2')
136136

137+
# Arm the Crazyflie
138+
cf.platform.send_arming_request(True)
139+
time.sleep(1.0)
140+
137141
print('takeoff')
138142
send_setpoint(cf, 4.0,
139143
[0.0, 0.0, 1.0],

examples/autonomy/motion_commander_demo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
cflib.crtp.init_drivers()
5353

5454
with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
55+
# Arm the Crazyflie
56+
scf.cf.platform.send_arming_request(True)
57+
time.sleep(1.0)
58+
5559
# We take off when the commander is created
5660
with MotionCommander(scf) as mc:
5761
time.sleep(1)

examples/autonomy/position_commander_demo.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
3030
Change the URI variable to your Crazyflie configuration.
3131
"""
32+
from time import time
33+
3234
import cflib.crtp
3335
from cflib.crazyflie import Crazyflie
3436
from cflib.crazyflie.syncCrazyflie import SyncCrazyflie
@@ -41,6 +43,10 @@
4143

4244
def slightly_more_complex_usage():
4345
with SyncCrazyflie(uri, cf=Crazyflie(rw_cache='./cache')) as scf:
46+
# Arm the Crazyflie
47+
scf.cf.platform.send_arming_request(True)
48+
time.sleep(1.0)
49+
4450
with PositionHlCommander(
4551
scf,
4652
x=0.0, y=0.0, z=0.0,
@@ -67,6 +73,10 @@ def slightly_more_complex_usage():
6773

6874
def land_on_elevated_surface():
6975
with SyncCrazyflie(uri, cf=Crazyflie(rw_cache='./cache')) as scf:
76+
# Arm the Crazyflie
77+
scf.cf.platform.send_arming_request(True)
78+
time.sleep(1.0)
79+
7080
with PositionHlCommander(scf,
7181
default_height=0.5,
7282
default_velocity=0.2,
@@ -80,6 +90,10 @@ def land_on_elevated_surface():
8090

8191
def simple_sequence():
8292
with SyncCrazyflie(uri, cf=Crazyflie(rw_cache='./cache')) as scf:
93+
# Arm the Crazyflie
94+
scf.cf.platform.send_arming_request(True)
95+
time.sleep(1.0)
96+
8397
with PositionHlCommander(scf, controller=PositionHlCommander.CONTROLLER_PID) as pc:
8498
pc.forward(1.0)
8599
pc.left(1.0)

examples/lighthouse/lighthouse_openvr_grab.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ def run_sequence(scf):
171171

172172
with SyncCrazyflie(uri, cf=Crazyflie(rw_cache='./cache')) as scf:
173173
reset_estimator(scf)
174+
175+
# Arm the Crazyflie
176+
scf.cf.platform.send_arming_request(True)
177+
time.sleep(1.0)
178+
174179
run_sequence(scf)
175180

176181
openvr.shutdown()

examples/lighthouse/lighthouse_openvr_grab_color.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ def run_sequence(scf):
203203
with SyncCrazyflie(uri, cf=Crazyflie(rw_cache='./cache')) as scf:
204204
reset_estimator(scf)
205205
# start_position_printing(scf)
206+
207+
# Arm the Crazyflie
208+
scf.cf.platform.send_arming_request(True)
209+
time.sleep(1.0)
210+
206211
run_sequence(scf)
207212

208213
openvr.shutdown()

0 commit comments

Comments
 (0)