尝试将Android SDK sample更新为版本4.11的情况下加载航点任务会导致内部Null Pointer异常
先决条件:
复制步骤:
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中代码的相关部分。
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
}
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)
使用P4A:代码会继续正常运行,然后继续执行航点任务。
对于Matrice 100,步骤3中的checkParameters
函数不返回任何结果,并且代码WaypointOperator.currentState
停留在READY_TO_UPLOAD
最近2天我都尝试了一切,我唯一能猜到的是我缺少了Matrice 100需要的一些参数,但是我不知道可能是什么,也找不到任何东西。有关它的文档。
答案 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.