视频流信息
mavlink id 269 VIDEO_STREAM_INFORMATION
关于视频流的信息。

MAV_CMD_VIDEO_START_STREAMING 2502
开始视频流式播放
| Param (:Label) | 描述 | 值 |
|---|---|---|
| param1:(Stream ID) | 要开启的视频流ID | 1:主摄像头,2:下视摄像头,3:红外摄像头 |
返回消息COMMAND_ACK
返回值 command 2502 执行命令id
返回值 result 0或4 0:执行成功,4:执行失败
于QGC控制台输入wideVideo
打开主摄像机视频流
于QGC控制台输入IRVideo
打开主摄像机红外视频流
于QGC控制台输入DownVideo,并将视频流接收端口改为5700
打开下视摄像机视频流
移动 App 图传设置中的“增强传输”状态
ENH_TRANS_STATE
设置
mavlink消息:
接收PARAM_SET
发送PARAM_VALUE
获取
mavlink消息
接收PARAM_REQUEST_READ
发送PARAM_VALUE
参数:
| 名称 | 枚举值 | 描述 |
|---|---|---|
| DJI_ENHANCEED_TRANSMISSION_STATE_DISABLED | 0 | 增强图传功能已禁用 |
| DJI_ENHANCEED_TRANSMISSION_STATE_ENABLED | 3 | 增强图传功能已启用 |
示例
import time
import sys
from pymavlink import mavutil
def connect_to_vehicle():
"""建立 UDP 监听连接(默认监听所有接口的 14550 端口)"""
connection_string = "udpin:0.0.0.0:14550"
print(f"Listening for MAVLink on: {connection_string}")
vehicle = mavutil.mavlink_connection(connection_string)
print("Waiting for HEARTBEAT (timeout: 10s)...")
try:
vehicle.wait_heartbeat(timeout=10)
print(f"✅ Heartbeat received from system {vehicle.target_system}, component {vehicle.target_component}")
return vehicle
except Exception as e:
print(f"❌ Connection failed: {str(e)}")
print("Ensure your vehicle is sending MAVLink messages to 14550 port")
print("Example QGroundControl setup: Settings > General > MAVLink > Listening Port = 14550")
sys.exit(1)
def format_param_id(param_id):
"""格式化16字节参数ID(符合MAVLink协议要求)"""
if len(param_id) > 16:
raise ValueError("param_id cannot exceed 16 characters")
param_id_bytes = bytearray(16)
for i in range(min(len(param_id), 16)):
param_id_bytes[i] = ord(param_id[i])
# 长度<16时添加NULL终止符
if len(param_id) < 16:
param_id_bytes[len(param_id)] = 0
return param_id_bytes
def send_param_set(vehicle, param_id, param_value, param_type):
"""发送参数设置请求"""
vehicle.mav.param_set_send(
vehicle.target_system,
vehicle.target_component,
format_param_id(param_id),
param_value,
param_type
)
print(f"📤 Sent PARAM_SET for '{param_id}' = {param_value} (type: {param_type})")
def send_param_request_read(vehicle, param_id=None, param_index=-1):
"""发送参数读取请求"""
param_id_bytes = format_param_id(param_id) if param_id else bytearray(16)
vehicle.mav.param_request_read_send(
vehicle.target_system,
vehicle.target_component,
param_id_bytes,
param_index
)
target = f"index {param_index}" if param_index >= 0 else f"ID '{param_id}'"
print(f"📤 Sent PARAM_REQUEST_READ for {target}")
def send_param_request_list(vehicle):
"""发送请求所有参数列表"""
vehicle.mav.param_request_list_send(
vehicle.target_system,
vehicle.target_component
)
print(f"📤 Sent PARAM_REQUEST_LIST to system {vehicle.target_system}, component {vehicle.target_component}")
def receive_param_value(vehicle, timeout=5.0):
"""接收参数值响应"""
print(f"⏳ Waiting for PARAM_VALUE ({timeout}s timeout)...")
msg = vehicle.recv_match(type='PARAM_VALUE', blocking=True, timeout=timeout)
if not msg:
print("❌ Timeout: No PARAM_VALUE received")
return None
# 解析参数ID
param_id = msg.param_id
# 解析参数值
param_value = msg.param_value
# 参数类型映射
type_names = {
0: "INT8", 1: "UINT8", 2: "INT16", 3: "UINT16", 4: "INT32",
5: "UINT32", 6: "INT64", 7: "UINT64", 8: "FLOAT", 9: "DOUBLE"
}
param_type = type_names.get(msg.param_type, f"UNKNOWN({msg.param_type})")
print("\n📥 Received PARAM_VALUE:")
print(f" 🆔 ID: {param_id}")
print(f" 🔢 Value: {param_value}")
print(f" 🧾 Type: {param_type}")
print(f" 📊 Index/Total: {msg.param_index}/{msg.param_count}")
return {
'id': param_id,
'value': param_value,
'type': param_type,
'index': msg.param_index,
'count': msg.param_count
}
def receive_all_param_values(vehicle, timeout=10.0):
"""接收所有参数值,直到收到 param_count 条消息后退出循环"""
received_params = []
expected_count = None
print(f"⏳ Waiting for all PARAM_VALUE messages...")
while True:
msg = vehicle.recv_match(type='PARAM_VALUE', blocking=True, timeout=timeout)
if not msg:
print(f"❌ Timeout: Received {len(received_params)} parameters (expected {expected_count if expected_count else 'unknown'})")
break
param_id = msg.param_id
param_value = msg.param_value
# 参数类型映射
type_names = {
0: "INT8", 1: "UINT8", 2: "INT16", 3: "UINT16", 4: "INT32",
5: "UINT32", 6: "INT64", 7: "UINT64", 8: "FLOAT", 9: "DOUBLE"
}
param_type = type_names.get(msg.param_type, f"UNKNOWN({msg.param_type})")
# 首次收到消息时记录总参数数量
if expected_count is None:
expected_count = msg.param_count
print(f"📊 Total parameters to receive: {expected_count}")
print(f" [{msg.param_index}/{expected_count}] {param_id} = {param_value} ({param_type})")
received_params.append({
'id': param_id,
'value': param_value,
'type': param_type,
'index': msg.param_index,
'count': msg.param_count
})
# 当已接收数量达到预期总数时退出循环
if len(received_params) >= expected_count:
print(f"\n✅ Successfully received all {expected_count} parameters")
break
return received_params
def main():
print("🚀 Starting MAVLink PARAM_SET Tool (UDP Listening Mode)")
print("-----------------------------------------------------")
print("This script listens for MAVLink on ALL interfaces:14550")
print("Ensure your vehicle is configured to send to this port")
print("-----------------------------------------------------\n")
vehicle = connect_to_vehicle()
# 操作选择
print("\nAvailable operations:")
print("1. Set parameter value")
print("2. Read parameter value (by ID or index)")
print("3. Request all parameters (PARAM_REQUEST_LIST)")
choice = input("\nSelect operation [1-3]: ").strip()
if choice == '1':
param_id = input("Enter parameter ID to set: ").strip()
param_value = float(input("Enter new value: ").strip())
print("\nParameter types:")
print(" 8 = FLOAT (most common)")
print(" 9 = DOUBLE")
print(" 4 = INT32")
print(" 1 = UINT8")
param_type = int(input("Enter type number [8]: ").strip() or 8)
send_param_set(vehicle, param_id, param_value, param_type)
receive_param_value(vehicle)
elif choice == '2':
# mode = input("Read by [id/index]: ").lower()
mode = 'id'
if mode == 'id':
param_id = input("Enter parameter ID: ").strip()
send_param_request_read(vehicle, param_id=param_id)
receive_param_value(vehicle)
elif mode == 'index':
param_index = int(input("Enter parameter index: "))
send_param_request_read(vehicle, param_index=param_index)
receive_param_value(vehicle)
else:
print("Invalid mode. Use 'id' or 'index'")
elif choice == '3':
print("\n📤 Requesting all parameters...")
send_param_request_list(vehicle)
all_params = receive_all_param_values(vehicle)
print(f"\n📋 Total parameters received: {len(all_params)}")
else:
print("Invalid choice. Select 1, 2, or 3.")
if __name__ == "__main__":
main()示例使用说明
获取
运行后,成功建立连接
输入“2”选择读取参数
输入对应参数“ENH_TRANS_STATE”
成功返回该参数对应的数值
设置
运行后,成功建立连接
输入“1”选择设置参数
输入对应参数“ENH_TRANS_STATE”
输入要设置的数值
选择参数类型“1”
成功返回设置值
作者:孙渝泓 创建时间:2026-06-15 16:13
最后编辑:孙渝泓 更新时间:2026-06-18 17:59
最后编辑:孙渝泓 更新时间:2026-06-18 17:59