-
Notifications
You must be signed in to change notification settings - Fork 928
Description
Description
I am trying to call get_estimated_position in a loop and it stuck after 254 iterations and when I exit the program I got this error.
error:
Traceback (most recent call last): File "/home/ori/crazyflie-lib-python/examples/swarm/hl-commander-swarm.py", line 95, in <module> print(swarm.get_estimated_positions()) File "/home/ori/crazyflie-lib-python/cflib/crazyflie/swarm.py", line 148, in get_estimated_positions self.parallel_safe(self.__get_estimated_position) File "/home/ori/crazyflie-lib-python/cflib/crazyflie/swarm.py", line 278, in parallel_safe thread.join() File "/usr/lib/python3.8/threading.py", line 1011, in join self._wait_for_tstate_lock() File "/usr/lib/python3.8/threading.py", line 1027, in _wait_for_tstate_lock elif lock.acquire(block, timeout): KeyboardInterrupt
Code snippet:
import time
import cflib.crtp
from cflib.crazyflie.swarm import CachedCfFactory
from cflib.crazyflie.swarm import Swarm
def activate_high_level_commander(scf):
scf.cf.param.set_value('commander.enHighLevel', '1')
def activate_mellinger_controller(scf, use_mellinger):
controller = 1
if use_mellinger:
controller = 2
scf.cf.param.set_value('stabilizer.controller', controller)
def run_shared_sequence(scf):
activate_mellinger_controller(scf, False)
box_size = 1
flight_time = 2
commander = scf.cf.high_level_commander
commander.takeoff(1.0, 2.0)
time.sleep(3)
commander.go_to(box_size, 0, 0, 0, flight_time, relative=True)
time.sleep(flight_time)
commander.go_to(0, box_size, 0, 0, flight_time, relative=True)
time.sleep(flight_time)
commander.go_to(-box_size, 0, 0, 0, flight_time, relative=True)
time.sleep(flight_time)
commander.go_to(0, -box_size, 0, 0, flight_time, relative=True)
time.sleep(flight_time)
commander.land(0.0, 2.0)
time.sleep(2)
commander.stop()
uris = {
'radio://0/80/2M/E7E7E7E7E7',
# 'radio://0/30/2M/E7E7E7E712',
# Add more URIs if you want more copters in the swarm
}
if __name__ == '__main__':
cflib.crtp.init_drivers()
factory = CachedCfFactory(rw_cache='./cache')
with Swarm(uris, factory=factory) as swarm:
swarm.parallel_safe(activate_high_level_commander)
swarm.reset_estimators()
# swarm.parallel_safe(run_shared_sequence)
for i in range(1000):
print(i)
print(swarm.get_estimated_positions())