-
-
Notifications
You must be signed in to change notification settings - Fork 302
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
Fix rest detection timescale #305
Merged
Eirenliel
merged 5 commits into
SlimeVR:main
from
wigwagwent:SensorFusionInconsistencies
Mar 8, 2024
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8c944b6
Fix rest detection timescale
wigwagwent 805fcd4
Revert calcLinearAcc Change
wigwagwent 8bacf9c
Merge remote-tracking branch 'upstream/main' into SensorFusionInconsi…
wigwagwent 5599172
Change rest detection timescale to seconds from microseconds
wigwagwent 5f93586
Update from comments
Eirenliel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,14 +20,14 @@ | |
struct RestDetectionParams { | ||
sensor_real_t biasClip; | ||
sensor_real_t biasSigmaRest; | ||
uint32_t restMinTimeMicros; | ||
uint32_t restMinTime; | ||
sensor_real_t restFilterTau; | ||
sensor_real_t restThGyr; | ||
sensor_real_t restThAcc; | ||
RestDetectionParams(): | ||
biasClip(2.0f), | ||
biasSigmaRest(0.03f), | ||
restMinTimeMicros(1.5 * 1e6), | ||
restMinTime(1.5), | ||
restFilterTau(0.5f), | ||
restThGyr(2.0f), | ||
restThAcc(0.5f) | ||
|
@@ -103,7 +103,7 @@ class RestDetection { | |
} | ||
#endif | ||
|
||
void updateGyr(uint32_t dtMicros, sensor_real_t gyr[3]) { | ||
void updateGyr(sensor_real_t gyr[3]) { | ||
#ifdef REST_DETECTION_DISABLE_LPF | ||
gyrLastSquaredDeviation = | ||
square(gyr[0] - lastSample.gyr[0]) + | ||
|
@@ -114,7 +114,7 @@ class RestDetection { | |
if (gyrLastSquaredDeviation >= square(params.restThGyr*sensor_real_t(M_PI/180.0)) | ||
|| fabs(lastSample.gyr[0]) > biasClip || fabs(lastSample.gyr[1]) > biasClip | ||
|| fabs(lastSample.gyr[2]) > biasClip) { | ||
restTimeMicros = 0; | ||
restTime = 0; | ||
restDetected = false; | ||
} | ||
|
||
|
@@ -134,13 +134,13 @@ class RestDetection { | |
if (gyrLastSquaredDeviation >= square(params.restThGyr*sensor_real_t(M_PI/180.0)) | ||
|| fabs(restLastGyrLp[0]) > biasClip || fabs(restLastGyrLp[1]) > biasClip | ||
|| fabs(restLastGyrLp[2]) > biasClip) { | ||
restTimeMicros = 0; | ||
restTime = 0; | ||
restDetected = false; | ||
} | ||
#endif | ||
} | ||
|
||
void updateAcc(uint32_t dtMicros, sensor_real_t acc[3]) { | ||
void updateAcc(uint32_t dt, sensor_real_t acc[3]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (acc[0] == sensor_real_t(0.0) && acc[1] == sensor_real_t(0.0) && acc[2] == sensor_real_t(0.0)) { | ||
return; | ||
} | ||
|
@@ -152,11 +152,11 @@ class RestDetection { | |
square(acc[2] - lastSample.acc[2]); | ||
|
||
if (accLastSquaredDeviation >= square(params.restThAcc)) { | ||
restTimeMicros = 0; | ||
restTime = 0; | ||
restDetected = false; | ||
} else { | ||
restTimeMicros += dtMicros; | ||
if (restTimeMicros >= params.restMinTimeMicros) { | ||
restTime += dt; | ||
if (restTime >= params.restMinTime) { | ||
restDetected = true; | ||
} | ||
} | ||
|
@@ -174,11 +174,11 @@ class RestDetection { | |
square(acc[2] - restLastAccLp[2]); | ||
|
||
if (accLastSquaredDeviation >= square(params.restThAcc)) { | ||
restTimeMicros = 0; | ||
restTime = 0; | ||
restDetected = false; | ||
} else { | ||
restTimeMicros += dtMicros; | ||
if (restTimeMicros >= params.restMinTimeMicros) { | ||
restTime += dt; | ||
if (restTime >= params.restMinTime) { | ||
restDetected = true; | ||
} | ||
} | ||
|
@@ -195,7 +195,7 @@ class RestDetection { | |
|
||
gyrLastSquaredDeviation = 0.0; | ||
accLastSquaredDeviation = 0.0; | ||
restTimeMicros = 0.0; | ||
restTime = 0.0; | ||
std::fill(restLastGyrLp, restLastGyrLp + 3, 0.0); | ||
std::fill(restGyrLpState, restGyrLpState + 3*2, NaN); | ||
std::fill(restLastAccLp, restLastAccLp + 3, 0.0); | ||
|
@@ -235,7 +235,7 @@ class RestDetection { | |
private: | ||
RestDetectionParams params; | ||
bool restDetected; | ||
uint32_t restTimeMicros; | ||
uint32_t restTime; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
sensor_real_t gyrLastSquaredDeviation = 0; | ||
sensor_real_t accLastSquaredDeviation = 0; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint32_t
->sensor_real_t