diff options
author | Roman Bapst <romanbapst@yahoo.de> | 2015-04-22 09:53:09 +0200 |
---|---|---|
committer | Roman Bapst <romanbapst@yahoo.de> | 2015-04-22 13:32:09 +0200 |
commit | 5b772e5720ed6bc8f90316dc7632b218819543b7 (patch) | |
tree | 3975dd4c8952ce4c68dde72b5f55240adab852a6 /src/modules | |
parent | 5e584c2942a3087b5250003d05917db8769f7789 (diff) | |
download | px4-firmware-5b772e5720ed6bc8f90316dc7632b218819543b7.tar.gz px4-firmware-5b772e5720ed6bc8f90316dc7632b218819543b7.tar.bz2 px4-firmware-5b772e5720ed6bc8f90316dc7632b218819543b7.zip |
update vehicle status before doing preflight checks
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/commander/commander.cpp | 21 | ||||
-rw-r--r-- | src/modules/commander/commander_helper.cpp | 5 | ||||
-rw-r--r-- | src/modules/commander/commander_helper.h | 1 |
3 files changed, 14 insertions, 13 deletions
diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index e0634bb34..65fc8f90e 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -1125,6 +1125,10 @@ int commander_thread_main(int argc, char *argv[]) commander_initialized = true; thread_running = true; + /* update vehicle status to find out vehicle type (required for preflight checks) */ + param_get(_param_sys_type, &(status.system_type)); // get system type + status.is_rotary_wing = is_rotary_wing(&status) || is_vtol(&status); + bool checkAirspeed = false; /* Perform airspeed check only if circuit breaker is not * engaged and it's not a rotary wing */ @@ -1204,15 +1208,7 @@ int commander_thread_main(int argc, char *argv[]) } /* disable manual override for all systems that rely on electronic stabilization */ - if (status.system_type == vehicle_status_s::VEHICLE_TYPE_COAXIAL || - status.system_type == vehicle_status_s::VEHICLE_TYPE_HELICOPTER || - status.system_type == vehicle_status_s::VEHICLE_TYPE_TRICOPTER || - status.system_type == vehicle_status_s::VEHICLE_TYPE_QUADROTOR || - status.system_type == vehicle_status_s::VEHICLE_TYPE_HEXAROTOR || - status.system_type == vehicle_status_s::VEHICLE_TYPE_OCTOROTOR || - (status.system_type == vehicle_status_s::VEHICLE_TYPE_VTOL_DUOROTOR && vtol_status.vtol_in_rw_mode) || - (status.system_type == vehicle_status_s::VEHICLE_TYPE_VTOL_QUADROTOR && vtol_status.vtol_in_rw_mode)) { - + if (is_rotary_wing(&status) || (is_vtol(&status) && vtol_status.vtol_in_rw_mode)) { status.is_rotary_wing = true; } else { @@ -1220,8 +1216,7 @@ int commander_thread_main(int argc, char *argv[]) } /* set vehicle_status.is_vtol flag */ - status.is_vtol = (status.system_type == vehicle_status_s::VEHICLE_TYPE_VTOL_DUOROTOR) || - (status.system_type == vehicle_status_s::VEHICLE_TYPE_VTOL_QUADROTOR); + status.is_vtol = is_vtol(&status); /* check and update system / component ID */ param_get(_param_system_id, &(status.system_id)); @@ -1422,8 +1417,8 @@ int commander_thread_main(int argc, char *argv[]) orb_copy(ORB_ID(vtol_vehicle_status), vtol_vehicle_status_sub, &vtol_status); status.vtol_fw_permanent_stab = vtol_status.fw_permanent_stab; - /* Make sure that this is only adjusted if vehicle realy is of type vtol*/ - if ((status.system_type == vehicle_status_s::VEHICLE_TYPE_VTOL_DUOROTOR) || (status.system_type == vehicle_status_s::VEHICLE_TYPE_VTOL_QUADROTOR)) { + /* Make sure that this is only adjusted if vehicle really is of type vtol*/ + if (is_vtol(&status)) { status.is_rotary_wing = vtol_status.vtol_in_rw_mode; } } diff --git a/src/modules/commander/commander_helper.cpp b/src/modules/commander/commander_helper.cpp index a5e4d1972..5f735b7b7 100644 --- a/src/modules/commander/commander_helper.cpp +++ b/src/modules/commander/commander_helper.cpp @@ -84,6 +84,11 @@ bool is_rotary_wing(const struct vehicle_status_s *current_status) || (current_status->system_type == vehicle_status_s::VEHICLE_TYPE_COAXIAL); } +bool is_vtol(const struct vehicle_status_s * current_status) { + return current_status->system_type == vehicle_status_s::VEHICLE_TYPE_VTOL_DUOROTOR || + current_status->system_type == vehicle_status_s::VEHICLE_TYPE_VTOL_QUADROTOR; +} + static int buzzer = -1; static hrt_abstime blink_msg_end = 0; // end time for currently blinking LED message, 0 if no blink message static hrt_abstime tune_end = 0; // end time of currently played tune, 0 for repeating tunes or silence diff --git a/src/modules/commander/commander_helper.h b/src/modules/commander/commander_helper.h index 0cefedba7..bf0c0505d 100644 --- a/src/modules/commander/commander_helper.h +++ b/src/modules/commander/commander_helper.h @@ -51,6 +51,7 @@ bool is_multirotor(const struct vehicle_status_s *current_status); bool is_rotary_wing(const struct vehicle_status_s *current_status); +bool is_vtol(const struct vehicle_status_s *current_status); int buzzer_init(void); void buzzer_deinit(void); |