mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 12:03:34 +08:00
geo: interface to get reference lat lon, option to set reference timestamp on initialization
This commit is contained in:
+14
-2
@@ -67,7 +67,7 @@ __EXPORT uint64_t map_projection_timestamp()
|
||||
return mp_ref.timestamp;
|
||||
}
|
||||
|
||||
__EXPORT void map_projection_init(double lat_0, double lon_0) //lat_0, lon_0 are expected to be in correct format: -> 47.1234567 and not 471234567
|
||||
__EXPORT void map_projection_init(double lat_0, double lon_0, uint64_t timestamp) //lat_0, lon_0 are expected to be in correct format: -> 47.1234567 and not 471234567
|
||||
{
|
||||
mp_ref.lat = lat_0 / 180.0 * M_PI;
|
||||
mp_ref.lon = lon_0 / 180.0 * M_PI;
|
||||
@@ -75,10 +75,22 @@ __EXPORT void map_projection_init(double lat_0, double lon_0) //lat_0, lon_0 are
|
||||
mp_ref.sin_lat = sin(mp_ref.lat);
|
||||
mp_ref.cos_lat = cos(mp_ref.lat);
|
||||
|
||||
mp_ref.timestamp = hrt_absolute_time();
|
||||
mp_ref.timestamp = timestamp;
|
||||
mp_ref.init_done = true;
|
||||
}
|
||||
|
||||
__EXPORT bool map_projection_reference(double *ref_lat, double *ref_lon)
|
||||
{
|
||||
if (!map_projection_initialized()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*ref_lat = mp_ref.lat;
|
||||
*ref_lon = mp_ref.lon;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
__EXPORT bool map_projection_project(double lat, double lon, float *x, float *y)
|
||||
{
|
||||
if (!map_projection_initialized()) {
|
||||
|
||||
+7
-1
@@ -88,6 +88,12 @@ __EXPORT bool map_projection_initialized();
|
||||
*/
|
||||
__EXPORT uint64_t map_projection_timestamp();
|
||||
|
||||
/**
|
||||
* Writes the reference values to ref_lat and ref_lon
|
||||
* @return true if map_projection_init was called before, false else
|
||||
*/
|
||||
__EXPORT bool map_projection_reference(double *ref_lat, double *ref_lon);
|
||||
|
||||
/**
|
||||
* Initializes the map transformation.
|
||||
*
|
||||
@@ -95,7 +101,7 @@ __EXPORT uint64_t map_projection_timestamp();
|
||||
* @param lat in degrees (47.1234567°, not 471234567°)
|
||||
* @param lon in degrees (8.1234567°, not 81234567°)
|
||||
*/
|
||||
__EXPORT void map_projection_init(double lat_0, double lon_0);
|
||||
__EXPORT void map_projection_init(double lat_0, double lon_0, uint64_t timestamp);
|
||||
|
||||
/**
|
||||
* Transforms a point in the geographic coordinate system to the local azimuthal equidistant plane
|
||||
|
||||
Reference in New Issue
Block a user