Hi,i want to now how to use python to restart the crazyflie? i find cflib/utils/power_switch.py,but i don`t know how to use it. it always run error with crazyradio or crtp.
The following is my code:
import time
import cflib.crtp
from cflib.drivers.crazyradio import Crazyradio
from cflib.crazyflie import Crazyflie
from cflib.crazyflie.log import LogConfig
from cflib.crazyflie.syncCrazyflie import SyncCrazyflie
from cflib.crazyflie.syncLogger import SyncLogger
from cflib.utils.power_switch import PowerSwitch
uri = 'radio://0/10/2M/E7E7E7E712'
if __name__ == '__main__':
cflib.crtp.init_drivers(enable_debug_driver=False)
with SyncCrazyflie(uri,cf=Crazyflie(rw_cache='./cache')) as scf:
cf = scf.cf
ps = PowerSwitch(uri)
ps.stm_power_down()
time.sleep(3)
ps.stm_power_up()
time.sleep(3)
Last edited by aqqz on Wed Dec 02, 2020 2:37 am, edited 1 time in total.
tz@ubuntu:~/crazyflie/crazyflie-firmware$ python3 tools/utils/reboot.py radio://0/10/2M/E7E7E7E710
Traceback (most recent call last):
File "tools/utils/reboot.py", line 33, in <module>
PowerSwitch(sys.argv[1]).stm_power_cycle()
File "/home/tz/crazyflie/crazyflie-lib-python/cflib/utils/power_switch.py", line 63, in stm_power_cycle
self.stm_power_down()
File "/home/tz/crazyflie/crazyflie-lib-python/cflib/utils/power_switch.py", line 54, in stm_power_down
self._send(self.BOOTLOADER_CMD_SYSOFF)
File "/home/tz/crazyflie/crazyflie-lib-python/cflib/utils/power_switch.py", line 79, in _send
if res.ack:
AttributeError: 'NoneType' object has no attribute 'ack'
I reinstall my cflib and it prompt I have installed,the function can close crazyflie by not restart it and output error as I gived,i think the PA don`t receive the ack from crazyflie.my test environment is ubuntu 18.04.