dji-sdk / Mobile-SDK-Android

DJI Mobile SDK for Android: http://developer.dji.com/mobile-sdk/
Other
978 stars 580 forks source link

Dji Drone Gimbal Rotation #1297

Closed huongta157 closed 5 months ago

huongta157 commented 5 months ago

How to rotate DJI drone gimbal? Any widget or interface to support it?

danilofariadutra commented 5 months ago

First of all, create a Gimbal object private Gimbal cameraGimbal; Then, if you have more than one Payload (If you have double gimbal support), create an ID to set the gimbal id private final int CURRENT_GIMBAL_ID = 0; // 0 is the first id number Set-up the gimbal's object as: cameraGimbal = ((Aircraft) DJISDKManager.getInstance().getProduct()).getGimbals().get(CURRENT_GIMBAL_ID);

Then you must create an object Rotation setup, to gimbal know what to do:

Rotation rotation = new Rotation.Builder(). mode(RotationMode.ABSOLUTE_ANGLE) // Can be RELATIVE_ANGLE, ABSOLUTE_ANGLE or SPEED .pitch(changeToPitchValue) // float value .yaw(changeToYawValue) // float value .roll(changeToRollValue) // float value .time(changeToTimeRotation) // Greater than 0 (double value) .build();

So, you put your rotation object in the method "rotate". Se bellow: cameraGimbal.rotate(rotation, djiError -> { });

For more information, you can read this: https://developer.dji.com/api-reference/android-api/Components/Gimbal/DJIGimbal_DJIGimbalRotation.html#djigimbal_djigimbalrotation_djigimbalrotationmode_inline

I hope to be helpfull!

dji-lyt commented 5 months ago

@danilofariadutra The response you provided is comprehensive and excellent. As an addition, here is an article explaining how to rotate the gimbal in speed mode.https://sdk-forum.dji.net/hc/en-us/articles/4402117653145-How-to-change-the-gimbal-attitude

huongta157 commented 5 months ago

@dji-lyt @danilofariadutra Thank you so much.

dji-dev commented 5 months ago

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

I hope this has been helpful to you.

°°°

huongta157 commented 5 months ago

Screenshot 2024-04-26 at 11 30 28 Sorry, I use this code to implement it, but get error with the message: Param Illegal My drone is: Air 2s

dji-dev commented 5 months ago

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

Please check if the angle you have input meets the requirements of the AIR 2S. Here is the way to obtain the rotation range:https://sdk-forum.dji.net/hc/en-us/articles/900006137606-How-to-get-the-rotation-range-of-a-gimbal?source=search&auth_token=eyJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50X2lkIjo5Nzg4MTcsInVzZXJfaWQiOjMwNTQxMDIxOTA1MzA1LCJ0aWNrZXRfaWQiOjEwNTU4NCwiY2hhbm5lbF9pZCI6NjMsInR5cGUiOiJTRUFSQ0giLCJleHAiOjE3MTY3MTg3Mzd9.2g8Do2pXzsWkql_cYzPyrSiwEl0rfkhHXQbqAd6dYug

°°°

huongta157 commented 5 months ago

@dji-dev I resolved this issue, thank you so much

huongta157 commented 5 months ago

@dji-dev Sorry, I have a new question. Does this SDK have support to get the current rotate value?

dji-dev commented 5 months ago

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

You can determine its current posture through the status of the gimbal. https://developer.dji.com/api-reference/android-api/Components/Gimbal/DJIGimbal_GimbalState.html#djigimbal_gimbalstate_attitude_inline

°°°

huongta157 commented 4 months ago

Screenshot 2024-05-06 at 11 26 08 I used this code to implement it, but setStateCallback is not called. Please help me check it.

dji-dev commented 4 months ago

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

I can't see any issues from your calls to the interface. You may try adjusting the location where you set up the listener, such as switching to the main thread.

°°°

huongta157 commented 4 months ago

@dji-dev I tried it on main and io thread, but still did not return results. Any other idea?

dji-lyt commented 4 months ago

Could you please provide us with a method to reproduce your issue on the sample code? Does the sample code also use gimbal.setStateCallback, and will it have the same issue? image

huongta157 commented 4 months ago

@dji-lyt I run the sample code, but onUpdate still does not call. Any documents for it, please send to me.

dji-dev commented 4 months ago

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

Could you please provide me with a video recording of the sample code? Here is the upload link:https://pan-sec.djicorp.com/s/25JiozQT8rHHz86 password:dji123

°°°

huongta157 commented 4 months ago

@dji-dev Thank you for your support, I uploaded the video, please check it https://pan-link.djicorp.com/s/25JiozQT8rHHz86?path=%2F&openfile=76171167

dji-dev commented 4 months ago

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

Could you please try updating the firmware version of your AIR 2S and then conduct the test again? I have uploaded the test video to this address:https://pan-link.djicorp.com/s/25JiozQT8rHHz86?path=%2F&openfile=76171167 image

°°°

huongta157 commented 4 months ago

@dji-dev Thank you so much, I updated the firmware version and it worked for me

dji-dev commented 4 months ago

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

I'm glad this has been helpful for you.

°°°