Skip to content

MotionProcessor

Class Implementation - MotionProcessorΒΆ


MethodsΒΆ

Creates a WebSocket server and starts listening for incoming MotionData messages

1
public void startListening() { ... }

Stops the WebSocket server and stops listening for incoming MotionData messages

1
public void stopListening() { ... }

Parses an incoming WebSocket message packet and processes the data. The data that is accepted is a string that can be of the following formats:

1
2
3
4
5
6
7
8
// Sending data
"data accelerationX;accelerationY;accelerationZ;rotationX;rotationY;rotationZ" // all values are floats

// Changing the sample rate
"sampleRate rate" // rate is an integer

// Calibrating the zero point
"zero x;y;z" // x, y, z are floats
1
public void parsePacket(@NotNull String message) { ... }

Processes the provided MotionData object, uses it as a relative path point, and calls the
motionDataEventHandler with the calculated vector.

1
public void addMotionData(MotionData data) { ... }

Sets the gesture path to the provided path.

1
public void setGesturePath(GesturePath gesturePath) { ... }

Updates the relative path to the provided path.

1
public void setRelativePath(List<Vector3> relativePath) { ... }

Sets the motionDataEventHandler to the provided handler.

1
public void setMotionDataEventHandler(Consumer<Vector3> consumer) { ... }

Calculate the relative vector given a MotionData object. This converts relative acceleration and rotation to a vector, taking the sample rate into account.

1
public Vector3 getRelativeVector(MotionData motionData) { ... }

Get a list of error values given the provided GesturePath. This compares the relative path (calibrated) to the provided path segments, and returns the offsets.

1
2
public List<Double> getErrors(GesturePath referencePath) { ... }
public List<Double> getErrors() { ... } // Using pre-set path

Get the error offset of the provided vector to the provided path, or with the set path. This compares a given vector to the provided GesturePath object.

1
2
public double getError(GesturePath path, Vector3 referencePoint) { ... } 
public double getError(Vector3 referencePoint) { ... } // Using pre-set path

Get the average error offset of the relative path and the provided GesturePath object.

1
2
public double getAverageError(GesturePath referencePath) { ... }
public double getAverageError() { ... } // Using pre-set path

Logs statistics to the console

1
public void logStatistics(GesturePath referencePath) { ... }