mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 14:33:35 +08:00
geo: Moved the map_projection_* functions and state into a self-contained C++ class
This commit is contained in:
committed by
Matthias Grob
parent
fe23718e2c
commit
8db7a6225b
@@ -264,7 +264,7 @@ private:
|
||||
uORB::Subscription _vehicle_command_sub{ORB_ID(vehicle_command)};
|
||||
|
||||
// hil map_ref data
|
||||
map_projection_reference_s _global_local_proj_ref{};
|
||||
MapProjection _global_local_proj_ref{};
|
||||
float _global_local_alt0{NAN};
|
||||
|
||||
vehicle_status_s _vehicle_status{};
|
||||
|
||||
@@ -542,14 +542,14 @@ void Simulator::handle_message_hil_state_quaternion(const mavlink_message_t *msg
|
||||
double lat = hil_state.lat * 1e-7;
|
||||
double lon = hil_state.lon * 1e-7;
|
||||
|
||||
if (!map_projection_initialized(&_global_local_proj_ref)) {
|
||||
map_projection_init(&_global_local_proj_ref, lat, lon);
|
||||
if (!_global_local_proj_ref.isInitialized()) {
|
||||
_global_local_proj_ref.initReference(lat, lon);
|
||||
_global_local_alt0 = hil_state.alt / 1000.f;
|
||||
}
|
||||
|
||||
float x;
|
||||
float y;
|
||||
map_projection_project(&_global_local_proj_ref, lat, lon, &x, &y);
|
||||
_global_local_proj_ref.project(lat, lon, x, y);
|
||||
hil_lpos.timestamp = timestamp;
|
||||
hil_lpos.xy_valid = true;
|
||||
hil_lpos.z_valid = true;
|
||||
@@ -569,9 +569,9 @@ void Simulator::handle_message_hil_state_quaternion(const mavlink_message_t *msg
|
||||
hil_lpos.heading = euler.psi();
|
||||
hil_lpos.xy_global = true;
|
||||
hil_lpos.z_global = true;
|
||||
hil_lpos.ref_timestamp = _global_local_proj_ref.timestamp;
|
||||
hil_lpos.ref_lat = math::degrees(_global_local_proj_ref.lat_rad);
|
||||
hil_lpos.ref_lon = math::degrees(_global_local_proj_ref.lon_rad);
|
||||
hil_lpos.ref_timestamp = _global_local_proj_ref.getProjectionReferenceTimestamp();
|
||||
hil_lpos.ref_lat = _global_local_proj_ref.getProjectionReferenceLat();
|
||||
hil_lpos.ref_lon = _global_local_proj_ref.getProjectionReferenceLon();
|
||||
hil_lpos.ref_alt = _global_local_alt0;
|
||||
hil_lpos.vxy_max = std::numeric_limits<float>::infinity();
|
||||
hil_lpos.vz_max = std::numeric_limits<float>::infinity();
|
||||
|
||||
Reference in New Issue
Block a user