Ground SDK MainCamera set active

I am working with Anafi 4K and I want to programmetically record videos using ground sdk

The code I wrote after following documentations is as follows

import com.parrot.drone.groundsdk.device.peripheral.MainCamera
import com.parrot.drone.groundsdk.device.peripheral.camera.Camera
.
.
.
private fun monitorCanStartStopRecord() {
        try {
            logger.log("---------Monitoring camera record options")
            cameraRef = drone?.getPeripheral(MainCamera::class.java) { camera ->
                camera?.run {
                    if (camera != null) {
                        logger.log("Camera initialized")
                    } else {
                        logger.log("Camera initialization failed")
                    }

                    camera.mode().value = Camera.Mode.RECORDING
                    logger.log("Main camera is ${if (isActive) "active" else "not active"}")
                    logger.log("Camera mode: ${mode().value}")
                    when {
                        canStartRecording() -> {
                            logger.log("Photo capture can be started")
                        }

                        canStopPhotoCapture() -> {
                            logger.log("Photo capture can be stopped")
                        }

                        canStartRecording() -> {
                            logger.log("Video recording can be started")
                        }

                        canStopRecording() -> {
                            logger.log("Video recording can be stopped")
                        }

                        else -> {
                            logger.log("Monitor: Video recording can't be started or stopped")
                        }
                    }
                }
            }
        }catch (e: Error){
            logger.log("Error : $e")
        }
    }

    private fun toggleStartStopRecord() {
        logger.log("Pressed record toggle")

        drone?.getPeripheral(MainCamera::class.java)?.run {
            when {
                canStartRecording() -> {
                    startRecording()
                    recordBtn.apply {
                        text = "Stop Recording"
                    }
                    logger.log("Started recording")
                }
                canStopRecording() -> {
                    stopRecording()
                    recordBtn.apply {
                        text = "Start Recording"
                    }
                    logger.log("Stopped recording")
                }
                else -> logger.log("Video recording can't be toggled")
            }
        }

    }

Apparenty ‘isActive’ in logger.log("Main camera is ${if (isActive) "active" else "not active"}") is always false. Does anyone know how to activate it or any advices?
I initially had StreamServer displaying the camera videw in my phone and it works well. I thought maybe the camera can’t be set active because streamserver is using it so removed the streamserver and tried but still MainCamera can’t be set active. Please help, I need this for my university project!

Finally figured it out. You have to have the SD card properly formatted. Just formatting it to FAT32 isnt enough apparently other features such as volume name should also be changed. ATM my fix is to format it using FreeFlight app first then using with the app I am developing.

This topic was automatically closed after 30 days. New replies are no longer allowed.