Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added locked info to supervisor #1321

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/modules/interface/supervisor.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,11 @@ bool supervisorCanArm();
* @return false
*/
bool supervisorIsArmed();

/**
* @brief Query if the system is locked (due to a crash)
*
* @return true
* @return false
*/
bool supervisorIsLocked();
8 changes: 8 additions & 0 deletions src/modules/src/supervisor.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ bool supervisorIsArmed() {
return supervisorMem.isArmingActivated || supervisorMem.deprecatedArmParam;
}

bool supervisorIsLocked() {
return supervisorStateLocked == supervisorMem.state;
}

bool supervisorRequestArming(const bool doArm) {
if (doArm == supervisorMem.isArmingActivated) {
return true;
Expand Down Expand Up @@ -305,6 +309,9 @@ static void updateLogData(SupervisorMem_t* this, const supervisorConditionBits_t
if (this->isTumbled) {
this->infoBitfield |= 0x0020;
}
if (supervisorStateLocked == this->state) {
this->infoBitfield |= 0x0040;
}
}

void supervisorUpdate(const sensorData_t *sensors, const setpoint_t* setpoint, stabilizerStep_t stabilizerStep) {
Expand Down Expand Up @@ -440,6 +447,7 @@ LOG_GROUP_START(supervisor)
* Bit 3 = can fly - the Crazyflie is ready to fly
* Bit 4 = is flying - the Crazyflie is flying.
* Bit 5 = is tumbled - the Crazyflie is up side down.
* Bit 6 = is locked - the Crazyflie is in the locked state and must be restarted.
*/
LOG_ADD(LOG_UINT16, info, &supervisorMem.infoBitfield)
LOG_GROUP_STOP(supervisor)
Expand Down