mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-17 07:30:36 +08:00
modules: commander: Group arm requirements in just one byte and add a new requirement
Instead of having several bools to each requirement to arm, lets group then in a byte and use bitmask. This also add a new arm requirement "arm authorization" that will be implemented in another patch.
This commit is contained in:
committed by
Lorenz Meier
parent
e5924f8172
commit
7e3ab95975
@@ -251,8 +251,7 @@ static uint64_t rc_signal_lost_timestamp; // Time at which the RC reception was
|
||||
|
||||
static float avionics_power_rail_voltage; // voltage of the avionics power rail
|
||||
|
||||
static bool arm_without_gps = false;
|
||||
static bool arm_mission_required = false;
|
||||
static uint8_t arm_requirements = ARM_REQ_NONE;
|
||||
|
||||
static bool _last_condition_global_position_valid = false;
|
||||
|
||||
@@ -468,10 +467,10 @@ int commander_main(int argc, char *argv[])
|
||||
|
||||
if (!strcmp(argv[1], "check")) {
|
||||
int checkres = 0;
|
||||
checkres = preflight_check(&status, &mavlink_log_pub, false, true, &status_flags, &battery, true, false, hrt_elapsed_time(&commander_boot_timestamp));
|
||||
checkres = preflight_check(&status, &mavlink_log_pub, false, true, &status_flags, &battery, ARM_REQ_GPS_BIT, hrt_elapsed_time(&commander_boot_timestamp));
|
||||
warnx("Preflight check: %s", (checkres == 0) ? "OK" : "FAILED");
|
||||
|
||||
checkres = preflight_check(&status, &mavlink_log_pub, true, true, &status_flags, &battery, arm_without_gps, arm_mission_required, hrt_elapsed_time(&commander_boot_timestamp));
|
||||
checkres = preflight_check(&status, &mavlink_log_pub, true, true, &status_flags, &battery, arm_requirements, hrt_elapsed_time(&commander_boot_timestamp));
|
||||
warnx("Prearm check: %s", (checkres == 0) ? "OK" : "FAILED");
|
||||
|
||||
return 0;
|
||||
@@ -742,8 +741,7 @@ transition_result_t arm_disarm(bool arm, orb_advert_t *mavlink_log_pub_local, co
|
||||
mavlink_log_pub_local,
|
||||
&status_flags,
|
||||
avionics_power_rail_voltage,
|
||||
arm_without_gps,
|
||||
arm_mission_required,
|
||||
arm_requirements,
|
||||
hrt_elapsed_time(&commander_boot_timestamp));
|
||||
|
||||
if (arming_res == TRANSITION_CHANGED) {
|
||||
@@ -1728,11 +1726,11 @@ int commander_thread_main(int argc, char *argv[])
|
||||
|
||||
int32_t arm_without_gps_param = 0;
|
||||
param_get(_param_arm_without_gps, &arm_without_gps_param);
|
||||
arm_without_gps = (arm_without_gps_param == 1);
|
||||
arm_requirements = arm_without_gps_param == 1 ? ARM_REQ_NONE : ARM_REQ_GPS_BIT;
|
||||
|
||||
int32_t arm_mission_required_param = 0;
|
||||
param_get(_param_arm_mission_required, &arm_mission_required_param);
|
||||
arm_mission_required = (arm_mission_required_param == 1);
|
||||
arm_requirements |= (arm_mission_required_param & (ARM_REQ_MISSION_BIT | ARM_REQ_ARM_AUTH_BIT));
|
||||
|
||||
status.rc_input_mode = rc_in_off;
|
||||
if (status.hil_state == vehicle_status_s::HIL_STATE_ON) {
|
||||
@@ -1880,10 +1878,9 @@ int commander_thread_main(int argc, char *argv[])
|
||||
param_get(_param_arm_switch_is_button, &arm_switch_is_button);
|
||||
|
||||
param_get(_param_arm_without_gps, &arm_without_gps_param);
|
||||
arm_without_gps = (arm_without_gps_param == 1);
|
||||
|
||||
arm_requirements = arm_without_gps_param == 1 ? ARM_REQ_NONE : ARM_REQ_GPS_BIT;
|
||||
param_get(_param_arm_mission_required, &arm_mission_required_param);
|
||||
arm_mission_required = (arm_mission_required_param == 1);
|
||||
arm_requirements |= (arm_mission_required_param & (ARM_REQ_MISSION_BIT | ARM_REQ_ARM_AUTH_BIT));
|
||||
|
||||
/* Autostart id */
|
||||
param_get(_param_autostart_id, &autostart_id);
|
||||
@@ -2009,7 +2006,7 @@ int commander_thread_main(int argc, char *argv[])
|
||||
} else {
|
||||
/* check sensors also */
|
||||
(void)Commander::preflightCheck(&mavlink_log_pub, true, true, true, true, checkAirspeed,
|
||||
(status.rc_input_mode == vehicle_status_s::RC_IN_MODE_DEFAULT), !arm_without_gps,
|
||||
(status.rc_input_mode == vehicle_status_s::RC_IN_MODE_DEFAULT), arm_requirements & ARM_REQ_GPS_BIT,
|
||||
/* checkDynamic */ true, is_vtol(&status), /* reportFailures */ hotplug_timeout, /* prearm */ false, hrt_elapsed_time(&commander_boot_timestamp));
|
||||
}
|
||||
|
||||
@@ -2125,8 +2122,7 @@ int commander_thread_main(int argc, char *argv[])
|
||||
&mavlink_log_pub,
|
||||
&status_flags,
|
||||
avionics_power_rail_voltage,
|
||||
arm_without_gps,
|
||||
arm_mission_required,
|
||||
arm_requirements,
|
||||
hrt_elapsed_time(&commander_boot_timestamp))) {
|
||||
arming_state_changed = true;
|
||||
}
|
||||
@@ -2437,8 +2433,7 @@ int commander_thread_main(int argc, char *argv[])
|
||||
&mavlink_log_pub,
|
||||
&status_flags,
|
||||
avionics_power_rail_voltage,
|
||||
arm_without_gps,
|
||||
arm_mission_required,
|
||||
arm_requirements,
|
||||
hrt_elapsed_time(&commander_boot_timestamp));
|
||||
|
||||
if (arming_ret == TRANSITION_CHANGED) {
|
||||
@@ -2734,8 +2729,7 @@ int commander_thread_main(int argc, char *argv[])
|
||||
&mavlink_log_pub,
|
||||
&status_flags,
|
||||
avionics_power_rail_voltage,
|
||||
arm_without_gps,
|
||||
arm_mission_required,
|
||||
arm_requirements,
|
||||
hrt_elapsed_time(&commander_boot_timestamp));
|
||||
|
||||
if (arming_ret == TRANSITION_CHANGED) {
|
||||
@@ -2789,8 +2783,7 @@ int commander_thread_main(int argc, char *argv[])
|
||||
&mavlink_log_pub,
|
||||
&status_flags,
|
||||
avionics_power_rail_voltage,
|
||||
arm_without_gps,
|
||||
arm_mission_required,
|
||||
arm_requirements,
|
||||
hrt_elapsed_time(&commander_boot_timestamp));
|
||||
|
||||
if (arming_ret == TRANSITION_CHANGED) {
|
||||
@@ -4234,8 +4227,7 @@ void *commander_low_prio_loop(void *arg)
|
||||
&mavlink_log_pub,
|
||||
&status_flags,
|
||||
avionics_power_rail_voltage,
|
||||
arm_without_gps,
|
||||
arm_mission_required,
|
||||
arm_requirements,
|
||||
hrt_elapsed_time(&commander_boot_timestamp))) {
|
||||
|
||||
answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_DENIED, command_ack_pub);
|
||||
@@ -4330,7 +4322,7 @@ void *commander_low_prio_loop(void *arg)
|
||||
}
|
||||
|
||||
status_flags.condition_system_sensors_initialized = Commander::preflightCheck(&mavlink_log_pub, true, true, true, true, checkAirspeed,
|
||||
!(status.rc_input_mode >= vehicle_status_s::RC_IN_MODE_OFF), !arm_without_gps,
|
||||
!(status.rc_input_mode >= vehicle_status_s::RC_IN_MODE_OFF), arm_requirements & ARM_REQ_GPS_BIT,
|
||||
/* checkDynamic */ true, is_vtol(&status), /* reportFailures */ hotplug_timeout, /* prearm */ false, hrt_elapsed_time(&commander_boot_timestamp));
|
||||
|
||||
arming_state_transition(&status,
|
||||
@@ -4342,8 +4334,7 @@ void *commander_low_prio_loop(void *arg)
|
||||
&mavlink_log_pub,
|
||||
&status_flags,
|
||||
avionics_power_rail_voltage,
|
||||
arm_without_gps,
|
||||
arm_mission_required,
|
||||
arm_requirements,
|
||||
hrt_elapsed_time(&commander_boot_timestamp));
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user