Gimbal Management

2025-01-08
No Rating

Overview

The gimbal management function of PSDK supports the simultaneous management of gimbal load devices mounted on different positions on the drone, including setting the gimbal mode, centering the gimbal, and controlling the gimbal rotation. The developer can design the control logic based on the interface of the gimbal management, so as to realize the function of precisely controlling the rotation of the designated gimbal to the corresponding angle during the flight of the drone.

Basic Concepts

Gimbal angle

Gimbal joint and gimbal joint angle

The joints of the gimbal are shown in Figure 1. The gimbal joint is the structural member on the gimbal that drives the load equipment to rotate: the gimbal motor and the gimbal joint angle is the angle at which the gimbal motor rotates. This tutorial uses the body coordinate system to describe the joint angles of the gimbal.

Figure 1. Gimbal joint

Gimbal attitude and gimbal attitude angle

The attitude of the gimbal is shown in Figure 2. The attitude of the gimbal is shown in Figure 2. According to the user's control instructions, the gimbal can adjust the attitude; The angle of the load device **, this angle is also called Euler angle.

Figure 2. Gimbal attitude

Gimbal limit angle description

Note:

  • The PSDK controls the gimbal yaw axis to rotate n degrees in absolute angle (the angle is set based on the geodetic coordinate system, o degree is the true north.). If n > 0, the gimbal will rotate to n degrees clockwise from the true north. If n < 0, the gimbal will rotate to n degrees counterclockwise from the true north.
  • The PSDK controls the gimbal yaw axis to rotate n degrees in relative angle (the angle is set based on current angle). If n > 0, the gimbal will rotate to n degrees clockwise from current angle. If n < 0, the gimbal will rotate to n degrees counterclockwise from current angle.
ModelGimbal Payload ModelPitchYawRoll
M300 RTK / M350 RTKH30normal: (-120, 60)
reversed: (-60, 120)
(-310, 310)(-45, 45)
H30Tnormal: (-120, 60)
reversed: (-60, 120)
(-310, 310)(-45, 45)
H20normal: (-120, 45)
reversed: (-45, 120)
(-310, 310)(-45, 45)
H20Tnormal: (-120, 30)
reversed: (-30, 120)
If gimbal pitch location limitation is opened:
normal: (-120, 45)
reversed: (-45, 120)
(-310, 310)(-45, 45)
H20Nnormal: (-120, 30)
reversed: (-30, 120)
(-310, 310)(-50, 50)
L1/L2normal: (-120, 30)
reversed: (-30, 120)
(-310, 310)(-50, 50)
P1normal: (-120, 30)
reversed: (-30, 120)
(-310, 310)(-50, 50)
PSDK(X-Port)normal: (-120, 30)
reversed: (-30, 120)
(-310, 310)(-50, 50)
PSDK(Skyport 2.0)contact third-party developerscontact third-party developerscontact third-party developers
M300 RTKXTSnormal: (-120, 30)
reversed: (-30, 120)
(-320, 320)(-40, 40)
XT2normal: (-90, 30)
reversed: (-30, 90)
(-310, 310)(-40, 40)
Z30normal: (-120, 30)
reversed: (-30, 120)
(-310, 310)(-40, 40)
M30(-120, 45)(-310, 310)(-50, 50)
M30T (-120, 45)(-310, 310)(-50, 50)
M3E(-90, 35)(-40, 40)(-20, 20)
M3T(-90, 35)(-40, 40)(-20, 20)
M3D(-90, 35)(-40, 40)(-20, 20)
M3TD(-90, 35)(-40, 40)(-20, 20)
Matrice 4E Not Supported Not Supported Not Supported
Matrice 4T Not Supported Not Supported Not Supported

Gimbal control

  • control mode

    • Absolute angle control: The gimbal developed with PSDK will rotate from the current position to the specified position within the specified time according to the user's instructions.
    • Speed control: The user can control the rotation speed of the gimbal developed with PSDK.

