Closed huongta157 closed 6 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!
@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
@dji-lyt @danilofariadutra Thank you so much.
Agent comment from yating.liao in Zendesk ticket #105584:
I hope this has been helpful to you.
°°°
Sorry, I use this code to implement it, but get error with the message: Param Illegal My drone is: Air 2s
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
°°°
@dji-dev I resolved this issue, thank you so much
@dji-dev Sorry, I have a new question. Does this SDK have support to get the current rotate value?
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
°°°
I used this code to implement it, but setStateCallback is not called. Please help me check it.
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.
°°°
@dji-dev I tried it on main and io thread, but still did not return results. Any other idea?
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?
@dji-lyt I run the sample code, but onUpdate still does not call. Any documents for it, please send to me.
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
°°°
@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
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
°°°
@dji-dev Thank you so much, I updated the firmware version and it worked for me
Agent comment from yating.liao in Zendesk ticket #105584:
I'm glad this has been helpful for you.
°°°
How to rotate DJI drone gimbal? Any widget or interface to support it?