Skip to content

Commit

Permalink
#315 Updated outlier filter
Browse files Browse the repository at this point in the history
Changed double to float
Removed unused estimated position param
  • Loading branch information
krichardsson committed May 22, 2018
1 parent a504122 commit a5dd1d5
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/deck/drivers/interface/outlierFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include "stabilizer_types.h"

bool outlierFilterValidateTdoa(tdoaMeasurement_t* tdoa, point_t* estimatedPosition);
bool outlierFilterValidateTdoa(tdoaMeasurement_t* tdoa);
void outlierFilterReset();

#endif // __OUTLIER_FILTER_H__
5 changes: 1 addition & 4 deletions src/deck/drivers/src/lpsTdoa2Tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ static uint64_t truncateToAnchorTimeStamp(uint64_t fullTimeStamp) {
}

static void enqueueTDOA(uint8_t anchorA, uint8_t anchorB, double distanceDiff) {
point_t estimatedPos;
estimatorKalmanGetEstimatedPos(&estimatedPos);

tdoaMeasurement_t tdoa = {
.stdDev = MEASUREMENT_NOISE_STD,
.distanceDiff = distanceDiff,
Expand All @@ -118,7 +115,7 @@ static void enqueueTDOA(uint8_t anchorA, uint8_t anchorB, double distanceDiff) {
.anchorPosition[1] = options->anchorPosition[anchorB]
};

if (outlierFilterValidateTdoa(&tdoa, &estimatedPos)) {
if (outlierFilterValidateTdoa(&tdoa)) {
if (options->combinedAnchorPositionOk ||
(options->anchorPosition[anchorA].timestamp && options->anchorPosition[anchorB].timestamp)) {
stats.packetsToEstimator++;
Expand Down
5 changes: 1 addition & 4 deletions src/deck/drivers/src/lpsTdoaTagEngine.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,13 @@ static uint64_t truncateToAnchorTimeStamp(uint64_t fullTimeStamp) {
}

static void enqueueTDOA(const anchorInfo_t* anchorACtx, const anchorInfo_t* anchorBCtx, double distanceDiff) {
point_t estimatedPos;
estimatorKalmanGetEstimatedPos(&estimatedPos);

tdoaMeasurement_t tdoa = {
.stdDev = MEASUREMENT_NOISE_STD,
.distanceDiff = distanceDiff
};

if (getAnchorPosition(anchorACtx, &tdoa.anchorPosition[0]) && getAnchorPosition(anchorBCtx, &tdoa.anchorPosition[1])) {
if (outlierFilterValidateTdoa(&tdoa, &estimatedPos)) {
if (outlierFilterValidateTdoa(&tdoa)) {
lpsTdoaStats.packetsToEstimator++;
estimatorKalmanEnqueueTDOA(&tdoa);

Expand Down
12 changes: 6 additions & 6 deletions src/deck/drivers/src/outlierFilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
#include "outlierFilter.h"

static bool isDistanceDiffSmallerThanDistanceBetweenAnchors(tdoaMeasurement_t* tdoa);
static double distanceSq(const point_t* a, const point_t* b);
static double sq(double a) {return a * a;}
static float distanceSq(const point_t* a, const point_t* b);
static float sq(float a) {return a * a;}


bool outlierFilterValidateTdoa(tdoaMeasurement_t* tdoa, point_t* estimatedPosition) {
bool outlierFilterValidateTdoa(tdoaMeasurement_t* tdoa) {
return isDistanceDiffSmallerThanDistanceBetweenAnchors(tdoa);
}

Expand All @@ -41,11 +41,11 @@ void outlierFilterReset() {
}

static bool isDistanceDiffSmallerThanDistanceBetweenAnchors(tdoaMeasurement_t* tdoa) {
double anchorDistanceSq = distanceSq(&tdoa->anchorPosition[0], &tdoa->anchorPosition[1]);
double distanceDiffSq = sq(tdoa->distanceDiff);
float anchorDistanceSq = distanceSq(&tdoa->anchorPosition[0], &tdoa->anchorPosition[1]);
float distanceDiffSq = sq(tdoa->distanceDiff);
return (distanceDiffSq < anchorDistanceSq);
}

static double distanceSq(const point_t* a, const point_t* b) {
static float distanceSq(const point_t* a, const point_t* b) {
return sq(a->x - b->x) + sq(a->y - b->y) + sq(a->z - b->z);
}
1 change: 0 additions & 1 deletion test/deck/drivers/src/TestLpsTdoa2Tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ void setUp(void) {
dwGetReceiveTimestamp_resetMock();

mockKalmanEstimator_resetMock();
estimatorKalmanGetEstimatedPos_Ignore();

options.combinedAnchorPositionOk = true;

Expand Down
7 changes: 3 additions & 4 deletions test/deck/drivers/src/TestOutlierFilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "mock_cfassert.h"

static tdoaMeasurement_t tdoa;
static point_t estimatedPosition;

void setUp(void) {
outlierFilterReset();
Expand All @@ -33,7 +32,7 @@ void testThatSamplesAreAcceptedWhenTdoaIsCloserThanDistanceBetweenAnchors() {
bool expected = true;

// Test
bool actual = outlierFilterValidateTdoa(&tdoa, &estimatedPosition);
bool actual = outlierFilterValidateTdoa(&tdoa);

// Assert
TEST_ASSERT_EQUAL(actual, expected);
Expand All @@ -46,7 +45,7 @@ void testThatSamplesAreRejectedWhenTdoaIsGreaterThanDistanceBetweenAnchors() {
bool expected = false;

// Test
bool actual = outlierFilterValidateTdoa(&tdoa, &estimatedPosition);
bool actual = outlierFilterValidateTdoa(&tdoa);

// Assert
TEST_ASSERT_EQUAL(actual, expected);
Expand All @@ -59,7 +58,7 @@ void testThatSamplesAreRejectedWhenTdoaIsGreaterButNegativeThanDistanceBetweenAn
bool expected = false;

// Test
bool actual = outlierFilterValidateTdoa(&tdoa, &estimatedPosition);
bool actual = outlierFilterValidateTdoa(&tdoa);

// Assert
TEST_ASSERT_EQUAL(actual, expected);
Expand Down

0 comments on commit a5dd1d5

Please sign in to comment.