MAV_CMD_NAV_RETURN_TO_LAUNCH 20
param1 0为返航 1为取消返航
返回command = MAV_CMD_REQUEST_MESSAGE
返回值 param1 20 执行命令id
返回值 param2 0或1 是否执行成功
返回值 param3 失败代码
失败代码列表
0 无异常
1 无法初始化无人机飞行控制
2 返航失败
3 取消返航失败
python测试脚本
import time
from pymavlink import mavutil
timestamp = int(time.time() * 1000)
millis = int(time.time() * 1000)
master = mavutil.mavlink_connection('udpin:0.0.0.0:14550')
master.wait_heartbeat()
boot_time = time.time()
def return_to_base(cancleReturn):
master.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_NAV_RETURN_TO_LAUNCH,
0,
cancleReturn, 0, 0, 0, 0, 0, 0
)
return_to_base(0)
time.sleep(10)
return_to_base(1)
while True:
msg = master.recv_match()
if not msg:
continue
if msg.get_type() == 'COMMAND_LONG':
print("\n\n*****Got message: %s*****" % msg.get_type())
print("Message: %s" % msg)
print("\nAs dictionary: %s" % msg.to_dict())
作者:bai 创建时间:2024-09-14 16:06
最后编辑:bai 更新时间:2024-11-20 18:11
最后编辑:bai 更新时间:2024-11-20 18:11