Skip to content

Instantly share code, notes, and snippets.

@danaabs
Created April 7, 2017 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danaabs/2f43542a255e724dc8dd511a149ee73d to your computer and use it in GitHub Desktop.
Save danaabs/2f43542a255e724dc8dd511a149ee73d to your computer and use it in GitHub Desktop.
Notch.java
Runnable mLogRealTimeData = new Runnable() {
@Override
public void run() {
// Index of first new frame in the last update
int startingFrame = mRealTimeData.getStartingFrame();
// Elapsed time since the last update
long millisSinceUpdate = System.currentTimeMillis() - mUpdateStartTime;
// Recording frequency
float frequency = mRealTimeData.getFrequency();
// Milliseconds per frame
float millisPerFrame = 1000.f / frequency;
// Slect the current frame from the last update
int currentFrame = startingFrame + (int)(millisSinceUpdate / millisPerFrame);
// Show the last frame until a new update comes
if (currentFrame > mRealTimeData.getFrameCount() - 1) currentFrame = mRealTimeData.getFrameCount() - 1;
// Logging data for measured bones
Log.d("REALTIME", "Current frame:" + currentFrame);
for (Bone b : mNotchService.getNetwork().getDevices().keySet()) {
//fvec3 a=mRealTimeData.getPos(b,currentFrame);
Log.d("REALTIME", b.getName() + " "
// Orientation (quaternion)
+ mRealTimeData.getQ(b,currentFrame) + " "
// Position of the bone (end of vector)
+ mRealTimeData.getPos(b,currentFrame));
mSocket.emit("newmessage",b.getName() + " "
// Orientation (quaternion)
+ mRealTimeData.getQ(b,currentFrame) + " "
// Position of the bone (end of vector)
+ mRealTimeData.getPos(b,currentFrame));
}
mHandler.postDelayed(mLogRealTimeData,mRefreshTime);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment