Information Management
Overview
Payload devices with message subscription functionality can subscribe to the flight status data from the UAV, allowing users to implement a wide range of applications.
Basic Concepts
Message Subscription
Various components on the UAV produce a large amount of data in real-time according to the UAV's actual flight conditions. This data is pushed to other modules on the UAV. Users can use payload devices with message subscription functionality to specify the required data to subscribe to.
Subscription Process
After subscribing to a data item, the payload device can receive the subscribed information.
Subscription Items
Below is the list of data items that can be subscribed to using the PSDK message subscription functionality:
Note:
- If you need to search for subscription items in the code project, replace
*_
withUAV_SUBSCRIPTION_TOPIC_
, for example,*_QUATERNION
becomesUAV_SUBSCRIPTION_TOPIC_QUATERNION
.
Data Subscription Topic | EVO Max Series | Autel Alpha Series |
---|---|---|
Attitude Quaternion *_QUATERNION | Up to 5 Hz | Up to 5 Hz |
Ground-relative Acceleration *_ACCELERATION_GROUND | Up to 1 Hz | Up to 1 Hz |
Body-relative Acceleration *_ACCELERATION_BODY | Up to 1 Hz | Up to 1 Hz |
Raw Acceleration *_ACCELERATION_RAW | Up to 5 Hz | Up to 5 Hz |
Velocity *_VELOCITY | Up to 5 Hz | Up to 5 Hz |
Fused Angular Velocity *_ANGULAR_RATE_FUSIONED | Up to 1 Hz | Up to 1 Hz |
Raw Angular Velocity *_ANGULAR_RATE_RAW | Up to 1 Hz | Up to 1 Hz |
Fused Altitude *_ALTITUDE_FUSED | Up to 5 Hz | Up to 5 Hz |
Barometer Altitude *_ALTITUDE_BAROMETER | Up to 1 Hz | Up to 1 Hz |
Home Point Altitude *_ALTITUDE_OF_HOMEPOINT | Up to 5 Hz | Up to 5 Hz |
Fused Relative Ground Altitude *_HEIGHT_FUSION | Up to 1 Hz | Up to 1 Hz |
Relative Ground Altitude *_HEIGHT_RELATIVE | Up to 5 Hz | Up to 5 Hz |
Fused Position Coordinates *_POSITION_FUSED | Up to 1 Hz | Up to 1 Hz |
GPS Date (YYYY-MM-DD) *_GPS_DATE | Up to 1 Hz | Up to 1 Hz |
GPS Time (HH:MM:SS) *_GPS_TIME | Up to 1 Hz | Up to 1 Hz |
GPS Position *_GPS_POSITION | Up to 1 Hz | Up to 50 Hz |
GPS Velocity *_GPS_VELOCITY | Up to 5 Hz | Up to 50 Hz |
GPS Details *_GPS_DETAILS | Up to 1 Hz | Up to 1 Hz |
GPS Signal Strength *_GPS_SIGNAL_LEVEL | Up to 1 Hz | Up to 1 Hz |
RTK Position *_RTK_POSITION | Up to 1 Hz | Up to 10 Hz |
RTK Velocity *_RTK_VELOCITY | Up to 5 Hz | Up to 10 Hz |
RTK Yaw *_RTK_YAW | Up to 1 Hz | Up to 10 Hz |
RTK Position Info *_RTK_POSITION_INFO | Up to 1 Hz | Up to 10 Hz |
RTK Yaw Info *_RTK_YAW_INFO | Up to 1 Hz | Up to 10 Hz |
Timestamped RTK Info *_RTK_ALL_INFO | - | Up to 10 Hz |
Compass Info *_COMPASS | Up to 1 Hz | Up to 1 Hz |
Remote Control Joystick Info *_RC | Up to 1 Hz | Up to 1 Hz |
Gimbal Angles *_GIMBAL_ANGLES | Up to 1 Hz | Up to 1 Hz |
Gimbal Status *_GIMBAL_STATUS | Up to 1 Hz | Up to 1 Hz |
Flight Status *_STATUS_FLIGHT | Up to 1 Hz | Up to 1 Hz |
Flight Mode Status *_STATUS_DISPLAYMODE | Up to 1 Hz | Up to 1 Hz |
Motor Start Error Code *_STATUS_MOTOR_START_ERROR | Up to 1 Hz | Up to 1 Hz |
Battery Info *_BATTERY_INFO | Up to 1 Hz | Up to 1 Hz |
Hardware Clock Sync *_HARD_SYNC | Up to 1 Hz | Up to 1 Hz |
GPS Control Level *_GPS_CONTROL_LEVEL | Up to 1 Hz | Up to 1 Hz |
Tagged RC Info *_RC_WITH_FLAG_DATA | Up to 1 Hz | Up to 1 Hz |
ESC Data *_ESC_DATA | Up to 1 Hz | Up to 1 Hz |
Gimbal Control Mode *_GIMBAL_CONTROL_MODE | Trigger-based | Up to 1 Hz |
Cartesian Position *_POSITION_VO | Up to 1 Hz | Up to 1 Hz |
Obstacle Avoidance Data *_AVOID_DATA | Up to 1 Hz | Up to 1 Hz |
Home Point Set Status *_HOME_POINT_SET_STATUS | Up to 1 Hz | Up to 1 Hz |
Home Point Info *_HOME_POINT_INFO | Up to 1 Hz | Up to 1 Hz |
Battery Info (Index 1) *_BATTERY_SINGLE_INDEX1 | Up to 1 Hz | Up to 1 Hz |
Battery Info (Index 2) *_BATTERY_SINGLE_INDEX2 | Up to 1 Hz | Up to 1 Hz |
Timestamped Flight Attitude Info *_IMU_ATTI_NAVI_WITH_TIMESTAMP | Up to 1 Hz | Up to 1 Hz |
Using the Message Subscription Function
PSDK supports subscribing to the data pushed by the UAV using a callback registration method.
Message Subscription Module Initialization
For payload devices developed using PSDK, to subscribe to the status information of the UAV, the message subscription module must be initialized by calling the UAV_Subscription_Init()
function.
uavStat = UAV_Subscription_Init();
if (uavStat != UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("init data subscription module error.");
return UAV_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
uavStat = UAV_Subscribe_Topic(UAV_SUBSCRIPTION_TOPIC_QUATERNION, UAV_DATA_SUBSCRIPTION_TOPIC_1_HZ,
UAV_FcSubscription_ReceiveQuaternionCallback);
if (uavStat != UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
UAV_LOG_ERROR("Subscribe topic quaternion info error.");
return UAV_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
} else {
UAV_LOG_INFO("Subscribe topic quaternion info success.");
}
Constructing a Callback Function to Receive Information from the UAV
- Constructing the Callback Function
The callback function is constructed to receive the information pushed from the UAV.Note:
- To avoid memory corruption, the data address must be type-cast to the pointer type defined in the subscription item data structure.
static T_UAVReturnCode UAV_FcSubscription_ReceiveQuaternionCallback(const uint8_t *data, uint16_t dataSize)
{
T_UAVSubscriptionQuaternion *quaternion = (T_UAVSubscriptionQuaternion *) data;
double pitch, yaw, roll;
USER_UTIL_UNUSED(dataSize);
pitch = (double) asinf(-2 * quaternion->q1 * quaternion->q3 + 2 * quaternion->q0 * quaternion->q2) * 57.3;
roll = (double) atan2f(2 * quaternion->q2 * quaternion->q3 + 2 * quaternion->q0 * quaternion->q1, -2 * quaternion->q1 * quaternion->q1 - 2 * quaternion->q2 * quaternion->q2 + 1) * 57.3;
yaw = (double) atan2f(2 * quaternion->q1 * quaternion->q2 + 2 * quaternion->q0 * quaternion->q3, -2 * quaternion->q2 * quaternion->q2 - 2 * quaternion->q3 * quaternion->q3 + 1) * 57.3;
if (s_userFcSubscriptionDataShow == true) {
USER_LOG_INFO("receive quaternion data.");
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);
UAV_Test_WidgetLogAppend("pitch = %.2f roll = %.2f yaw = %.2f.", pitch, yaw, roll);
}
return UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}