mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-23 10:27:34 +08:00
Merge branch 'release_v1.0.0' into beta
This commit is contained in:
@@ -1479,7 +1479,22 @@ int commander_thread_main(int argc, char *argv[])
|
||||
|
||||
if (updated) {
|
||||
/* position changed */
|
||||
orb_copy(ORB_ID(vehicle_global_position), global_position_sub, &global_position);
|
||||
vehicle_global_position_s gpos;
|
||||
orb_copy(ORB_ID(vehicle_global_position), global_position_sub, &gpos);
|
||||
|
||||
/* copy to global struct if valid, with hysteresis */
|
||||
|
||||
// XXX consolidate this with local position handling and timeouts after release
|
||||
// but we want a low-risk change now.
|
||||
if (status.condition_global_position_valid) {
|
||||
if (gpos.eph < eph_threshold * 2.5f) {
|
||||
orb_copy(ORB_ID(vehicle_global_position), global_position_sub, &global_position);
|
||||
}
|
||||
} else {
|
||||
if (gpos.eph < eph_threshold) {
|
||||
orb_copy(ORB_ID(vehicle_global_position), global_position_sub, &global_position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* update local position estimate */
|
||||
@@ -1492,17 +1507,16 @@ int commander_thread_main(int argc, char *argv[])
|
||||
|
||||
//update condition_global_position_valid
|
||||
//Global positions are only published by the estimators if they are valid
|
||||
if(hrt_absolute_time() - global_position.timestamp > POSITION_TIMEOUT) {
|
||||
if (hrt_absolute_time() - global_position.timestamp > POSITION_TIMEOUT) {
|
||||
//We have had no good fix for POSITION_TIMEOUT amount of time
|
||||
if(status.condition_global_position_valid) {
|
||||
if (status.condition_global_position_valid) {
|
||||
set_tune_override(TONE_GPS_WARNING_TUNE);
|
||||
status_changed = true;
|
||||
status.condition_global_position_valid = false;
|
||||
}
|
||||
}
|
||||
else if(global_position.timestamp != 0) {
|
||||
//Got good global position estimate
|
||||
if(!status.condition_global_position_valid) {
|
||||
} else if (global_position.timestamp != 0) {
|
||||
// Got good global position estimate
|
||||
if (!status.condition_global_position_valid) {
|
||||
status_changed = true;
|
||||
status.condition_global_position_valid = true;
|
||||
}
|
||||
@@ -2637,7 +2651,8 @@ set_control_mode()
|
||||
|
||||
control_mode.flag_control_position_enabled = !offboard_control_mode.ignore_position;
|
||||
|
||||
control_mode.flag_control_altitude_enabled = !offboard_control_mode.ignore_position;
|
||||
control_mode.flag_control_altitude_enabled = !offboard_control_mode.ignore_velocity ||
|
||||
!offboard_control_mode.ignore_position;
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -74,6 +74,8 @@ static constexpr float POS_RESET_THRESHOLD = 5.0f; ///< Seconds before we si
|
||||
static constexpr unsigned MAG_SWITCH_HYSTERESIS = 10; ///< Ignore the first few mag failures (which amounts to a few milliseconds)
|
||||
static constexpr unsigned GYRO_SWITCH_HYSTERESIS = 5; ///< Ignore the first few gyro failures (which amounts to a few milliseconds)
|
||||
static constexpr unsigned ACCEL_SWITCH_HYSTERESIS = 5; ///< Ignore the first few accel failures (which amounts to a few milliseconds)
|
||||
static constexpr float EPH_LARGE_VALUE = 1000.0f;
|
||||
static constexpr float EPV_LARGE_VALUE = 1000.0f;
|
||||
|
||||
/**
|
||||
* estimator app start / stop handling function
|
||||
@@ -924,8 +926,16 @@ void AttitudePositionEstimatorEKF::publishGlobalPosition()
|
||||
(hrt_elapsed_time(&_distance_last_valid) < 20 * 1000 * 1000);
|
||||
|
||||
_global_pos.yaw = _local_pos.yaw;
|
||||
_global_pos.eph = _gps.eph;
|
||||
_global_pos.epv = _gps.epv;
|
||||
|
||||
const float dtLastGoodGPS = static_cast<float>(hrt_absolute_time() - _previousGPSTimestamp) / 1e6f;
|
||||
|
||||
if (_gps.timestamp_position == 0 || (dtLastGoodGPS >= POS_RESET_THRESHOLD)) {
|
||||
_global_pos.eph = EPH_LARGE_VALUE;
|
||||
_global_pos.epv = EPV_LARGE_VALUE;
|
||||
} else {
|
||||
_global_pos.eph = _gps.eph;
|
||||
_global_pos.epv = _gps.epv;
|
||||
}
|
||||
|
||||
if (!isfinite(_global_pos.lat) ||
|
||||
!isfinite(_global_pos.lon) ||
|
||||
@@ -1424,7 +1434,7 @@ void AttitudePositionEstimatorEKF::pollData()
|
||||
|
||||
// If it has gone more than POS_RESET_THRESHOLD amount of seconds since we received a GPS update,
|
||||
// then something is very wrong with the GPS (possibly a hardware failure or comlink error)
|
||||
const float dtLastGoodGPS = static_cast<float>(_gps.timestamp_position - _previousGPSTimestamp) / 1e6f;
|
||||
const float dtLastGoodGPS = static_cast<float>(hrt_absolute_time() - _previousGPSTimestamp) / 1e6f;
|
||||
|
||||
if (dtLastGoodGPS >= POS_RESET_THRESHOLD) {
|
||||
|
||||
|
||||
@@ -135,7 +135,8 @@ void Commander::SetOffboardControl(const px4::offboard_control_mode &msg_offboar
|
||||
|
||||
msg_vehicle_control_mode.flag_control_position_enabled = !msg_offboard_control_mode.ignore_position;
|
||||
|
||||
msg_vehicle_control_mode.flag_control_altitude_enabled = !msg_offboard_control_mode.ignore_position;
|
||||
msg_vehicle_control_mode.flag_control_altitude_enabled = !msg_offboard_control_mode.ignore_velocity ||
|
||||
!msg_offboard_control_mode.ignore_position;
|
||||
}
|
||||
|
||||
void Commander::EvalSwitches(const px4::manual_control_setpointConstPtr &msg,
|
||||
|
||||
Reference in New Issue
Block a user