WaypointMissionOperator.checkDJI Matrice 100或600中的NPE

时间:2019-11-17 19:33:56

标签: dji-sdk

更新

尝试将Android SDK sample更新为版本4.11的情况下加载航点任务会导致内部Null Pointer异常

先决条件:

  • 安装了示例SDK的android手机已更新为4.11
  • 连接到DJI Assistant 2的Matrice 100/600

复制步骤:

  1. 打开示例SDK
  2. 无人机连接后,点击“打开”
  3. 点击“新Waypoint任务运营商”
  4. 点击“加载”
  5. 应用程序崩溃并出现以下堆栈
com.dji.sdk.sample E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dji.sdk.sample, PID: 14107
java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object java.util.Map.get(java.lang.Object)' on a null object reference
    at dji.common.mission.waypoint.Waypoint.checkParameters(Unknown Source:15)
    at dji.common.mission.MissionUtils.checkEachWaypointValid(Unknown Source:18)
    at dji.common.mission.MissionUtils.checkWaypointMissionParameters(Unknown Source:44)
    at dji.common.mission.waypoint.WaypointMission$Builder.checkParameters(Unknown Source:10)
    at dji.internal.mission.abstraction.waypoint.WaypointMissionAbstraction.a(Unknown Source:0)
    at dji.sdk.mission.waypoint.WaypointMissionOperator.loadMission(Unknown Source:32)
    at com.dji.sdk.sample.demo.missionoperator.WaypointMissionOperatorView.onClick(:107)
    at android.view.View.performClick(View.java:6310)
    at android.view.View$PerformClick.run(View.java:24970)
    at android.os.Handler.handleCallback(Handler.java:794)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:176)
    at android.app.ActivityThread.main(ActivityThread.java:6662)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

原始问题

相同的代码在P4A上可以完美地工作,但在Matrice 100/600上则失败。

这是我在Kotlin中代码的相关部分。

  1. 创建航点列表。
val waypointList: List<Waypoint> = data.points.map {
    val waypoint = Waypoint(it.latitude, it.longitude, it.altitude)
    waypoint.speed = 3
    waypoint.heading = 0
    waypoint.gimbalPitch = 0
    waypoint.turnMode = WaypointTurnMode.CLOCKWISE

    waypoint.actionRepeatTimes = 1
    waypoint.actionTimeoutInSeconds = 3
    waypoint.cornerRadiusInMeters = 1
    waypoint
}
  1. 创建WaypointMission.Builder对象
val mission = WaypointMission.Builder()
    .waypointList(waypointList)
    .waypointCount(waypointList.size)
    .autoFlightSpeed(10)
    .repeatTimes(1)
    .setGimbalPitchRotationEnabled(false)
    .setExitMissionOnRCSignalLostEnabled(false)
    .finishedAction(WaypointMissionFinishedAction.NO_ACTION)
    .maxFlightSpeed(13)
    .flightPathMode(WaypointMissionFlightPathMode.CURVED)
    .headingMode(WaypointMissionHeadingMode.AUTO)
    .gotoFirstWaypointMode(WaypointMissionGotoWaypointMode.POINT_TO_POINT)
  1. 任务。checkParameters()
  2. WaypointOperator.loadMission(mission.build())
  3. WaypointOperator.uploadMission()

使用P4A:代码会继续正常运行,然后继续执行航点任务。 对于Matrice 100,步骤3中的checkParameters函数不返回任何结果,并且代码WaypointOperator.currentState停留在READY_TO_UPLOAD

处在此处停滞

最近2天我都尝试了一切,我唯一能猜到的是我缺少了Matrice 100需要的一些参数,但是我不知道可能是什么,也找不到任何东西。有关它的文档。

1 个答案:

答案 0 :(得分:0)

这是DJI的一个错误,但他们为我提供了一个临时解决方案,直到下一个版本发布为止。

After confirming, this problem only occurs when your aircraft is not mounting the camera.

So, for the temporary workaround, you can mount a camera on your drone when you using v4.11.
Also, this issue will be fixed in the coming v4.11.1 official release.