Skip to content

Commit

Permalink
fix: object processing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximvdw committed Nov 27, 2023
1 parent 66c2dde commit 4e99528
Show file tree
Hide file tree
Showing 14 changed files with 622 additions and 518 deletions.
795 changes: 422 additions & 373 deletions package-lock.json

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,42 +66,42 @@
"imu"
],
"peerDependencies": {
"@openhps/core": ">=0.5.5",
"@openhps/core": ">=0.6.4",
"reflect-metadata": ">=0.1.13"
},
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@openhps/core": ">=0.5.5",
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@openhps/core": ">=0.6.4",
"@openhps/csv": "^0.1.11",
"@openhps/web-sensors": "^0.1.9",
"@types/chai": "^4.3.6",
"@types/mocha": "^10.0.1",
"@types/node": "^20.6.1",
"@typescript-eslint/eslint-plugin": ">=6.7.0",
"@typescript-eslint/parser": ">=6.7.0",
"chai": "^4.3.8",
"eslint": "^8.49.0",
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6",
"@types/node": "^20.10.0",
"@typescript-eslint/eslint-plugin": ">=6.12.0",
"@typescript-eslint/parser": ">=6.12.0",
"chai": "^4.3.10",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsdoc": "^46.8.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsdoc": "^46.9.0",
"eslint-plugin-prettier": "^5.0.1",
"husky": "^8.0.3",
"mocha": "^10.2.0",
"mocha-junit-reporter": "^2.2.1",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"prettier": "^3.0.3",
"prettier": "^3.1.0",
"reflect-metadata": ">=0.1.13",
"serve": "^14.2.1",
"shx": "^0.3.4",
"standard-version": "^9.5.0",
"terser-webpack-plugin": "^5.3.9",
"ts-node": ">=10.9.1",
"typedoc": ">=0.25.1",
"typescript": ">=5.2.2",
"webpack": "^5.88.2",
"typedoc": ">=0.25.4",
"typescript": ">=5.3.2",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
},
"nyc": {
Expand Down
1 change: 0 additions & 1 deletion src/nodes/processing/AbsoluteOrientationProcessingNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {

/**
* Geomagnetic orientation processing node
*
* @see {@link https://github.com/visakhanc/eCompass/blob/master/source/main.c}
* @category Processing node
*/
Expand Down
3 changes: 1 addition & 2 deletions src/nodes/processing/AccelerationProcessingNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {

/**
* Acceleration processing to linear velocity
*
* @category Processing node
*/
export class AccelerationProcessingNode extends FilterProcessingNode<DataFrame> {
Expand All @@ -31,7 +30,7 @@ export class AccelerationProcessingNode extends FilterProcessingNode<DataFrame>
public filter(object: DataObject, frame: DataFrame): Promise<DataObject> {
return new Promise<DataObject>((resolve) => {
const accl = frame.getSensor(LinearAccelerationSensor) || frame.getSensor(Accelerometer);
const dt = 1000. / accl.frequency;
const dt = 1000 / accl.frequency;
const linearVelocity = frame.getSensor(LinearVelocitySensor, this.uid);
linearVelocity.value = LinearVelocity.fromArray(accl.value.clone().multiplyScalar(dt).toArray());
linearVelocity.frequency = accl.frequency;
Expand Down
27 changes: 15 additions & 12 deletions src/nodes/processing/GravityProcessingNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class GravityProcessingNode extends FilterProcessingNode<DataFrame> {

constructor(options?: GravityProcessingOptions) {
super(options);
this.options.method = this.options.method || GravityProcessingMethod.LOW_PASS;
}

public initFilter(object: DataObject, frame: DataFrame, options?: FilterProcessingOptions): Promise<any> {
Expand All @@ -34,30 +33,34 @@ export class GravityProcessingNode extends FilterProcessingNode<DataFrame> {

public filter(object: DataObject, frame: DataFrame): Promise<DataObject> {
return new Promise<DataObject>((resolve) => {
let method: GravityProcessingMethod;
let method: GravityProcessingMethod = this.options.method;

if (frame.getSensor(LinearAccelerationSensor)) {
method = GravityProcessingMethod.LINEAR_ACCELERATION;
} else if (frame.getSensor(RelativeOrientationSensor)) {
method = GravityProcessingMethod.RELATIVE_ORIENTATION;
} else if (frame.getSensor(AbsoluteOrientationSensor)) {
method = GravityProcessingMethod.ABSOLUTE_ORIENTATION;
if (method === undefined) {
if (frame.getSensor(LinearAccelerationSensor)) {
method = GravityProcessingMethod.LINEAR_ACCELERATION;
} else if (frame.getSensor(RelativeOrientationSensor)) {
method = GravityProcessingMethod.RELATIVE_ORIENTATION;
} else if (frame.getSensor(AbsoluteOrientationSensor)) {
method = GravityProcessingMethod.ABSOLUTE_ORIENTATION;
} else {
method = GravityProcessingMethod.LOW_PASS;
}
}

switch (method) {
case GravityProcessingMethod.LINEAR_ACCELERATION:
this._fromLinearAcceleration(frame);
break;
case GravityProcessingMethod.LOW_PASS:
this._usingLPFilter(frame); // Unused
break;
case GravityProcessingMethod.ABSOLUTE_ORIENTATION:
this._fromAbsoluteOrientation(frame);
break;
default:
case GravityProcessingMethod.RELATIVE_ORIENTATION:
this._fromRelativeOrientation(frame);
break;
case GravityProcessingMethod.LOW_PASS:
default:
this._usingLPFilter(frame); // Unused
break;
}
resolve(object);
});
Expand Down
12 changes: 8 additions & 4 deletions src/nodes/processing/PedometerProcessingNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
* Pedometer processing node
*
* Based on:
*
* @see {@link https://github.com/MaximilianBuegler/node-pedometer/blob/master/src/pedometer.js}
* @see {@link https://github.com/MaximilianBuegler/node-kinetics/blob/master/src/kinetics.js}
* @author Maximilian Bügler
Expand Down Expand Up @@ -213,9 +212,14 @@ export class PedometerData {
lastStepIndex = -Infinity;

public add(frame: DataFrame): this {
this.accelerometerData.push(frame.getSensor(LinearAccelerationSensor).value);
this.attitudeData.push(frame.getSensor(AbsoluteOrientationSensor).value.toEuler('ZYX'));
this.frequency = frame.getSensor(LinearAccelerationSensor).frequency;
const linearAccelerometer = frame.getSensor(LinearAccelerationSensor);
const absoluteOrientation = frame.getSensor(AbsoluteOrientationSensor);
if (!linearAccelerometer || !absoluteOrientation) {
throw new Error(`No linear accelerometer sensor or absolute orientation sensors in data frame!`);
}
this.accelerometerData.push(linearAccelerometer.value);
this.attitudeData.push(absoluteOrientation.value.toEuler('ZYX'));
this.frequency = linearAccelerometer.frequency;
return this;
}

Expand Down
1 change: 0 additions & 1 deletion src/nodes/processing/RelativeOrientationProcessingNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {

/**
* Relative orientation processing node
*
* @see {@link https://www.w3.org/TR/motion-sensors/#relative-orientation-sensor}
* @category Processing node
*/
Expand Down
1 change: 0 additions & 1 deletion src/nodes/processing/VelocityCalculationNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {

/**
* Calculate linear and angular velocity
*
* @category Processing node
*/
export class VelocityCalculationNode<InOut extends DataFrame> extends ObjectProcessingNode<InOut> {
Expand Down
1 change: 0 additions & 1 deletion src/nodes/processing/VelocityProcessingNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {

/**
* Linear and angular velocity processing
*
* @category Processing node
*/
export class VelocityProcessingNode<InOut extends DataFrame> extends ObjectProcessingNode<InOut> {
Expand Down

0 comments on commit 4e99528

Please sign in to comment.