Mobile-SDK-Android icon indicating copy to clipboard operation
Mobile-SDK-Android copied to clipboard

Combine drone telemetry and gimbal telemetry

Open ykn96 opened this issue 3 years ago • 10 comments

Hi ! I am looking to combine the onUpdate functions for both the drone telemetry and gimbal telemetry, such that whenever they are updated, the values can be shown on the screen

How may i combine these 2 functions ? Since both uses the onUpdate function ? Drone telemetry. Currently i have found from the sdk and written code like this below.

       if (ModuleVerificationUtil.isFlightControllerAvailable()) {
            mFlightController = ((Aircraft) DJISampleApplication.getProductInstance()).getFlightController();

            mFlightController.setStateCallback(new FlightControllerState.Callback() {
                @Override
                public void onUpdate(@NonNull FlightControllerState djiFlightControllerCurrentState) {

                    droneLocationLat = djiFlightControllerCurrentState.getAircraftLocation().getLatitude();
                    droneLocationLng = djiFlightControllerCurrentState.getAircraftLocation().getLongitude();
                    droneAltitude = djiFlightControllerCurrentState.getAircraftLocation().getAltitude();

                    dronePitch = djiFlightControllerCurrentState.getAttitude().pitch;
                    droneRoll = djiFlightControllerCurrentState.getAttitude().roll;
                    droneYaw = djiFlightControllerCurrentState.getAttitude().yaw;
                    droneVeloX = djiFlightControllerCurrentState.getVelocityX();
                    droneVeloY = djiFlightControllerCurrentState.getVelocityY();
                    droneVeloZ = djiFlightControllerCurrentState.getVelocityZ();
}

Gimbal telemetry. I see this inside PushGimbalDataView.java in the example app.

        if (ModuleVerificationUtil.isGimbalModuleAvailable()) {
            DJISampleApplication.getProductInstance().getGimbal().setStateCallback(new GimbalState.Callback() {
                @Override
                public void onUpdate(@NonNull GimbalState gimbalState) {
                    stringBuffer.delete(0, stringBuffer.length());

                    stringBuffer.append("PitchInDegrees: ").
                            append(gimbalState.getAttitudeInDegrees().getPitch()).append("\n");
                    stringBuffer.append("RollInDegrees: ").
                            append(gimbalState.getAttitudeInDegrees().getRoll()).append("\n");
                    stringBuffer.append("YawInDegrees: ").
                            append(gimbalState.getAttitudeInDegrees().getYaw()).append("\n");

                    showStringBufferResult();
                }

Can i combine them under the same OnUpdate ? Or do it have to be different OnUpdate ?

=============== Question: How do i find the camera's FOV and current zoom level ??

ykn96 avatar Jul 04 '22 06:07 ykn96

Agent comment from yating.liao in Zendesk ticket #67092:

We can only read the latest status of the gimbal or drone in the respective callbacks, and then update the screen information in a method Although the callback method is both onUpdate, this method belongs to a different class, so there is no way to merge these two methods into one in the code.

°°°

dji-dev avatar Jul 04 '22 09:07 dji-dev

@dji-dev can i use the callbacks to update a variable, then access the variable elsewhere from within the same class ?

Eg i assign dronePitch = djiFlightControllerCurrentState.getAttitude().pitch; , where dronePitch is a private float

Thereafter, in another function, i format dronePitch into another string, then display the new string in stringBuffer ?

ykn96 avatar Jul 04 '22 09:07 ykn96

Agent comment from yating.liao in Zendesk ticket #67092:

Yes, you can do that. This is how we go about implementing screen information updates at sample as well.It's like this.
image.png

°°°

dji-dev avatar Jul 04 '22 11:07 dji-dev

@dji-dev how can i find the camera's current FOV and zoom level ? I don't need to set the value, but i want to read the current value of the FOV and number of times zoomed

ykn96 avatar Jul 05 '22 09:07 ykn96

Agent comment from yating.liao in Zendesk ticket #67092:

What kind of drone are you using? If it is a drone that supports zoom, you can get the current focal length by getHybridZoomFocalLength or getDigitalZoomFactor.If it is a drone that does not support zoom, you can find out the fixed focal length of the camera in the parameters of the corresponding model. You should also be able to find out the FOV values on the UAV parameters page.

°°°

dji-dev avatar Jul 06 '22 02:07 dji-dev

@dji-dev i am using Mavic 2 enterprise advanced. I am also looking to use for M210 and M300

ykn96 avatar Jul 06 '22 04:07 ykn96

Agent comment from yating.liao in Zendesk ticket #67092:

The M2EA's visible camera supports zoom, you can get the current focal length with lens.getHybridZoomFocalLength. the M210 and M300 can carry different cameras, so you need to judge according to the camera. You can determine if the zoom is supported by isHybridZoomSupported.

°°°

dji-dev avatar Jul 06 '22 10:07 dji-dev

@dji-dev thank you.

may i know where in the API i can find how to move the gimbal ??

I can only find gimbal max and min. What if i want to move it to an intermediate angle ? Like 35 degrees ?

ykn96 avatar Jul 13 '22 12:07 ykn96

Agent comment from yating.liao in Zendesk ticket #67092:

You can use gimbal.rotate to pass in the specified angle.

°°°

dji-dev avatar Jul 14 '22 03:07 dji-dev

Please look at the Gimbal class, it contains everything you need; hint, you don’t move the gimbal, you rotate it.

It is best if you learn how to use the available documentation, posting questions for common operations documented and included in the example will not lead to an efficient development on your part.

From: ykn96 @.> Sent: Wednesday, July 13, 2022 5:35 AM To: dji-sdk/Mobile-SDK-Android @.> Cc: Subscribed @.***> Subject: Re: [dji-sdk/Mobile-SDK-Android] Combine drone telemetry and gimbal telemetry (Issue #1153)

@dji-dev https://github.com/dji-dev thank you.

may i know where in the API i can find how to move the gimbal ??

I can only find gimbal max and min. What if i want to move it to an intermediate angle ? Like 35 degrees ?

— Reply to this email directly, view it on GitHub https://github.com/dji-sdk/Mobile-SDK-Android/issues/1153#issuecomment-1183167807 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ADHP4OCZUAMYGQXKAGIJU53VT2ZY7ANCNFSM52SBIWOA . You are receiving this because you are subscribed to this thread. https://github.com/notifications/beacon/ADHP4OHZWKFFA44F7E5FDJDVT2ZY7A5CNFSM52SBIWOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOI2C3KPY.gif Message ID: @.*** @.***> >

kenargo avatar Oct 11 '22 07:10 kenargo