LOCO定位系统入门教程-使用python脚本与crazyflie建立联系
说明:
介绍如何使用python脚本与crazyflie建立联系
该脚本与Crazyflie连接、同步,并在几秒钟后断开连接
步骤:
新建一个python脚本connect_log_param.py
代码如下
import logging
import time
import cflib.crtp
from cflib.crazyflie import Crazyflie
from cflib.crazyflie.syncCrazyflie import SyncCrazyflie
# URI to the Crazyflie to connect to
uri = 'radio://0/80/2M/E7E7E7E7E7'
def simple_connect():
print("Yeah, I'm connected! :D")
time.sleep(3)
print("Now I will disconnect :'(")
if __name__ == '__main__':
# Initialize the low-level drivers
cflib.crtp.init_drivers()
with SyncCrazyflie(uri, cf=Crazyflie(rw_cache='./cache')) as scf:
simple_connect()
- 运行脚本
python3 connect_log_param.py
M4 LED会黄色闪烁,说明Crazyflie已连接到脚本。simple_connect()执行结束,M4 LED就会熄灭
结果如下
Yeah, I'm connected! :D
Now I will disconnect :'(
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号