EXCEEDED_INPUT_TIME_LIMIT while taking a photo
CompletedI have the following function for rotating the gimbal downwards 90 degrees and then taking a single photo:
fun rotateGimbalDownAndTakePicture() {
//Rotate gimbal 90° downwards
val gimbalAngleRotation = GimbalAngleRotation()
gimbalAngleRotation.mode = GimbalAngleRotationMode.ABSOLUTE_ANGLE
gimbalAngleRotation.duration = 0.5
gimbalAngleRotation.yaw=0.00
gimbalAngleRotation.roll=0.00
gimbalAngleRotation.pitch=-90.00
KeyManager.getInstance()
.performAction(
KeyTools.createKey(GimbalKey.KeyRotateByAngle),
gimbalAngleRotation,
object : CommonCallbacks.CompletionCallbackWithParam<EmptyMsg> {
override fun onSuccess(nil: EmptyMsg) {
// Create MediaVM instance
val mediaVM = MediaVM()
// Initialize MediaVM
mediaVM.init()
//Take photo
mediaVM.takePhoto(object : CommonCallbacks.CompletionCallback {
override fun onSuccess() {
ToastUtils.showToast("media index:"+mediaVM.mediaFileListData.value?.data?.lastOrNull()?.fileIndex.toString())
}
override fun onFailure(error: IDJIError) {
ToastUtils.showToast("takePhoto:${error.errorCode()}")
}
})
mediaVM.destroy()
}
override fun onFailure(error: IDJIError) {
ToastUtils.showToast("${error.errorCode()}")
}
}
)
}
Almost in every case when I call the function above, I receive the error EXCEEDED_INPUT_TIME_LIMIT while performing the 'takePhoto' action.
In rarer cases I receive the error CANNOT_START_TASK_VLOTAGE_ALARM
In even rarer cases I am able to take the picture normally
I precise that I instantiate val mediaVM = MediaVM(), referring to the file MediaVM.kt in the MSDK 5.8 sample code.
How can I solve this problem ? Thank you.
Tested on Mini Pro 3 MSDK 5.8
-
Could you provide us with the MediaVM.kt file you are using? Here is an upload link:https://pan-sec.djicorp.com/s/QTs4wf74pMnAaAj The password for it is dji123. Thank you! -
I have uploaded the file at the link you provided. It is just the MediaVM.kt file of your example here anyway: https://github.com/dji-sdk/Mobile-SDK-Android-V5.
-
I am calling the function rotateGimbalDownAndTakePicture() as the only action on a button setOnClickListener just like you did in your test.
I have created the button on the file frag_virtual_stick_page.xml for using on the file VirtualStickFragment.kt. I have also added import dji.sampleV5.aircraft.models.MediaVM directive at the top of VirtualStickFragment.kt in order to be able to intstantiate MediaVM() from there.
Aside from that, after many attempts with taking photos, I started to receive persistently the CANNOT_START_TASK_VLOTAGE_ALARM error. Could it be due to drone overheating or some other hardware issues ?
-
I suggest placing mediaVM.init() in the onViewCreated section of the fragment, and then calling mediaVM.destroy() when the fragment is destroyed. I have tried delaying the execution of takePhoto by 2 seconds, which was successful. However, the file list status will change to updating, so at this point, you will not be able to directly access the file index of the latest generated photo. -
I am now able to take pictures from my function on VirtualStickFragment.kt without errors. I have just moved the instantiation outside of the function:
class VirtualStickFragment : DJIFragment() {
private val mediaVM = MediaVM()The problem is that, similarly to what you were saying, the code that I now have within the function returns always "file count:0". So I don't have access to the picture I have just taken.// Initialize MediaVM
mediaVM.init()
//Take photo
mediaVM.takePhoto(object : CommonCallbacks.CompletionCallback {
override fun onSuccess() {// Get media file list
val mediaFiles = mediaVM.getMediaFileList()
ToastUtils.showToast("file count:"+mediaFiles.count().toString())
}
override fun onFailure(error: IDJIError) {
ToastUtils.showToast("takePhoto:${error.errorCode()}")
}
})
mediaVM.destroy()My aim is downloading the picture as soon as possible, even asyncronously, when it is saved in the internal memory of the drone.Is there a listener I can set so that I can proceed with my operations when the 'new file saved' event is generated ? Thank you. -
PS. I have tested the code for showing the media files count after taking a picture on MediaFragment.kt as well and the result was still "file count:0"
btn_take_photo.setOnClickListener {
mediaVM.takePhoto(object : CommonCallbacks.CompletionCallback {
override fun onSuccess() {
val mediaFiles = mediaVM.getMediaFileList()
ToastUtils.showToast("file count:"+mediaFiles.count().toString())
//ToastUtils.showToast("take photo success")
}
override fun onFailure(error: IDJIError) {
ToastUtils.showToast("take photo failed")
}
})
}UPDATE. I have noticed that mediaFiles.count() is populated and returns the right number of photos in the drone's memory after a click on the button 'fetch media file list' on the Media page of the sample app.There are in summary, as far as the Media page is concerned, these two cases:1) if I click directly on the 'take photo' I see 'file count:0'2) If I click on the 'fetch media file list' button and then I click on the 'take photo' button I see 'file count: 36' (if there are 36 photos in the drone's internal memory -
I have verified that if I fetch the media file list programmatically within OnViewCreated on VirtualStickFragment.kt, I can at least read the index of the latest picture saved on the drone's memory from my function:
class VirtualStickFragment : DJIFragment() {[...]override fun onViewCreated(view: View, savedInstanceState: Bundle?) {[...]// Initialize MediaVM
mediaVM.init()
//Set the storage
mediaVM.setStorage(CameraStorageLocation.INTERNAL)
//Fetch media file list
mediaVM.pullMediaFileListFromCamera(-1, -1)fun rotateGimbalDownAndTakePicture() {[...]var mediaFiles = mediaVM.getMediaFileList()
//Index of the latest picture saved on the drone
var indexLatestPicture =mediaFiles.first().fileIndex
ToastUtils.showToast("indexLatestPicture:"+indexLatestPicture)Of course mediaFiles is not updated when new pictures are taken with my function.Is there a way of updating it correctly every time a new photo is taken ? -
If you want to immediately get the fileIndex of the latest photo after taking a photo, this may not be achievable. The success of `takephoto` indicates that the SDK has requested the aircraft to take a photo successfully, but it does not necessarily mean that the aircraft has successfully taken the photo. Therefore, often when you receive a successful photo callback, the photo has not been generated yet. For newly generated photos, you can consider using KeyNewlyGeneratedMediaFile to monitor information about newly generated photos. However, it is important to note that KeyNewlyGeneratedMediaFile may also experience data loss. Therefore, I recommend that you check which photos have already been downloaded when downloading photos.
Please sign in to leave a comment.
Comments
14 comments