Boardcast And Subscription

2020-05-084.0.0

NOTE This article is Machine-Translated. If you have any questions about this article, please send an E-mail to DJI, we will correct it in time. DJI appreciates your support and attention.

Overview

In order to improve the safety of applications when controlling drones perform tasks, OSDK provides data broadcasting and data subscription functions. The application with broadcasting functions could broadcasting the information in real-time.The application with data subscription functions can obtain the data generated by the sensors on the drone and the flight status of the drone in real-time .

Concepts

Subscription

According to the actual flight status of the drone, various components and third-party sensors will generate a large amount of data information in real-time and pushed to other modules by the drone. The application with subscription could record the data user need.

Topic

Table1 Shows the topic that the data could be subscribed from the drone.

Table1. The Topic On The Drone

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Item Topic Frequency (Hz)
Basic Content Gesture Guaternion 200
Hardware Sync 400
Home Point and Status 50
Remote Controller 50
Drone's Status Flight Status 50
Flight Mode 50
Landing Gear 50
ESC 50
Battery 50
Error code of the motor 50
Abnormal Flight 50
Drone's Speed Flight speed 200
Fusion Angular Velocity 200
Original Angular Velocity 400
Original Acceleration 400
Acceleration(Geodetic Coordinate) 200
Acceleration(Body Coordinate) 200
Sensor
Barometer Height 200
Fusion Barometer Altitude 200
Barometer Altitude At The Home Point 1
Relative Height Of Fusion 100
Compass 100
VO Visual Position 200
Obstacle Avoidance 100
Gimbal
Gimbal Atatus 50
Gimbal's Angle 200
Gimbal's Mode 50
Location
GPS Signal Level 50
GPS Original Information 5
GPS Fusion Information 50
RTK Connection Status 50
RTK Original Information 5

Rules

  • The message subscription function supports up to 0Hz, 1Hz, 10Hz, 50Hz, 100Hz, 5 types of frequency, each subscription can only be subscribed only once.
  • When specifying the subscription frequency, the subscription frequency of any parameter cannot be less than or equal to 0, and the total data length of topics with the same subscription frequency must be less than or equal to 242.

Broadcast

According to the actual flight conditions of the drone, various components and third-party sensors will generate a large amount of data information in real-time. The broadcast function of the OSDK can not only receive the data actively pushed by the drone to other modules, but also receive the data of third-party sensors. The Mobile APP developed based on MSDK, the Onboard Computer developed based on OSDK could receive the broadcast information of the drone and record broadcast information.

Broadcast

Applications with OSDK broadcast can broadcast the following information:

  • Sensor Information: Sensor such as gyroscope and magnetometer
  • Fusion: such as attitude and global position
  • Basic Information: battery, gimbal and flight status

Frequency

  • The broadcast of OSDK supports up to 0Hz, 1Hz, 10Hz, 50Hz, 100Hz, 5 types of frequency, each broadcast item can only be broadcast once. For example, if you specify 50 Hz for the GPS and 10 Hz for the gyroscope, the entire packet from the broadcast will come in at 50 Hz, but the gyroscope will only appear once every 5 packets.
  • After using OSDK's broadcast, applications developed based on OSDK will broadcast data at the default frequency. To change the broadcast frequency, please call the API of the broadcast or use DJI Assistant 2 to change the broadcast frequency.
  • When specifying the broadcast's frequency, the frequency of any parameter cannot be less than or equal to 0, and the total data length of topics with the same subscription frequency must be less than or equal to 242.

NOTE Due to the large bandwidth occupied by the broadcast and the OSDK wouldn't develop the broadcast function, so we recommended to use the Subscription function.

Develop With Subscription

1. Verify

ACK::ErrorCode subscribeStatus;
subscribeStatus=vehicle->subscribe->verify(timeout);
if (ACK::getError(subscribeStatus) != ACK::SUCCESS) {
ACK::getErrorCodeMessage(subscribeStatus, __func__);
return false;
}

2. Initialization

After initialized the message subscription function, the developer needs to specify the topic, frequency, package number, and data size.

bool enableTimestamp=false;
bool pkgStatus=vehicle->subscribe->initPackageFromTopicList(
    pkgIndex, topicSize, topicList, enableTimestamp, freq);
if (!(pkgStatus)) {
  return pkgStatus;
}

3. Get Subscription's Data

subscribeStatus=vehicle->subscribe->startPackage(pkgIndex, timeout);
if (ACK::getError(subscribeStatus) != ACK::SUCCESS) {
  ACK::getErrorCodeMessage(subscribeStatus, __func__);

4. Clear and Stop

Clear cache and stop subscription.

    ACK::ErrorCode ack=vehicle->subscribe->removePackage(pkgIndex, timeout);
if (ACK::getError(ack)) {
DERROR(
"Error unsubscription; please restart the drone/FC to get "
"back to a clean state");
}
return false;
}
return true;
} else {
DERROR("vehicle haven't been initialized", __func__);
return false;
}

Developers can choose a set of "topic" or "subscription data sets" and add them in the "subscription" package, and configure the corresponding subscription frequency. Users using the DJI Onboard API can configure five data packages, at the same time, a separate frequency can be set for each data package. OSDK provide a buffer(300 bytes), allowing users add more subscriptions to each package.

Figure 1. Topic Subscription