Information Management

No Rating


The information management function of PSDK includes information acquisition and message subscription functions. The payload device developed based on PSDK has the information acquisition function, which can actively obtain information such as the model of the drone, the location where the payload device is mounted, and the Mobile App used by the user. Loading different configuration files is convenient for users to use the payload device. The payload device with message subscription function can record the data information subscribed by the user, which is convenient for the user to realize a wider range of applications.

Basic concepts

Access to information

Information acquisition means that the payload device can actively acquire and record the data information on the drone, such as the drone model, hardware platform type, and the mounting position of the payload device.

Note: Install the payload device developed with PSDK on the drone, and the correct data information of the drone can be obtained only after 5s of booting and initialization.

After the payload device developed with PSDK is initialized, the following information can be obtained:

  • Basic information: drone model, hardware platform type, and payload mounting location
  • Mobile App information: the system language of the App and the screen type of the App

Data subscription

Various components on the drone will generate a large amount of data information in real time according to the actual flight status of the drone and will be pushed to other modules by the drone. The user can specify the data information to be subscribed by using the payload device with the message subscription function.

Subscription Process

After subscribing to the data item, the payload device can obtain the subscription information. The specific process is shown in Figure 1. Message subscription.

Figure 1. Message subscription


The data information that can be subscribed using the PSDK message subscription function is shown in Table 1. drone subscription items.

Table 1. Drone Subscription Items

Data typeTopicMaximum subscription frequency(Hz)
basic informationAttitude Quaternion200
Fusion Altitude200
Relative height200
fusion position200
flight status50
battery information50
GPS informationGPS date5
GPS time5
GPS position5
GPS velocity5
GPS information5
GPS Signal level50
RTK informationRTK position5
RTK velocity5
RTK yaw5
RTK location attribute5
RTK Heading Angle Properties5

Subscription rules

  • The message subscription function supports up to 4 types of frequency subscriptions, such as up to 10Hz, 20Hz, 50Hz, 100Hz, and 4 types of frequencies. Each subscription item can only be subscribed once.
  • When specifying the subscription frequency, the subscription frequency of any parameter cannot be less than or equal to 0, and the sum of the data lengths of topics with the same subscription frequency must be less than or equal to 242.

Note: When using the simulator in DJI Assistant 2 to simulate the working state of the payload device, the simulator will cannot obtain the sensor raw data such as GPS information and RTK information, but developers can subscribe to such as fusion location, Fusing fused data such as altitude or relative altitude.

Use the message subscription feature

PSDK supports subscription to the data information pushed by the drone through registration callback and interface call:

  • Obtain the data information of the latest subscription item generated by the drone and its corresponding time by calling DjiFcSubscription_GetLatestValueOfTopic().
  • Specify the subscription frequency and subscription items by calling the DjiFcSubscription_SubscribeTopic interface, and obtain the data information of the latest subscription items generated by the drone and the corresponding time by constructing and registering the callback function.

Note: Use the subscription function to synchronize the data received by the subscription item with the time of the drone system when the data is generated. This time is not currently supported and the time on the payload device.

Message subscription function module initialization

If a payload developed with PSDK needs to subscribe to the status information on the drone, it needs to call DjiFcSubscription_Init() to initialize the message subscription module.

djiStat = DjiFcSubscription_Init();
    USER_LOG_ERROR("init data subscription module error.");

Get the information on the drone by constructing the callback function

  1. Construct callback function Receive the information pushed by the drone by constructing a callback function.

Note: To avoid memory stamping events, the type of the data address must be cast to the pointer type in the subscription data structure.

static T_DjiReturnCode DjiTest_FcSubscriptionReceiveQuaternionCallback(const uint8_t *data, uint16_t dataSize, const T_DjiDataTimestamp *timestamp)
    T_DjiFcSubscriptionQuaternion *quaternion = (T_DjiFcSubscriptionQuaternion *) data;
    dji_f64_t pitch, yaw, roll;


    pitch = (dji_f64_t) asinf(-2 * quaternion->q1 * quaternion->q3 + 2 * quaternion->q0 * quaternion->q2) * 57.3;
    roll = (dji_f64_t) atan2f(2 * quaternion->q1 * quaternion->q2 + 2 * quaternion->q0 * quaternion->q3, -2 * quaternion->q2 * quaternion->q2 - 2 * quaternion->q3 * quaternion->q3 + 1) * 57.3;
    yaw = (dji_f64_t) atan2f(2 * quaternion->q2 * quaternion->q3 + 2 * quaternion->q0 * quaternion->q1, -2 * quaternion->q1 * quaternion->q1 - 2 * quaternion->q2 * quaternion->q2 + 1) * 57.3;

    if (s_userFcSubscriptionDataShow == true) {
        USER_LOG_INFO("receive quaternion data.");

        USER_LOG_INFO("timestamp: millisecond %u microsecond %u.", timestamp->millisecond,
        USER_LOG_INFO("quaternion: %f %f %f %f.\r\n", quaternion->q0, quaternion->q1, quaternion->q2, quaternion->q3);
        USER_LOG_INFO("euler angles: pitch = %.2f roll = %.2f yaw = %.2f.", pitch, yaw, roll);
        DjiTest_WidgetLogAppend("pitch = %.2f roll = %.2f yaw = %.2f.", pitch, yaw, roll);

  1. register callback function The registration callback function receives the data information generated by the drone and pushed to the outside world. The following code subscribes the drone's "drone flight speed" and "drone GPS coordinates" at a frequency of 1Hz, as shown in Figure 2. Subscription results (1 ) shown.

Note: When using the subscription function to subscribe to the data information on the drone, the subscription frequency can only be a submultiple of the "maximum subscription frequency".

    USER_LOG_ERROR("Subscribe topic velocity error.");

    USER_LOG_ERROR("Subscribe topic gps position error.");

Figure 2. Subscription results (1)

Get info on drone in thread function

Obtain the information pushed by the drone through the data subscription thread function and print it on the terminal. The following code subscribes the latest drone flight speed and drone GPS coordinates generated by the drone at a frequency of 1Hz, as well as the corresponding time of the data, as shown in Figure 3. Subscription result (2).

djiStat = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_VELOCITY,
                                                  (uint8_t *) &velocity,
    USER_LOG_ERROR("get value of topic velocity error.");
} else {
    USER_LOG_INFO("velocity: x = %f y = %f z = %f healthFlag = %d.",,,

djiStat = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_POSITION,
                                                  (uint8_t *) &gpsPosition,
    USER_LOG_ERROR("get value of topic gps position error.");
} else {
    USER_LOG_INFO("gps position: x = %d y = %d z = %d.", gpsPosition.x, gpsPosition.y, gpsPosition.z);

Figure 3. Subscription results (2)