Positioning

2022-08-09
No Rating

Tips: Before running the "Precise Positioning" sample code, please use the APP developed by DJI Pilot or MSDK to check the good communication status between the drone and RTK satellites to ensure that the payload device can obtain accurate positioning results. Figure 1. RTK signal states as shown.

Figure 1. RTK Signal Status

Overview

In order to meet the positioning requirements of payload devices developed using PSDK for centimeter-level accuracy, DJI supports developers to use reference stations (such as D-RTK 2) and mobile stations (M300 RTK), with RTK (Real Time Kinematic, real-time dynamic carrier phase difference) technology) to obtain drone flight attitude and high-precision positioning information.

Basic Concepts

Terminology Explanation

  • Target point: The position where the positioning information is actually obtained, such as the center point of the gimbal port.

Notes: The target point of M300 RTK is the center point of the upper surface of the load device adapter ring, and the load device needs to be mounted on the drone No. 1 gimbal.

  • Point of interest: The position of a device on the load device arbitrarily specified by the user, such as the center point of the camera image sensor, the target point can also be a point of interest.
  • Mission: A collection of multiple continuous flight actions is called a mission, such as a surveying and mapping mission for a certain area. Users can create multiple tasks according to actual usage needs.
  • Positioning event: An event that triggers a positioning request. For example, a positioning request is triggered when the camera is exposed, and "camera exposure" is a positioning event; a collection of multiple events is an event collection, and a load device developed using PSDK can request multiple positioning events at the same time. Location information at the time of occurrence, such as camera co-exposure.

Get precise positioning

Note: When obtaining precise positioning, you need to use the time synchronization function to synchronize the local time of the load device to the drone time. For details on using the time synchronization function, please refer to Time Synchronizationopen in new window.

  1. When a positioning event occurs, the load device needs to record the local time (this time is the time on the load device).
  2. The load device converts the time on the load device to the time on the drone through the time conversion function.
  3. The payload device requests the location using the drone time (the time of the drone system) at the time of the location event.

Note: The time of the drone (the time of the drone system) when the positioning event occurs should be earlier than the rising edge time of the latest PPS signal, and the time interval must be within 1~2s, as shown in Figure 2. Precise positioning shown.

Figure 2. Get precise positioning

After obtaining the position of the target point, according to the position of the target point, the position of the point of interest can be calculated using the offset of the target point and the position of the RTK main antenna of the drone, the attitude of the drone, and the structure of the load equipment.

Using precise positioning

1. Initialize the positioning function module

Before using the "Precise Positioning" function, you need to initialize the precise positioning function module to ensure that the precise positioning function can operate normally.

djiStat = DjiPositioning_Init();
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("positioning module init error.");
return djiStat;
}
Set the task number

Recommended to use the task number function, which is convenient for users to quickly find the location request information in the Mark file (when the task number is not set, the default value of the task number is 0).

DjiPositioning_SetTaskIndex(0);

2. Request and print location information

After the user triggers the precise positioning function, the load device will obtain precise positioning information according to the time when the positioning event occurs.

  1. Get local time After the user triggers the precise positioning function, the load device obtains the local time on the load device when the PPS signal is triggered.
djiStat = DjiTest_TimeSyncGetNewestPpsTriggerLocalTimeUs(&ppsNewestTriggerTimeUs);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("get newest pps trigger time error: 0x%08llX.", djiStat);
continue;
}
  1. Time conversion Converts the local time on the payload at the time of the specified positioning event to the time of the UAS.
for (i = 0; i < DJI_TEST_POSITIONING_EVENT_COUNT; ++i) {
eventInfo[i].eventSetIndex = s_eventIndex;
eventInfo[i].targetPointIndex = i;

djiStat = DjiTimeSync_TransferToAircraftTime(
ppsNewestTriggerTimeUs - 1000000 - i * DJI_TEST_TIME_INTERVAL_AMONG_EVENTS_US, &aircraftTime);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("transfer to aircraft time error: 0x%08llX.", djiStat);
continue;
}

eventInfo[i].eventTime = aircraftTime;
}
  1. Obtain accurate positioning information After the time synchronization is completed, the user can obtain and print the precise location of the load device at a certain moment. The detailed location information of the load device is shown in Figure 3. Positioning Details.
djiStat = DjiPositioning_GetPositionInformationSync(DJI_TEST_POSITIONING_EVENT_COUNT, eventInfo, positionInfo);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("get position information error.");
continue;
}

USER_LOG_DEBUG("request position of target points success.");
USER_LOG_DEBUG("detail position information:");
for (i = 0; i < DJI_TEST_POSITIONING_EVENT_COUNT; ++i) {
USER_LOG_DEBUG("position solution property: %d.", positionInfo[i].positionSolutionProperty);
USER_LOG_DEBUG("pitchAttitudeAngle: %d\trollAttitudeAngle: %d\tyawAttitudeAngle: %d",
positionInfo[i].droneAttitude.pitch, positionInfo[i].droneAttitude.roll,
positionInfo[i].droneAttitude.yaw);
    USER_LOG_DEBUG("northPositionOffset: %d\tearthPositionOffset: %d\tdownPositionOffset: %d",
positionInfo[i].offsetBetweenMainAntennaAndTargetPoint.x,
positionInfo[i].offsetBetweenMainAntennaAndTargetPoint.y,
positionInfo[i].offsetBetweenMainAntennaAndTargetPoint.z);
USER_LOG_DEBUG("longitude: %.8f\tlatitude: %.8f\theight: %.8f",
positionInfo[i].targetPointPosition.longitude,
positionInfo[i].targetPointPosition.latitude,
positionInfo[i].targetPointPosition.height);
USER_LOG_DEBUG(
"longStandardDeviation: %.8f\tlatStandardDeviation: %.8f\thgtStandardDeviation: %.8f",
positionInfo[i].targetPointPositionStandardDeviation.longitude,
positionInfo[i].targetPointPositionStandardDeviation.latitude,
positionInfo[i].targetPointPositionStandardDeviation.height);
}

s_eventIndex++;

Figure 3. Positioning Details

Query location records

Please check the Mark file in the cam_mark_file file in the drone to obtain accurate positioning information. For the detailed description of the Mark file, please refer to [Mark File Introduction](https://djisdksupport.zendesk.com/hc/zh-cn /articles/360024019493 - Introduction to the Mark file).

Note: M300 RTK does not support viewing location log information in Mark files.

Compatible products

M300 RTK