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

Merge ftc #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
43 changes: 25 additions & 18 deletions src/ikSensorDiagnoser/ikSensorDiagnoser.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,44 +54,51 @@ int ikSensorDiagnoser_init(ikSensorDiagnoser *self, const ikSensorDiagnoserParam
self->tol = 1.0;
if (!err) err = -2;
}

/* initilise fault states */
for (i = 0; i < 3; i++) self->ok[i] = self->n;

return err;

}

void ikSensorDiagnoser_step(ikSensorDiagnoser *self, int ok[3], const double signals[3]) {
int i,j;
int _ok[3] = {0,0,0};

/* check tolerances */
for(i = 0; i < 3; i++) {
j = i + 1;
if(j > 2) j = 0;
if(self->tol > fabs(signals[i] - signals[j])) {
if (self->ok[i] && self->ok[j]) {
_ok[i] = 1;
_ok[j] = 1;
}
}
}

/* check tolerances */
for(i = 0; i < 3; i++) {
j = i + 1;
if(j > 2) j = 0;
if(self->tol > fabs(signals[i] - signals[j])) {
if (self->ok[i] && self->ok[j]) {
_ok[i] = 1;
_ok[j] = 1;
}
}
}
/* compute steps left for fault detection */
for(i = 0; i < 3; i++) {
self->ok[i]--;
self->ok[i] = self->ok[i] > 0 ? self->ok[i] : 0;
if (_ok[i]) self->ok[i] = self->n;
}


/*
####################################################################
*/
if(self->ResetSignal > 0){
for(i = 0; i < 3; i++) {
self->ok[i] = 1;
self->ok[i] = self->n;
}
}
/* set outputs */
ikSensorDiagnoser_getOutput(self, ok);
}

void ikSensorDiagnoser_getOutput(const ikSensorDiagnoser *self, int ok[3]) {
int i;
for(i = 0; i < 3; i++) ok[i] = self->ok[i] > 0;

for(i = 0; i < 3; i++) ok[i] = self->ok[i] > 0;
}

/* @endcond */
1 change: 1 addition & 0 deletions src/ikSensorDiagnoser/ikSensorDiagnoser.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ extern "C" {
int ok[3];
int n;
double tol;
int ResetSignal;
/* @endcond */
} ikSensorDiagnoser;

Expand Down