Skip to content

Commit

Permalink
arm/disarm via remote working
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed May 3, 2017
1 parent f79fa19 commit 997dc09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions AirLib/include/controllers/rosflight/firmware/mode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ void Mode::init(Board* _board, CommLink* _comm_link, CommonState* _common_state,
bool Mode::arm(void)
{
bool success = false;
if (!started_gyro_calibration && common_state->is_disarmed())
if (!started_gyro_calibration)
{
comm_link->log_message("Cannot arm because gyro calibration is not complete", 1);
if (common_state->is_disarmed())
comm_link->log_message("Cannot arm because gyro calibration is not complete", 1);

sensors->start_gyro_calibration();
started_gyro_calibration = true;
Expand Down Expand Up @@ -125,7 +126,7 @@ void Mode::updateCommLinkArmStatus()
if (common_state->is_armed())
comm_link->log_message("Vehicle is now armed", 0);
else if (common_state->is_disarmed())
comm_link->log_message("Vehicle is now armed", 0);
comm_link->log_message("Vehicle is now disarmed", 0);
else
comm_link->log_message("Attempt to arm or disarm failed", 0);

Expand Down Expand Up @@ -192,11 +193,12 @@ bool Mode::check_mode(uint64_t now)
{
if (rc->rc_switch(params->get_param_int(Params::PARAM_ARM_CHANNEL)))
{
if (common_state->get_armed_state() == CommonState::DISARMED)
if (common_state->is_disarmed())
arm();
} else
{
disarm();
if (common_state->is_armed())
disarm();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion AirLib/include/controllers/rosflight/firmware/param.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ void Params::set_param_defaults(void)
/*** ARMING SETUP ***/
/********************/
init_param_int(PARAM_ARM_STICKS, "ARM_STICKS", false); // use RC sticks to arm vehicle (disables arm RC switch if enabled) | 0 | 1
init_param_int(PARAM_ARM_CHANNEL, "ARM_CHANNEL", 8); // RC switch mapped to arm/disarm [0 -indexed] | 4 | 7
init_param_int(PARAM_ARM_CHANNEL, "ARM_CHANNEL", 4); // RC switch mapped to arm/disarm [0 -indexed] | 4 | 7
init_param_int(PARAM_ARM_THRESHOLD, "ARM_THRESHOLD", 150); // RC deviation from max/min in yaw and throttle for arming and disarming check (us) | 0 | 500
}

Expand Down

0 comments on commit 997dc09

Please sign in to comment.