mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 06:01:35 +08:00
Correctly do position lock led signalling on IO and position lock measurement on FMU, tested with HIL.
This commit is contained in:
@@ -1476,21 +1476,45 @@ int commander_thread_main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* End battery voltage check */
|
/* End battery voltage check */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check for valid position information.
|
||||||
|
*
|
||||||
|
* If the system has a valid position source from an onboard
|
||||||
|
* position estimator, it is safe to operate it autonomously.
|
||||||
|
* The flag_vector_flight_mode_ok flag indicates that a minimum
|
||||||
|
* set of position measurements is available.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* store current state to reason later about a state change */
|
||||||
bool vector_flight_mode_ok = current_status.flag_vector_flight_mode_ok;
|
bool vector_flight_mode_ok = current_status.flag_vector_flight_mode_ok;
|
||||||
bool global_pos_valid = current_status.flag_global_position_valid;
|
bool global_pos_valid = current_status.flag_global_position_valid;
|
||||||
bool local_pos_valid = current_status.flag_local_position_valid;
|
bool local_pos_valid = current_status.flag_local_position_valid;
|
||||||
|
|
||||||
/* check for global or local position updates, set a timeout of 2s */
|
/* check for global or local position updates, set a timeout of 2s */
|
||||||
if (hrt_absolute_time() - last_global_position_time < 2000000) {
|
if (hrt_absolute_time() - last_global_position_time < 2000000) {
|
||||||
current_status.flag_vector_flight_mode_ok = true;
|
|
||||||
current_status.flag_global_position_valid = true;
|
current_status.flag_global_position_valid = true;
|
||||||
// XXX check for controller status and home position as well
|
// XXX check for controller status and home position as well
|
||||||
|
} else {
|
||||||
|
current_status.flag_global_position_valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hrt_absolute_time() - last_local_position_time < 2000000) {
|
if (hrt_absolute_time() - last_local_position_time < 2000000) {
|
||||||
current_status.flag_vector_flight_mode_ok = true;
|
|
||||||
current_status.flag_local_position_valid = true;
|
current_status.flag_local_position_valid = true;
|
||||||
// XXX check for controller status and home position as well
|
// XXX check for controller status and home position as well
|
||||||
|
} else {
|
||||||
|
current_status.flag_local_position_valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Consolidate global position and local position valid flags
|
||||||
|
* for vector flight mode.
|
||||||
|
*/
|
||||||
|
if (current_status.flag_local_position_valid ||
|
||||||
|
current_status.flag_global_position_valid) {
|
||||||
|
current_status.flag_vector_flight_mode_ok = true;
|
||||||
|
} else {
|
||||||
|
current_status.flag_vector_flight_mode_ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* consolidate state change, flag as changed if required */
|
/* consolidate state change, flag as changed if required */
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ static unsigned counter = 0;
|
|||||||
* Define the various LED flash sequences for each system state.
|
* Define the various LED flash sequences for each system state.
|
||||||
*/
|
*/
|
||||||
#define LED_PATTERN_SAFE 0xffff /**< always on */
|
#define LED_PATTERN_SAFE 0xffff /**< always on */
|
||||||
#define LED_PATTERN_VECTOR_FLIGHT_MODE_OK 0x3000 /**< always on with short break */
|
#define LED_PATTERN_VECTOR_FLIGHT_MODE_OK 0xFFFE /**< always on with short break */
|
||||||
#define LED_PATTERN_FMU_ARMED 0x4444 /**< slow blinking */
|
#define LED_PATTERN_FMU_ARMED 0x4444 /**< slow blinking */
|
||||||
#define LED_PATTERN_IO_ARMED 0x5555 /**< fast blinking */
|
#define LED_PATTERN_IO_ARMED 0x5555 /**< fast blinking */
|
||||||
#define LED_PATTERN_IO_FMU_ARMED 0x5050 /**< long off then double blink */
|
#define LED_PATTERN_IO_FMU_ARMED 0x5050 /**< long off then double blink */
|
||||||
|
|||||||
Reference in New Issue
Block a user