Browse Source

commander: don't notify user about rejected disarm to not confuse, flag_control_altitude_enabled added, flags values fixed

sbg
Anton Babushkin 12 years ago
parent
commit
7c1693a877
  1. 39
      src/modules/commander/commander.cpp
  2. 24
      src/modules/commander/state_machine_helper.cpp
  3. 1
      src/modules/uORB/topics/vehicle_control_mode.h

39
src/modules/commander/commander.cpp

@ -1398,30 +1398,18 @@ int commander_thread_main(int argc, char *argv[])
} }
} }
/* /* Check if left stick is in lower left position and we're in manual mode --> switch to standby state.
* Check if left stick is in lower left position --> switch to standby state. * Do this only for multirotors, not for fixed wing aircraft.
* Do this only for multirotors, not for fixed wing aircraft. * TODO allow disarm when landed
*/ */
if ((sp_man.yaw < -STICK_ON_OFF_LIMIT) && (sp_man.throttle < STICK_THRUST_RANGE * 0.1f)) { if (sp_man.yaw < -STICK_ON_OFF_LIMIT && sp_man.throttle < STICK_THRUST_RANGE * 0.1f &&
control_mode.flag_control_manual_enabled &&
((current_status.system_type == VEHICLE_TYPE_QUADROTOR) ||
(current_status.system_type == VEHICLE_TYPE_HEXAROTOR) ||
(current_status.system_type == VEHICLE_TYPE_OCTOROTOR))) {
if (stick_off_counter > STICK_ON_OFF_COUNTER_LIMIT) { if (stick_off_counter > STICK_ON_OFF_COUNTER_LIMIT) {
arming_state_transition(status_pub, &current_status, ARMING_STATE_STANDBY, armed_pub, &armed, mavlink_fd);
if((current_status.system_type == VEHICLE_TYPE_QUADROTOR) || tune_positive();
(current_status.system_type == VEHICLE_TYPE_HEXAROTOR) ||
(current_status.system_type == VEHICLE_TYPE_OCTOROTOR)
) {
if (control_mode.flag_control_position_enabled || control_mode.flag_control_velocity_enabled) {
mavlink_log_critical(mavlink_fd, "DISARM DENY, go manual mode first");
tune_negative();
} else {
arming_state_transition(status_pub, &current_status, ARMING_STATE_STANDBY, armed_pub, &armed, mavlink_fd);
tune_positive();
}
} else {
mavlink_log_critical(mavlink_fd, "DISARM not allowed");
tune_negative();
}
stick_off_counter = 0; stick_off_counter = 0;
} else { } else {
@ -1430,9 +1418,8 @@ int commander_thread_main(int argc, char *argv[])
} }
} }
/* check if left stick is in lower right position and we're in manual --> arm */ /* check if left stick is in lower right position and we're in manual mode --> arm */
if (sp_man.yaw > STICK_ON_OFF_LIMIT && if (sp_man.yaw > STICK_ON_OFF_LIMIT && sp_man.throttle < STICK_THRUST_RANGE * 0.1f) {
sp_man.throttle < STICK_THRUST_RANGE * 0.1f) {
if (stick_on_counter > STICK_ON_OFF_COUNTER_LIMIT) { if (stick_on_counter > STICK_ON_OFF_COUNTER_LIMIT) {
arming_state_transition(status_pub, &current_status, ARMING_STATE_ARMED, armed_pub, &armed, mavlink_fd); arming_state_transition(status_pub, &current_status, ARMING_STATE_ARMED, armed_pub, &armed, mavlink_fd);
stick_on_counter = 0; stick_on_counter = 0;

24
src/modules/commander/state_machine_helper.cpp

@ -192,6 +192,7 @@ int navigation_state_transition(int status_pub, struct vehicle_status_s *current
control_mode->flag_control_attitude_enabled = false; control_mode->flag_control_attitude_enabled = false;
control_mode->flag_control_velocity_enabled = false; control_mode->flag_control_velocity_enabled = false;
control_mode->flag_control_position_enabled = false; control_mode->flag_control_position_enabled = false;
control_mode->flag_control_altitude_enabled = false;
control_mode->flag_control_manual_enabled = false; control_mode->flag_control_manual_enabled = false;
} }
break; break;
@ -214,6 +215,7 @@ int navigation_state_transition(int status_pub, struct vehicle_status_s *current
control_mode->flag_control_attitude_enabled = true; control_mode->flag_control_attitude_enabled = true;
control_mode->flag_control_velocity_enabled = false; control_mode->flag_control_velocity_enabled = false;
control_mode->flag_control_position_enabled = false; control_mode->flag_control_position_enabled = false;
control_mode->flag_control_altitude_enabled = false;
control_mode->flag_control_manual_enabled = true; control_mode->flag_control_manual_enabled = true;
} }
} }
@ -231,6 +233,7 @@ int navigation_state_transition(int status_pub, struct vehicle_status_s *current
control_mode->flag_control_attitude_enabled = true; control_mode->flag_control_attitude_enabled = true;
control_mode->flag_control_velocity_enabled = false; control_mode->flag_control_velocity_enabled = false;
control_mode->flag_control_position_enabled = false; control_mode->flag_control_position_enabled = false;
control_mode->flag_control_altitude_enabled = false;
control_mode->flag_control_manual_enabled = true; control_mode->flag_control_manual_enabled = true;
} }
break; break;
@ -258,7 +261,8 @@ int navigation_state_transition(int status_pub, struct vehicle_status_s *current
control_mode->flag_control_attitude_enabled = true; control_mode->flag_control_attitude_enabled = true;
control_mode->flag_control_velocity_enabled = true; control_mode->flag_control_velocity_enabled = true;
control_mode->flag_control_position_enabled = false; control_mode->flag_control_position_enabled = false;
control_mode->flag_control_manual_enabled = false; control_mode->flag_control_altitude_enabled = true;
control_mode->flag_control_manual_enabled = true;
} }
} }
break; break;
@ -290,7 +294,8 @@ int navigation_state_transition(int status_pub, struct vehicle_status_s *current
control_mode->flag_control_attitude_enabled = true; control_mode->flag_control_attitude_enabled = true;
control_mode->flag_control_velocity_enabled = true; control_mode->flag_control_velocity_enabled = true;
control_mode->flag_control_position_enabled = false; control_mode->flag_control_position_enabled = false;
control_mode->flag_control_manual_enabled = false; control_mode->flag_control_altitude_enabled = true;
control_mode->flag_control_manual_enabled = true;
} }
} }
break; break;
@ -321,8 +326,9 @@ int navigation_state_transition(int status_pub, struct vehicle_status_s *current
control_mode->flag_control_rates_enabled = true; control_mode->flag_control_rates_enabled = true;
control_mode->flag_control_attitude_enabled = true; control_mode->flag_control_attitude_enabled = true;
control_mode->flag_control_velocity_enabled = true; control_mode->flag_control_velocity_enabled = true;
control_mode->flag_control_position_enabled = false; control_mode->flag_control_position_enabled = true;
control_mode->flag_control_manual_enabled = false; control_mode->flag_control_altitude_enabled = true;
control_mode->flag_control_manual_enabled = true;
} }
} }
break; break;
@ -353,7 +359,8 @@ int navigation_state_transition(int status_pub, struct vehicle_status_s *current
control_mode->flag_control_attitude_enabled = true; control_mode->flag_control_attitude_enabled = true;
control_mode->flag_control_velocity_enabled = true; control_mode->flag_control_velocity_enabled = true;
control_mode->flag_control_position_enabled = false; control_mode->flag_control_position_enabled = false;
control_mode->flag_control_manual_enabled = false; control_mode->flag_control_altitude_enabled = true;
control_mode->flag_control_manual_enabled = true;
} }
} }
break; break;
@ -382,6 +389,7 @@ int navigation_state_transition(int status_pub, struct vehicle_status_s *current
control_mode->flag_control_attitude_enabled = true; control_mode->flag_control_attitude_enabled = true;
control_mode->flag_control_velocity_enabled = true; control_mode->flag_control_velocity_enabled = true;
control_mode->flag_control_position_enabled = true; control_mode->flag_control_position_enabled = true;
control_mode->flag_control_altitude_enabled = true;
control_mode->flag_control_manual_enabled = false; control_mode->flag_control_manual_enabled = false;
} }
} }
@ -405,6 +413,7 @@ int navigation_state_transition(int status_pub, struct vehicle_status_s *current
control_mode->flag_control_attitude_enabled = true; control_mode->flag_control_attitude_enabled = true;
control_mode->flag_control_velocity_enabled = true; control_mode->flag_control_velocity_enabled = true;
control_mode->flag_control_position_enabled = true; control_mode->flag_control_position_enabled = true;
control_mode->flag_control_altitude_enabled = true;
control_mode->flag_control_manual_enabled = false; control_mode->flag_control_manual_enabled = false;
} }
} }
@ -420,6 +429,7 @@ int navigation_state_transition(int status_pub, struct vehicle_status_s *current
control_mode->flag_control_attitude_enabled = true; control_mode->flag_control_attitude_enabled = true;
control_mode->flag_control_velocity_enabled = true; control_mode->flag_control_velocity_enabled = true;
control_mode->flag_control_position_enabled = true; control_mode->flag_control_position_enabled = true;
control_mode->flag_control_altitude_enabled = true;
control_mode->flag_control_manual_enabled = false; control_mode->flag_control_manual_enabled = false;
} }
break; break;
@ -447,6 +457,7 @@ int navigation_state_transition(int status_pub, struct vehicle_status_s *current
control_mode->flag_control_attitude_enabled = true; control_mode->flag_control_attitude_enabled = true;
control_mode->flag_control_velocity_enabled = true; control_mode->flag_control_velocity_enabled = true;
control_mode->flag_control_position_enabled = true; control_mode->flag_control_position_enabled = true;
control_mode->flag_control_altitude_enabled = true;
control_mode->flag_control_manual_enabled = false; control_mode->flag_control_manual_enabled = false;
} }
} }
@ -472,6 +483,7 @@ int navigation_state_transition(int status_pub, struct vehicle_status_s *current
control_mode->flag_control_attitude_enabled = true; control_mode->flag_control_attitude_enabled = true;
control_mode->flag_control_velocity_enabled = true; control_mode->flag_control_velocity_enabled = true;
control_mode->flag_control_position_enabled = true; control_mode->flag_control_position_enabled = true;
control_mode->flag_control_altitude_enabled = true;
control_mode->flag_control_manual_enabled = false; control_mode->flag_control_manual_enabled = false;
} }
} }
@ -500,6 +512,7 @@ int navigation_state_transition(int status_pub, struct vehicle_status_s *current
control_mode->flag_control_attitude_enabled = true; control_mode->flag_control_attitude_enabled = true;
control_mode->flag_control_velocity_enabled = true; control_mode->flag_control_velocity_enabled = true;
control_mode->flag_control_position_enabled = true; control_mode->flag_control_position_enabled = true;
control_mode->flag_control_altitude_enabled = true;
control_mode->flag_control_manual_enabled = false; control_mode->flag_control_manual_enabled = false;
} }
} }
@ -524,6 +537,7 @@ int navigation_state_transition(int status_pub, struct vehicle_status_s *current
control_mode->flag_control_attitude_enabled = true; control_mode->flag_control_attitude_enabled = true;
control_mode->flag_control_velocity_enabled = true; control_mode->flag_control_velocity_enabled = true;
control_mode->flag_control_position_enabled = true; control_mode->flag_control_position_enabled = true;
control_mode->flag_control_altitude_enabled = true;
control_mode->flag_control_manual_enabled = false; control_mode->flag_control_manual_enabled = false;
} }
} }

1
src/modules/uORB/topics/vehicle_control_mode.h

@ -77,6 +77,7 @@ struct vehicle_control_mode_s
bool flag_control_attitude_enabled; /**< true if attitude stabilization is mixed in */ bool flag_control_attitude_enabled; /**< true if attitude stabilization is mixed in */
bool flag_control_velocity_enabled; /**< true if speed (implies direction) is controlled */ bool flag_control_velocity_enabled; /**< true if speed (implies direction) is controlled */
bool flag_control_position_enabled; /**< true if position is controlled */ bool flag_control_position_enabled; /**< true if position is controlled */
bool flag_control_altitude_enabled; /**< true if altitude is controlled */
bool failsave_lowlevel; /**< Set to true if low-level failsafe mode is enabled */ bool failsave_lowlevel; /**< Set to true if low-level failsafe mode is enabled */
bool failsave_highlevel; /**< Set to true if high-level failsafe mode is enabled */ bool failsave_highlevel; /**< Set to true if high-level failsafe mode is enabled */

Loading…
Cancel
Save