Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can's seem to rotate Gimbal in SDK #471

Open
petered opened this issue Jan 8, 2025 · 4 comments
Open

Can's seem to rotate Gimbal in SDK #471

petered opened this issue Jan 8, 2025 · 4 comments

Comments

@petered
Copy link

petered commented Jan 8, 2025

I'm trying to rotate the gimbal in the DJI SDK 5.12

As an experiment, I'm just trying to do a -20deg pitch, -30deg yaw over 0.5 sec.

My code for doing it is

    suspend fun rotateGimbal(rotation: GimbalAngleRotation) = suspendCoroutine<Result<Boolean>> { continuation ->
        val actualKey = KeyTools.createKey(co_y.KeyRotateByAngle)
        djiKeyManager.setValue(actualKey, rotation, object : CommonCallbacks.CompletionCallback {
            override fun onSuccess() {
                log("Gimbal rotation set successfully to ${rotation.toJson()}")
                continuation.resume(Result.success(true))
            }

            override fun onFailure(error: IDJIError) {
                log("Failed to set gimbal rotation:  ${error}: ${error.description()}.  Rotation: ${rotation.toJson()}")
                continuation.resume(Result.failure(Exception("Failed to set gimbal rotation: ${error}: ${error.description()}")))
            }
        })
    }

It always fails. The log is:

Failed to set gimbal rotation:  ErrorImp{errorType='CORE', errorCode='REQUEST_HANDLER_NOT_FOUND', innerCode='GIMBAL.RotateByAngle:-1', description='null', hint='error code = -1'}: null.  
Rotation: {"mode":0,"pitch":-20,"roll":0,"yaw":-30,"pitchIgnored":false,"rollIgnored":false,"yawIgnored":false,"duration":0.5,"jointReferenceUsed":false,"timeout":1000}

Does anyone have an idea of what I might be doing wrong here?

@dji-dev
Copy link
Contributor

dji-dev commented Jan 9, 2025

Agent comment from SHENRONG.LE in Zendesk ticket #126550:

Dear developers,
Hello, thank you for contacting DJI Innovation.

As shown in the screenshot, did you pass in exactly the right parameters to achieve the Angle change? I need to pass in all the parameters.

Thank you for your email and have a nice life!
Best Regards,
Dji innovation SDK technical support
image.png

°°°

@petered
Copy link
Author

petered commented Jan 9, 2025

Thank you for your response.

Unfortunately I am not able to see your screenshot (even when I log in)

image

@brien-crean
Copy link

@petered I've had success pitching the gimbal with these parameters using the KEY.create().action() syntax. Although I haven't actually tried yawing it.

fun rotateGimbal() {
    val gimbalRotation = GimbalAngleRotation()
    gimbalRotation.pitch = -20.0
    gimbalRotation.yaw = -30.0
    gimbalRotation.mode = GimbalAngleRotationMode.ABSOLUTE_ANGLE
    gimbalRotation.duration = 0.5

    GimbalKey.KeyRotateByAngle.create()
        .action(gimbalRotation, {}, { djiError ->
            Log.e("GIMBAL_PITCH_ERROR", "KeyRotateByAngle Error: $djiError")
        })
}

@petered
Copy link
Author

petered commented Jan 14, 2025

Bingo! Thank you @brien-crean . Turned out I had 2 things wrong:

  1. I wasn't using the .action syntax as you showed
  2. The command gets ignored if the yaw or pitch are out of the possible range (which in this case was true for -30deg yaw while the drone was not flying).

Notes

  • RELATIVE_ANGLE does work - but the command will be ignored if the requested angle is not possible.
  • If the drone is flying, it will use it's body to achieve the yaw rather than the gimbal (ie - gimbal's yaw will stay at zero and the drone's body will rotate instead)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants