大疆上云api 无人机摄像头红外调色模式

发布于:2025-06-21 ⋅ 阅读:(14) ⋅ 点赞:(0)
# topic  
thing/product/{你的机场}/property/set

# 监听topic,获取设置结果
thing/product/+/property/set_reply

#mqtt
https://developer.dji.com/doc/cloud-api-tutorial/cn/api-reference/dock-to-cloud/mqtt/aircraft/m3d-properties.html

thermal_current_palette_style: {"0":"白热","1":"黑热","2":"描红","3":"医疗","5":"彩虹 1","6":"铁红","8":"北极","11":"熔岩","12":"热铁","13":"彩虹 2"}	

81-0-0: 为无人机payload第一个摄像头的payload_index值

消息体:
{
    "tid": "0cfb666f-9cc7-4ca4-8962-3074cc342a66",
    "bid": "98509752-e2d3-45e3-b113-53d9087fe58b",
    "timestamp": 1750295776621,
    "data": {
        "81-0-0": {
            "thermal_current_palette_style": 1
        }
    }
}

对应Java代码  Common.publish 参考:https://blog.csdn.net/now19930616/article/details/148625191?spm=1011.2415.3001.5331


public void setThermalPaletteStyle(String sn, Integer state) {
        // 校验state  M3TD
        List<Integer> stateList = Arrays.asList(0, 1, 2, 3, 5, 6, 8, 11, 12, 13);
        if (!stateList.contains(state)) {
            throw new BusinessException("参数错误: state: " + state);
        }
        // 调用上云api获取设备信息
        LinkedHashMap dockInfoMap = cloudApiInvoke.cloudApiDeviceInfo(sn);
        // 获取机场绑定的无人机信息
        String droneSn = TypeUtils.castToString(dockInfoMap.get("child_device_sn"));
        if (StrUtil.isBlank(droneSn)) {
            throw new RuntimeException("当前机场尚未绑定无人机");
        }
        // 获取无人机osd信息,无人机开机状态是可以获取到的,关机获取不到
        LinkedHashMap droneOsdInfo = cloudApiInvoke.cloudApiOsdDockDroneDeviceInfo(droneSn);

        String payloadIndex = TypeUtils.castToString(((ArrayList<LinkedHashMap>) droneOsdInfo.get("payload")).get(0).get("payload_index"));

        Map<String, Object> map = new HashMap<>();
        String uuid = IdUtil.simpleUUID();
        map.put("bid", uuid);
        map.put("tid", uuid);
        map.put("timestamp", System.currentTimeMillis());
        HashMap<String, Object> data = new HashMap<>();
        data.put(payloadIndex, new HashMap<String, Object>() {{
            put("thermal_current_palette_style", state);
        }});
        map.put("data", data);
        JSONObject publish = Common.publish(mqttMessageGateway, "thing/product/" + sn + "/property/set", map);
        if (publish == null || !publish.containsKey("data")) {
            throw new BusinessException("设置失败,请稍后重试");
        }
        JSONObject d = publish.getJSONObject("data");
        if (TypeUtils.castToInt(d.getJSONObject(payloadIndex).getJSONObject("thermal_current_palette_style").get("result")) != 0) {
            throw new BusinessException("设置失败, result:" + TypeUtils.castToInt(d.get("result")));
        }
    }


网站公告

今日签到

点亮在社区的每一天
去签到