Precision Positioning
Tip: Before running the “Precision Positioning” sample code, please use the UAV or an MSDK-based app to ensure a stable communication link between the drone and the satellite signals for RTK. This ensures that the payload can obtain accurate positioning results.
Overview
To meet the centimeter-level positioning accuracy requirements of payloads developed using the PSDK, Autel Robotics supports the use of base stations and mobile stations. With the help of RTK (Real-Time Kinematic) technology, developers can obtain high-precision positioning and drone attitude information.
Basic Concepts
Obtaining Precision Positioning
Note: When obtaining precision positioning, you must use the time synchronization feature to align the local time of the payload with the drone time. For detailed instructions, please refer to the Time Synchronization section.
- When positioning data is required, the payload should record the local timestamp (i.e., the time on the payload) and subscribe to RTK position data;
- Then, the RTK event pin will be triggered (set to high level), and the positional data corresponding to that timestamp will be sent to the payload. The payload will use the time conversion function to translate its local time into the drone's system time.
Using the Precision Positioning Feature
1. Initialization of the Positioning Module
Before using the "Precision Positioning" feature, you must initialize the precision positioning module to ensure that the feature functions correctly.
uavStat = UAV_Positioning_Init(gpioCallback, RTK_UART_PATH);
if (uavStat != 0) {
LOG_ERROR("positioning module init error.");
return uavStat;
}
Note: You must register a custom GPIO callback function to control the GPIO trigger for RTK events.
2. Request and Print Positioning Information
After the precision positioning feature is triggered by the user, the payload obtains high-precision positioning information based on the time the positioning event occurs. The local time of the payload at the moment the positioning event is triggered must be converted into the drone's system time.
T_UAVReturnCode iRet;
iRet =UAV_TimeSync_TransferToAircraftTime(get_local_time_us(), ×tamp);
3. Obtain Precise Positioning Data
After completing the time synchronization, you can retrieve and print the precise positioning data of the payload at a specific timestamp. The retrieved information includes detailed coordinates and position data.
T_UAVReturnCode iRet = UAV_Positioning_GetCurrentPositioning_Sync(&positionInfo);
if (iRet == UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
/*print property, position, positionDeviation*/
USER_LOG_INFO("get positioning sync success, {}, [{},{},{}], [{},{},{}]",
(int)positionInfo.property,
positionInfo.position.longitude, positionInfo.position.latitude, positionInfo.position.altitude,
positionInfo.positionDeviation.longitude, positionInfo.positionDeviation.latitude, positionInfo.positionDeviation.altitude);
}