Trevor Pennypacker
Trevor Pennypacker

Reputation: 1

Get gimbal angle from DJI Android SDK

I've figured out how to control the gimbal programmatically, but I have no way of telling when a user has moved the gimbal manually from the controller. I'm looking at the documentation here https://developer.dji.com/api-reference/android-api/Components/Gimbal/DJIGimbal_GimbalState.html

but I have no idea how to instantiate a GimbalState object so that I can read in the current angle of the gimbal. Does anybody know how to do this?

Upvotes: 0

Views: 297

Answers (1)

Michael
Michael

Reputation: 666

Hi @Trevor here is my advice:

1.get the gimbal instance:

Gimbal gimbal = DJISDKManager.getInstance().getProduct().getGimbal()

2.set the callback using following method which will return you the gimbal state:

gimbal.setStateCallback(new GimbalState.Callback() {
                @Override
                public void onUpdate(final GimbalState state) {
                    if (handler != null && !handler.hasMessages(UPDATE_MSG)) {
                        gimbalState = state;
                        handler.sendEmptyMessage(UPDATE_MSG);
                    } else {
                        DJILog.e(TAG,"too many events!");
                    }
                }
            })

Note: the updating frequency of gimbal state is quite high (10HZ), please try to avoid the blocking of UI element.

Upvotes: 1

Related Questions