dji-sdk / Mobile-SDK-Android-V5

MSDK V5 Sample
Other
282 stars 146 forks source link

M300 Flight Planning Error - CANT_EXCUTE_IN_CURRENT_STATUS #63

Closed wooldridgetm closed 1 year ago

wooldridgetm commented 1 year ago

I've gotten flight planning working on the M3E, M3T, M30T drones, but for whatever reason, the same code and KMZ files do not work on the M300 + Smart Controller Enterprise. Every time I try to start a mission, it throws an exception CANT_EXECUTE_IN_CURRENT_STATUS, description='Unable to perform task. Device status error'.

Firmware/SDK Versions:

Details:

  1. Before uploading the KMZ, the WaypointMissionExecuteState is WaypointMissionExecuteState.READY.
  2. We upload Waypoint1.zip to the drone (Please note that the file extension was changed from KMZ to ZIP for the purposes of this post. In our app, the file is actually named Waypoint1.kmz).
  3. The WaypointMissionExecuteState changes to WaypointMissionExecuteState.UPLOADING
  4. Once it finishes uploading the KMZ, the WaypointMissionExecuteState changes to WaypointMissionExecuteState.READY.
  5. We start the mission, and this is where the problem lies.

Every time we try to start the mission, it throws the exception ErrorImp{errorType='WAYPOINT', errorCode='CANT_EXECUTE_IN_CURRENT_STATUS', innerCode='-1', description='Unable to perform task. Device status error', hint=''}). The full error & stack trace are delineated below.

What am I doing wrong?

Could not execute the flight plan: startMission (ErrorImp{errorType='WAYPOINT', errorCode='CANT_EXCUTE_IN_CURRENT_STATUS', innerCode='-1', description='Unable to perform task. Device status error', hint=''})
    com.dronesense.dji5system.common.Dji5Exception: startMission (ErrorImp{errorType='WAYPOINT', errorCode='CANT_EXCUTE_IN_CURRENT_STATUS', innerCode='-1', description='Unable to perform task. Device status error', hint=''})
        at com.dronesense.dji5system.model.flightplanning.BaseDji5MissionManager$start$$inlined$complete$default$1$1.onFailure(CompletionCallbackExtension.kt:24)
        at dji.v5.common.utils.CallbackUtils.onFailure(CallbackUtils.java:2)
        at com.dji.industry.mission.waypointv2.abstraction.WaypointV2Abstraction$2.lambda$onFailure$1(WaypointV2Abstraction.java:1)
        at com.dji.industry.mission.waypointv2.abstraction.WaypointV2Abstraction$2$$Lambda$2.run(WaypointV2Abstraction.java)
        at io.reactivex.rxjava3.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:123)
        at android.os.Handler.handleCallback(Handler.java:755)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:167)
        at android.app.ActivityThread.main(ActivityThread.java:6240)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1000)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:868)
DJI-William commented 1 year ago

@wooldridgetm There is no problem on my side by executing the Waypoint1.kmz file you have provided. Please check you IDeviceStatusManager and IDeviceHealthManager if you have any warnings. Also you can run this file in DJI Pilot 2 to see if you have any warning comes out.

wooldridgetm commented 1 year ago

The KMZ attached above was successfully executed in the DJI Pilot 2 app on the M300, but in our app, we get an exception. I will check for warnings in IDeviceStatusManager and IDeviceHealthManager and report back. Thanks.

DJI-William commented 1 year ago

It can run on my MSDK v5 sample.

wooldridgetm commented 1 year ago

We're still getting the error CANT_EXCUTE_IN_CURRENT_STATUS.

The device status reports as NORMAL. The device health reports a message with just an info code of 0x1B080003. No title or description is provided.

This is the log that's generated...

