Modeling
1. Feature Overview
The modeling capability lets the plugin sense Pilot's reality-modeling progress and, once modeling completes, move the modeling file to a public directory for the plugin to read and process further. The plugin receives progress, success, and failure callbacks via a listener, then retrieves the output file as needed.
1.1 Capability Overview
| Capability | Description |
|---|---|
| Modeling state listening | Register a listener to receive modeling progress / success / failure callbacks |
| Move modeling file | Move the modeling output to a public folder; the callback returns the path |
| Remove listener | Remove the modeling state listener |
1.2 Use Cases
- Progress display: show Pilot's modeling progress on the plugin UI
- Output retrieval: after modeling completes, move the file to a public directory for the plugin to read or upload
2. Interface Call Examples
The examples below assume you have completed SDK initialization and the plugin is connected to Pilot (for connection state, see the Plugin Connection State documentation). All interfaces are called through the manager singleton PilotModelingManager.getInstance().
2.1 Listen for Modeling State (addPilotModelingListener)
Register an IPilotModelingListener to receive progress, success, and failure callbacks:
val modelingManager = PilotModelingManager.getInstance() // get the manager singleton
private val modelingListener = object : IPilotModelingListener {
override fun onProgressUpdate(progress: Double) {
// modeling progress (0.0 to 100.0)
}
override fun onSuccess() {
// modeling complete; you can call moveModelingFileToPublic to retrieve the output (see 2.2)
}
override fun onFailure(error: IDJIError) {
// get the code via error.errorCode()
}
}
modelingManager.addPilotModelingListener(modelingListener) // re-adding the same listener is de-duplicated
2.2 Move the Modeling File to a Public Directory (moveModelingFileToPublic)
After modeling completes, move the output file to a public folder; the success callback returns the target path:
modelingManager.moveModelingFileToPublic(object : CommonCallbacks.CompletionCallbackWithParam<String> {
override fun onSuccess(path: String) {
// path is the modeling file path in the public directory, for later reading / uploading
}
override fun onFailure(error: IDJIError) {
// get the code via error.errorCode()
}
})
2.3 Remove the Listener (removePilotModelingListener)
Remove the listener when the page is destroyed:
override fun onDestroy() {
super.onDestroy()
modelingManager.removePilotModelingListener(modelingListener)
}
3. Interface Overview
IPilotModelingManager is the entry point of the modeling management interface, exposing the following methods:
| Item | Description |
|---|---|
IPilotModelingManager | Entry point of the modeling management interface |
addPilotModelingListener | Add a modeling state listener |
removePilotModelingListener | Remove a modeling state listener |
moveModelingFileToPublic | Move the modeling file to a public folder; the callback returns the path |
4. FAQ
Q1: When do I start receiving callbacks after registering?
addPilotModelingListener does not fire the current state immediately after registration; it fires only when Pilot's modeling has progress, succeeds, or fails. Register early so you do not miss progress events. Re-adding the same listener is de-duplicated.
Q2: moveModelingFileToPublic returns REMOTE_DISCONNECTED / EXECUTION_FAILED?
REMOTE_DISCONNECTED: called before the connection is ready (delegate not injected). Retry after the connection state isCONNECTED.EXECUTION_FAILED: an error while moving the file. Confirm modeling is complete and the output file exists, then retry.
Q3: Do I need to remove the listener manually?
Yes. The listener is held long-term by a local list; not removing it lets the anonymous inner class implicitly hold a page reference, causing a memory leak. Remove it in pairs with removePilotModelingListener when the page is destroyed.
Appendix: Error Code Quick Reference
The error codes below come from dji.open.pilot.base.error.RemoteError:
| Error code constant | Trigger | Suggested handling |
|---|---|---|
REMOTE_DISCONNECTED | Called before the connection is ready | Retry after the connection state is CONNECTED; see Q2 |
EXECUTION_FAILED | An error while moving the modeling file | Confirm modeling is complete and the output exists; see Q2 |