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 |
---|---|
Attitude Quaternion *_QUATERNION | Maximum frequency of 100Hz |
Relative Ground Acceleration *_ACCELERATION_GROUND | Maximum frequency of 5Hz |
Relative Body Acceleration *_ACCELERATION_BODY | Maximum frequency of 5Hz |
Raw Acceleration *_ACCELERATION_RAW | Maximum frequency of 100Hz |
Velocity *_VELOCITY | Maximum frequency of 100Hz |
Fused Angular Rate *_ANGULAR_RATE_FUSIONED | Maximum frequency of 100Hz |
Raw Angular Rate *_ANGULAR_RATE_RAW | Maximum frequency of 100Hz |
Fused Altitude *_ALTITUDE_FUSED | Maximum frequency of 20Hz |
Barometer Altitude *_ALTITUDE_BAROMETER | Maximum frequency of 5Hz |
Home Point Altitude *_ALTITUDE_OF_HOMEPOINT | Maximum frequency of 10Hz |
Fused Relative Ground Altitude *_HEIGHT_FUSION | Maximum frequency of 1Hz |
Relative Ground Altitude *_HEIGHT_RELATIVE | Maximum frequency of 20Hz |
Fused Position Coordinates *_POSITION_FUSED | Maximum frequency of 20Hz |
GPS Date (YYYY-MM-DD) *_GPS_DATE | Maximum frequency of 10Hz |
GPS Time (HH:MM:SS) *_GPS_TIME | Maximum frequency of 10Hz |
GPS position *_GPS_POSITION | Maximum frequency of 10Hz |
GPS velocity *_GPS_VELOCITY | Maximum frequency of 10Hz |
GPS Information *_GPS_DETAILS | Maximum frequency of 10Hz |
GPS Signal strength *_GPS_SIGNAL_LEVEL | Maximum frequency of 10Hz |
RTK position *_RTK_POSITION | Maximum frequency of 10Hz |
RTK velocity *_RTK_VELOCITY | Maximum frequency of 5Hz |
RTK heading angle *_RTK_YAW | Maximum frequency of 5Hz |
RTK position information *_RTK_POSITION_INFO | Maximum frequency of 10Hz |
RTK heading information *_RTK_YAW_INFO | Maximum frequency of 5Hz |
Compass information *_COMPASS | Maximum frequency of 5Hz |
Remote control joystick information *_RC | Maximum frequency of 50Hz |
Gimbal angles *_GIMBAL_ANGLES | Maximum frequency of 100Hz |
Gimbal status *_GIMBAL_STATUS | Maximum frequency of 100Hz |
Flight status *_STATUS_FLIGHT | Maximum frequency of 2Hz |
Flight mode status *_STATUS_DISPLAYMODE | Maximum frequency of 2Hz |
Motor startup error code *_STATUS_MOTOR_START_ERROR | Maximum frequency of 5Hz |
Battery information *_BATTERY_INFO | Maximum frequency of 1Hz |
Hardware clock synchronization *_HARD_SYNC | Maximum frequency of 10H0z |
GPS control level *_GPS_CONTROL_LEVEL | Maximum frequency of 10Hz |
Tagged remote control remote sensing information *_RC_WITH_FLAG_DATA | Maximum frequency of 50Hz |
ESC data (Electronic Speed Controller data) *_ESC_DATA | Maximum frequency of 5Hz |
Gimbal control mode *_GIMBAL_CONTROL_MODE | Control trigger |
Cartesian coordinate position *_POSITION_VO | Maximum frequency of 100Hz |
Obstacle avoidance data *_AVOID_DATA | Maximum frequency of 20Hz |
Return home point setting status *_HOME_POINT_SET_STATUS | Maximum frequency of 1Hz |
Return home point information *_HOME_POINT_INFO | Maximum frequency of 1Hz |
1 Battery information of No. X *_BATTERY_SINGLE_INDEX1 | Maximum frequency of 1Hz |
2 Battery information of No. X *_BATTERY_SINGLE_INDEX2 | Maximum frequency of 1Hz |
Flight attitude information with timestamp *_IMU_ATTI_NAVI_WITH_TIMESTAMP | Maximum frequency of 20Hz |
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;
}