BaseDji5WaypointMission: WaypointMissionExecuteState: READY
BaseDji5MissionManager: DeviceStatus: NORMAL
BaseDji5MissionManager: DeviceHealth: [dji.v5.manager.diagnostic.DJIDeviceHealthInfo@1be3b14]
BaseDji5MissionManager: DeviceHealth TITLE:
BaseDji5MissionManager: DeviceHealth DESC:
BaseDji5MissionManager: DeviceHealth INFO CODE: 0x1B080003
BaseDji5MissionManager: --
BaseDji5MissionManager: Fx onStateUpdated(waypointMissionExecuteState: READY)
BaseDji5MissionManager: Fx onStateUpdated(waypointMissionExecuteState: READY)
BaseDji5MissionExecutor: Mission item 0 failed to execute
Received a state update from the executor: com.dronesense.pilotkit.model.flightplanning.enums.FlightPlanExecutionState$Error@85dd8ac
Could not execute the flight plan: startMission (ErrorImp{errorType='WAYPOINT', errorCode='CANT_EXCUTE_IN_CURRENT_STATUS', innerCode='-1', description='Unable to perform task. Device status error', hint=''})
    com.dronesense.dji5system.common.Dji5Exception: startMission (ErrorImp{errorType='WAYPOINT', errorCode='CANT_EXCUTE_IN_CURRENT_STATUS', innerCode='-1', description='Unable to perform task. Device status error', hint=''})
        at com.dronesense.dji5system.model.flightplanning.BaseDji5MissionManager$start$lambda-5$$inlined$complete$default$1$1.onFailure(CompletionCallbackExtension.kt:24)
        at dji.v5.common.utils.CallbackUtils.onFailure(CallbackUtils.java:2)
        at com.dji.industry.mission.waypointv2.abstraction.WaypointV2Abstraction$2.lambda$onFailure$1(WaypointV2Abstraction.java:1)
        at com.dji.industry.mission.waypointv2.abstraction.WaypointV2Abstraction$2$$Lambda$2.run(WaypointV2Abstraction.java)
        at io.reactivex.rxjava3.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:123)
        at android.os.Handler.handleCallback(Handler.java:755)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:167)
        at android.app.ActivityThread.main(ActivityThread.java:6240)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1000)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:868)
wooldridgetm commented 1 year ago

nvm, we figured it out. We just needed to add a 1 second delay after uploading the KMZ to starting the mission.

wooldridgetm commented 1 year ago

The delay doesn't help with some of the bigger stuff, like orbits and surveys. I'm putting together a sample app so you'll can reproduce the issue.

shoerob commented 1 year ago

Hello (I work with @wooldridgetm), I've figured out how to consistently reproduce the problem we are encountering in your sample app.

I've uploaded the sample here: https://github.com/shoerob/Mobile-SDK-Android-V5/tree/issues/startMissionFailure

I've included the KMZ file in the 'KMZ Sample' folder.

The problem occurs when you call startMission after the mission upload is reported as a success. I suspect there is a race condition in the backend, and the mission upload is reported as a success before it actually should be. I've modified the linked sample to show this.

DJI-William commented 1 year ago

OK, we will check the sorce code. A work aroud for you is to just seprate the upload and start functions into 2 buttons. That is what we do in sample and DJI Pilot 2.

DJI-William commented 1 year ago

The code you are using is incorrect, you have to check if the waypointMissionState is READY and then call start. There is no this check before you start which means you may start the mission without completing upload the kmz file. The upload method is pushKMZFileToAircraft.

Rick-v-E commented 1 year ago

I can confirm that on the M300 you get an error when calling startMission too soon after uploading a mission. Waiting for the waypointMissionState to change to READY is not solving this issue.

When I check some logs, I noticed that the waypointMissionState (printed in aWaypointMissionExecuteStateListener) is set to READY before the upload is at 100% (printed in the pushKMZFileToAircraft function's progress callback). The state changes to READY 5-10 ms before the upload is at 100%. However, starting a mission when both the upload is at 100% and the waypointMissionState is READY still gives the CANT_EXECUTE_IN_CURRENT_STATUS error.

The only way to get around this now is to add a delay of around 500 ms between uploading and starting the mission. However, for larger missions, this value should be larger.

DJI-William commented 1 year ago

Ok, we will check internally. Thanks for the update, the Ready state should be emitted after the 100% progress. This means the interal state of M300 isn't ready when the READY state is emitted.

dji-lyt commented 1 year ago

We have submitted the fix code for this part. Not surprisingly, it will be released in version 5.5.