将任务航路点上传到DJI无人机(A3)时出现DATA_NOT_ENOUGH错误

时间:2018-11-25 16:07:07

标签: dji-sdk

在尝试进行一个新的航路点任务时,当我尝试上载第一个航路点时,通常会出现OpenProtocol::ErrorCode::MissionACK::WayPoint::DATA_NOT_ENOUGH错误。奇怪的是,如果我此后停止任务并再次尝试上传,它将成功。

不幸的是,我找不到有关此错误含义的任何详细文档。

这是我的代码(请注意,它是板载SDK,而不是移动SDK;代码是Java调用的本机代码; SWIG生成的接口):

public void uploadWaypointMissionImpl(@NonNull DroneMission mission) throws DroneException{
    WayPointInitSettings wpis = newMissionSettings(mission);

    MissionManager missionManager = vehicle.getMissionManager();
    WaypointMission wptMission;
    int wpcount = missionManager.getWayptCounter();
    if (wpcount > 0){
        wptMission = missionManager.getWpMission();
        wptMission.stop(REQUEST_TIMEOUT_SECONDS);
        wptMission.init(wpis, REQUEST_TIMEOUT_SECONDS);
    } else{
        missionManager.initWaypoint(wpis, REQUEST_TIMEOUT_SECONDS));
        wptMission = missionManager.getWpMission();
    }

    if (wptMission == null)
        throw new DroneException("Failed to initialize mission manager");

    int pointCount = mission.getNavPoints().size();
    logger.i("Waypoint mission created, uploading %d points", pointCount);
    for (int i = 0; i < pointCount; ++i){
        WayPointSettings wp = newWayPointSettings(mission, i);
        wptMission.uploadIndexData(wp, REQUEST_TIMEOUT_SECONDS).getAck(); // <-- ERROR HERE
    }
}


private static WayPointInitSettings newMissionSettings(@NonNull DroneMission mission){
    WayPointInitSettings wpis = new WayPointInitSettings();
    wpis.setMaxVelocity(mission.getVelocityMps());
    wpis.setIdleVelocity(mission.getVelocityMps());
    wpis.setTraceMode((short)(!mission.isInPlace() && Prefs.drone.traceMode().get() ? 1 : 0));
    wpis.setRCLostAction((short)(Prefs.drone.rcLostMode().get() ? 1 : 0));
    wpis.setGimbalPitch((short)(Prefs.drone.gimbalPitchAutoMode().get() ? 1 : 0));
    wpis.setYawMode((short)0);
    wpis.setExecutiveTimes((short)1);
    wpis.setFinishAction((short)4);
    wpis.setLatitude(0.0);
    wpis.setLongitude(0.0);
    wpis.setAltitude(0.0f);
    wpis.setIndexNumber((short)mission.getNavPoints().size());

    Uint8Array reserved = new Uint8Array(16);
    for (int i = 0; i < 16; ++i){
        reserved.setitem(i, (short)0);
    }
    wpis.setReserved(reserved.cast());

    return wpis;
}



private static WayPointSettings newWayPointSettings(@NonNull DroneMission mission, int index){
    WayPointSettings wp = new WayPointSettings();
    wp.setDamping(Prefs.drone.dampingDistanceM().get());
    wp.setGimbalPitch(Prefs.drone.gimbalPitch().get().shortValue());
    wp.setYaw(Prefs.drone.yawDeg().get().shortValue());
    wp.setTurnMode((short)(Prefs.drone.turnModeCounterClockwise().get() ? 1 : 0));
    wp.setActionTimeLimit(100);

    wp.setHasAction((short)0);
    wp.setActionNumber((short)0);
    wp.setActionRepeat((short)0);

    Uint8Array commandList = new Uint8Array(16);
    Uint16Array commandParameter = new Uint16Array(16);
    for (int i = 0; i < 16; ++i){
        commandList.setitem(i, (short)0);
        commandParameter.setitem(i, 0);
    }
    wp.setCommandList(commandList.cast());
    wp.setCommandParameter(commandParameter.cast());

    NavPoint point = mission.getNavPoints().get(index);
    wp.setLongitude(point.getLocation().getLngRad());
    wp.setLatitude(point.getLocation().getLatRad());
    wp.setAltitude((float)Math.ceil(point.getCruisingAltitude() - mission.getTakeoffAltitudeMeters()));
    wp.setIndex((short)index);

    return wp;
}

2 个答案:

答案 0 :(得分:1)

当我在android设备上尝试时,Waypoint任务至少需要3个航路点,尝试再添加2个点,但请注意,每个点之间必须有1米的距离

编辑:我添加了制作航点并将其添加到列表中的代码

// Create a waypoint instance
Waypoint mWaypoint1 = new Waypoint(Latitude, Longitude, altitude);
//check if the mission's builder is null
if (waypointMissionBuilder != null) {
        waypointList.add(mWaypoint1);
        waypointMissionBuilder.waypointList(waypointList).
        waypointCount(waypointList.size());
     }
else {
    waypointMissionBuilder = new WaypointMission.Builder();
    waypointList.add(mWaypoint1);
    waypointMissionBuilder.waypointList(waypointList).
    waypointCount(waypointList.size());
    }

您需要制作一个包含Lat,Long,Alt的航点实例。给它正确的参数并将其添加到列表中,然后使用构建器进行配置,上传并开始执行任务。如果列表的大小不超过2,则在尝试使用config函数时,任务会给您djiError。

答案 1 :(得分:0)

您好,也许您需要在开始新的航点任务之前调用“ wptMission.stop”。您编写的该任务的所有数据都将上传到飞行控制器,仅当您调用“ wptMission.stop”时,飞行控制器会知道您要调用其他命令。