diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2012-12-29 11:00:15 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2012-12-29 11:00:15 +0100 |
commit | c652f718c0d2ab78fd80f503d5932ecf526136a9 (patch) | |
tree | 763656259754c8c786ae1577643eecf7d895d9b7 /apps/commander | |
parent | be85589e48cdc1b297bffe8e492cd7d69f949b4b (diff) | |
download | px4-firmware-c652f718c0d2ab78fd80f503d5932ecf526136a9.tar.gz px4-firmware-c652f718c0d2ab78fd80f503d5932ecf526136a9.tar.bz2 px4-firmware-c652f718c0d2ab78fd80f503d5932ecf526136a9.zip |
Minor fixes, pushing WIP
Diffstat (limited to 'apps/commander')
-rw-r--r-- | apps/commander/commander.c | 35 | ||||
-rw-r--r-- | apps/commander/commander.h | 3 | ||||
-rw-r--r-- | apps/commander/state_machine_helper.c | 1 |
3 files changed, 33 insertions, 6 deletions
diff --git a/apps/commander/commander.c b/apps/commander/commander.c index 50544320b..be50289c3 100644 --- a/apps/commander/commander.c +++ b/apps/commander/commander.c @@ -147,7 +147,6 @@ int commander_thread_main(int argc, char *argv[]); static int buzzer_init(void); static void buzzer_deinit(void); -static void tune_confirm(void); static int led_init(void); static void led_deinit(void); static int led_toggle(int led); @@ -272,6 +271,10 @@ void tune_confirm(void) { ioctl(buzzer, TONE_SET_ALARM, 3); } +void tune_error(void) { + ioctl(buzzer, TONE_SET_ALARM, 4); +} + void do_rc_calibration(int status_pub, struct vehicle_status_s *status) { int sub_man = orb_subscribe(ORB_ID(manual_control_setpoint)); @@ -980,8 +983,13 @@ void handle_command(int status_pub, struct vehicle_status_s *current_vehicle_sta break; case MAV_CMD_PREFLIGHT_STORAGE: { - if (current_status.flag_system_armed) { - mavlink_log_info(mavlink_fd, "[cmd] REJECTING param command while armed"); + if (current_status.flag_system_armed && + ((current_status.system_type == MAV_TYPE_QUADROTOR) || + (current_status.system_type == MAV_TYPE_HEXAROTOR) || + (current_status.system_type == MAV_TYPE_OCTOROTOR))) { + /* do not perform expensive memory tasks on multirotors in flight */ + // XXX this is over-safe, as soon as cmd is in low prio thread this can be allowed + mavlink_log_info(mavlink_fd, "[cmd] REJECTING save cmd while multicopter armed"); } else { // XXX move this to LOW PRIO THREAD of commander app @@ -1680,6 +1688,7 @@ int commander_thread_main(int argc, char *argv[]) * Check if manual control modes have to be switched */ if (!isfinite(sp_man.manual_mode_switch)) { + printf("man mode sw not finite\n"); /* this switch is not properly mapped, set default */ if ((current_status.system_type == MAV_TYPE_QUADROTOR) || @@ -1688,13 +1697,17 @@ int commander_thread_main(int argc, char *argv[]) /* assuming a rotary wing, fall back to SAS */ current_status.manual_control_mode = VEHICLE_MANUAL_CONTROL_MODE_SAS; + current_status.flag_control_attitude_enabled = true; + current_status.flag_control_rates_enabled = true; } else { /* assuming a fixed wing, fall back to direct pass-through */ current_status.manual_control_mode = VEHICLE_MANUAL_CONTROL_MODE_DIRECT; + current_status.flag_control_attitude_enabled = false; + current_status.flag_control_rates_enabled = false; } - } else if (sp_man.manual_sas_switch < -STICK_ON_OFF_LIMIT) { + } else if (sp_man.manual_mode_switch < -STICK_ON_OFF_LIMIT) { /* bottom stick position, set direct mode for vehicles supporting it */ if ((current_status.system_type == MAV_TYPE_QUADROTOR) || @@ -1703,22 +1716,32 @@ int commander_thread_main(int argc, char *argv[]) /* assuming a rotary wing, fall back to SAS */ current_status.manual_control_mode = VEHICLE_MANUAL_CONTROL_MODE_SAS; + current_status.flag_control_attitude_enabled = true; + current_status.flag_control_rates_enabled = true; } else { - /* assuming a fixed wing, fall back to direct pass-through */ + /* assuming a fixed wing, set to direct pass-through as requested */ current_status.manual_control_mode = VEHICLE_MANUAL_CONTROL_MODE_DIRECT; + current_status.flag_control_attitude_enabled = false; + current_status.flag_control_rates_enabled = false; } - } else if (sp_man.manual_sas_switch > STICK_ON_OFF_LIMIT) { + } else if (sp_man.manual_mode_switch > STICK_ON_OFF_LIMIT) { /* top stick position, set SAS for all vehicle types */ current_status.manual_control_mode = VEHICLE_MANUAL_CONTROL_MODE_SAS; + current_status.flag_control_attitude_enabled = true; + current_status.flag_control_rates_enabled = true; } else { /* center stick position, set rate control */ current_status.manual_control_mode = VEHICLE_MANUAL_CONTROL_MODE_RATES; + current_status.flag_control_attitude_enabled = false; + current_status.flag_control_rates_enabled = true; } + printf("man ctrl mode: %d\n", (int)current_status.manual_control_mode); + /* * Check if manual stability control modes have to be switched */ diff --git a/apps/commander/commander.h b/apps/commander/commander.h index bea67bead..04b4e72ab 100644 --- a/apps/commander/commander.h +++ b/apps/commander/commander.h @@ -52,4 +52,7 @@ #define LOW_VOLTAGE_BATTERY_HYSTERESIS_TIME_MS 1000.0f #define CRITICAL_VOLTAGE_BATTERY_HYSTERESIS_TIME_MS 100.0f +void tune_confirm(void); +void tune_error(void); + #endif /* COMMANDER_H_ */ diff --git a/apps/commander/state_machine_helper.c b/apps/commander/state_machine_helper.c index 4152142df..a8cef8c01 100644 --- a/apps/commander/state_machine_helper.c +++ b/apps/commander/state_machine_helper.c @@ -535,6 +535,7 @@ void update_state_machine_mode_stabilized(int status_pub, struct vehicle_status_ { if (!current_status->flag_vector_flight_mode_ok) { mavlink_log_critical(mavlink_fd, "NO POS LOCK, REJ. STAB MODE"); + tune_error(); return; } if (current_status->state_machine == SYSTEM_STATE_GROUND_READY || current_status->state_machine == SYSTEM_STATE_MANUAL || current_status->state_machine == SYSTEM_STATE_AUTO) { |