使用Python和Java实现MQTT控制无人机与传感器
一、使用Python通过MQTT控制无人机
在使用Python进行编程时,为了发布控制无人机的命令并检查命令执行结果,编写Python代码是很有必要的。虽然像MQTT.fx这样的GUI工具和Mosquitto命令行工具非常有用,但在确认一切按预期工作后,我们可以使用相同的编程语言编写必要的代码来进行测试。
- Python代码实现
- 定义变量和类
from command import *
from command import *
import paho.mqtt.client as mqtt
import os.path
import time
import json
# Replace /Users/gaston/certificates with the path
# in which you saved the certificate authoritity file,
# the client certificate file and the client key
certificates_path = "/Users/gaston/certificates"
ca_certificate = os.path.join(certificates_path, "ca.crt")
client_certificate = os.path.join(certificates_path, "devic
超级会员免费看
订阅专栏 解锁全文
1019

被折叠的 条评论
为什么被折叠?



