import socket
import struct
from pymavlink import mavutil
# 连接到Pixhawk
connection_string = '/dev/ttyS0' # 替换为你的Pixhawk连接串口
mav_conn = mavutil.mavlink_connection(connection_string)
# 创建一个心跳消息
heartbeat = mavlink.mavlink.MAVLink_heartbeat_message_t()
heartbeat.type = mavlink.MAV_TYPE_GCS
heartbeat.autopilot = mavlink.MAV_AUTOPILOT_INVALID
# 发送心跳消息
mav_conn.mav.send(mav_conn.mavtype, heartbeat)
# 循环发送消息
while True:
# 更新心跳计时器,或者发送其他期望的消息
pass
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交