Skip to content

Commit

Permalink
Merge pull request #522 from bitcraze/Aris/Issues_in_examples
Browse files Browse the repository at this point in the history
Fixed some example issues
  • Loading branch information
ToveRumar authored Feb 19, 2025
2 parents b7ead19 + e17a506 commit 768c58e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
20 changes: 18 additions & 2 deletions examples/autonomy/autonomousSequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
one every 5 seconds.
This example is intended to work with the Loco Positioning System in TWR TOA
mode. It aims at documenting how to set the Crazyflie in position control mode
and how to send setpoints.
mode and with the Lighthouse Positioning System. It aims at documenting how
to set the Crazyflie in position control mode and how to send setpoints.
"""
import time

Expand Down Expand Up @@ -56,6 +56,19 @@
]


def take_off(cf, position):
take_off_time = 1.0
sleep_time = 0.1
steps = int(take_off_time / sleep_time)
vz = position[2] / take_off_time

print(f'take off at {position[2]}')

for i in range(steps):
cf.commander.send_velocity_world_setpoint(0, 0, vz, 0)
time.sleep(sleep_time)


def position_callback(timestamp, data, logconf):
x = data['kalman.stateX']
y = data['kalman.stateY']
Expand All @@ -81,6 +94,9 @@ def run_sequence(scf, sequence):
cf.platform.send_arming_request(True)
time.sleep(1.0)

take_off(cf, sequence[0])
time.sleep(1.0)

for position in sequence:
print('Setting position {}'.format(position))
for i in range(50):
Expand Down
2 changes: 1 addition & 1 deletion examples/autonomy/position_commander_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Change the URI variable to your Crazyflie configuration.
"""
from time import time
import time

import cflib.crtp
from cflib.crazyflie import Crazyflie
Expand Down
2 changes: 1 addition & 1 deletion examples/positioning/flowsequenceSync.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""
Simple example that connects to the crazyflie at `URI` and runs a figure 8
sequence. This script requires some kind of location system, it has been
tested with (and designed for) the flow deck.
tested with the flow deck and the lighthouse positioning system.
Change the URI variable to your Crazyflie configuration.
"""
Expand Down
3 changes: 2 additions & 1 deletion examples/swarm/swarmSequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ def run_sequence(scf, sequence):
try:
cf = scf.cf

arm(cf)
take_off(cf, sequence[0])
for position in sequence:
print('Setting position {}'.format(position))
Expand Down Expand Up @@ -249,4 +248,6 @@ def run_sequence(scf, sequence):
print('Waiting for parameters to be downloaded...')
swarm.parallel(wait_for_param_download)

swarm.parallel(arm)

swarm.parallel(run_sequence, args_dict=seq_args)

0 comments on commit 768c58e

Please sign in to comment.