Illustrate

  • In the angle control mode, the rotation time of the gimbal is limited by the maximum rotation speed and acceleration of the gimbal, and the actual rotation angle is limited by the limit angle of the gimbal.
  • In speed control mode, the gimbal rotates for 0.5s according to the speed specified by the user. When the gimbal rotates to the limit angle, it will stop rotating.
  • gimbal mode: Currently, the gimbal control function of PSDK supports only free mode. In this mode, when the attitude of the drone changes, the gimbal will not rotate.

Gimbal status information

Applications developed using PSDK can obtain the current information on the specified gimbal. For details, please refer to PSDK API documentation.

Using the gimbal management function

1. Gimbal management module initialization

If the load device developed with PSDK needs to control the gimbal, it needs to call the DjiGimbalManager_Init() interface to initialize the gimbal management module.

returnCode = DjiGimbalManager_Init();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
    USER_LOG_ERROR("Init gimbal manager failed, error code: 0x%08X", returnCode);
    goto out;
}

2. Set gimbal mode

Before controlling the gimbal, you need to call the DjiGimbalManager_SetMode interface to set the working mode of the gimbal.

returnCode = DjiGimbalManager_SetMode(mountPosition, gimbalMode);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
    USER_LOG_ERROR("Set gimbal mode failed, error code: 0x%08X", returnCode);
    goto out;
}

3. Control the gimbal rotation

Control the gimbal to rotate according to the expected angle and speed by calling the DjiGimbalManager_Rotate interface.

USER_LOG_INFO("Target gimbal pry = (30, 0, 0) in the body coordinate system");
rotation = (T_DjiGimbalManagerRotation) {DJI_GIMBAL_ROTATION_MODE_RELATIVE_ANGLE, 30, 0, 0, 0.5};
returnCode = DjiGimbalManager_Rotate(mountPosition, rotation);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
    USER_LOG_ERROR("Target gimbal pry = (30, 0, 0) failed, error code: 0x%08X", returnCode);
    goto out;
}

osalHandler->TaskSleepMs(1000);

USER_LOG_INFO("Target gimbal pry = (0, 30, 0) in the body coordinate system");
rotation = (T_DjiGimbalManagerRotation) {DJI_GIMBAL_ROTATION_MODE_RELATIVE_ANGLE, 0, 30, 0, 0.5};
returnCode = DjiGimbalManager_Rotate(mountPosition, rotation);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
    USER_LOG_ERROR("Target gimbal pry = (0, 30, 0) failed, error code: 0x%08X", returnCode);
    goto out;
}
osalHandler->TaskSleepMs(1000);

USER_LOG_INFO("Target gimbal pry = (0, 0, 30) in the body coordinate system");
rotation = (T_DjiGimbalManagerRotation) {DJI_GIMBAL_ROTATION_MODE_RELATIVE_ANGLE, 0, 0, 30, 0.5};
returnCode = DjiGimbalManager_Rotate(mountPosition, rotation);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
    USER_LOG_ERROR("Target gimbal pry = (0, 0, 30) failed, error code: 0x%08X", returnCode);
    goto out;
}
osalHandler->TaskSleepMs(1000);

4. Control the gimbal back to center

Applications developed using PSDK support to rotate the pitch and yaw axes of the gimbal to the neutral position by calling the DjiGimbalManager_Reset interface.

USER_LOG_INFO("Target gimbal reset.\r\n");
returnCode = DjiGimbalManager_Reset(mountPosition);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
    USER_LOG_ERROR("Reset gimbal failed, error code: 0x%08X", returnCode);
    goto out;
}

5. Get gimbal status

Developers can use the subscription data items DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES and DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_STATUS to obtain the attitude angle and status of the gimbal at different positions.

If you have any comments or confusion about our documentation, you can click here to give feedback and we will get back to you as soon as possible.