mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 06:43:34 +08:00
ekf2 support SET_GPS_GLOBAL_ORIGIN and remove globallocalconverter usage
- vehicle_command cmd extended from uint16 to support PX4 internal commands that don't map to mavlink
This commit is contained in:
@@ -410,17 +410,24 @@ RoverPositionControl::Run()
|
||||
|
||||
position_setpoint_triplet_poll();
|
||||
|
||||
//Convert Local setpoints to global setpoints
|
||||
// Convert Local setpoints to global setpoints
|
||||
if (_control_mode.flag_control_offboard_enabled) {
|
||||
if (!globallocalconverter_initialized()) {
|
||||
globallocalconverter_init(_local_pos.ref_lat, _local_pos.ref_lon,
|
||||
_local_pos.ref_alt, _local_pos.ref_timestamp);
|
||||
if (!map_projection_initialized(&_global_local_proj_ref)
|
||||
|| (_global_local_proj_ref.timestamp != _local_pos.ref_timestamp)) {
|
||||
|
||||
} else {
|
||||
globallocalconverter_toglobal(_pos_sp_triplet.current.x, _pos_sp_triplet.current.y, _pos_sp_triplet.current.z,
|
||||
&_pos_sp_triplet.current.lat, &_pos_sp_triplet.current.lon, &_pos_sp_triplet.current.alt);
|
||||
map_projection_init_timestamped(&_global_local_proj_ref, _local_pos.ref_lat, _local_pos.ref_lon,
|
||||
_local_pos.ref_timestamp);
|
||||
|
||||
_global_local_alt0 = _local_pos.ref_alt;
|
||||
}
|
||||
|
||||
// local -> global
|
||||
map_projection_reproject(&_global_local_proj_ref,
|
||||
_pos_sp_triplet.current.x, _pos_sp_triplet.current.y,
|
||||
&_pos_sp_triplet.current.lat, &_pos_sp_triplet.current.lon);
|
||||
|
||||
_pos_sp_triplet.current.alt = _global_local_alt0 - _pos_sp_triplet.current.z;
|
||||
_pos_sp_triplet.current.valid = true;
|
||||
}
|
||||
|
||||
// update the reset counters in any case
|
||||
|
||||
@@ -129,6 +129,9 @@ private:
|
||||
hrt_abstime _control_position_last_called{0}; /**<last call of control_position */
|
||||
hrt_abstime _manual_setpoint_last_called{0};
|
||||
|
||||
map_projection_reference_s _global_local_proj_ref{};
|
||||
float _global_local_alt0{NAN};
|
||||
|
||||
/* Pid controller for the speed. Here we assume we can control airspeed but the control variable is actually on
|
||||
the throttle. For now just assuming a proportional scaler between controlled airspeed and throttle output.*/
|
||||
PID_t _speed_ctrl{};
|
||||
|
||||
Reference in New Issue
Block a user