mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
adding a rnning average on the velocity values returned by the hydra and adding a simple js to test
This commit is contained in:
parent
bffce7b92c
commit
be843a0035
2 changed files with 103 additions and 1 deletions
102
examples/controllers/handPosesDebug.js
Normal file
102
examples/controllers/handPosesDebug.js
Normal file
|
@ -0,0 +1,102 @@
|
|||
//
|
||||
// handPosesDebug.js
|
||||
// examples
|
||||
//
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
|
||||
|
||||
function makeSphere(color) {
|
||||
var SPHERE_SIZE = 0.05;
|
||||
var sphere = Overlays.addOverlay("sphere", {
|
||||
position: { x: 0, y: 0, z: 0 },
|
||||
size: SPHERE_SIZE,
|
||||
color: color,
|
||||
alpha: 1.0,
|
||||
solid: true,
|
||||
visible: true,
|
||||
});
|
||||
|
||||
return sphere;
|
||||
}
|
||||
|
||||
|
||||
var NUM_HANDS = 2;
|
||||
var NUM_SPHERES_PER_HAND = 2;
|
||||
var LEFT_HAND = 0;
|
||||
var RIGHT_HAND = 1;
|
||||
|
||||
var COLORS = [ { red: 255, green: 0, blue: 0 }, { red: 0, green: 0, blue: 255 } ];
|
||||
|
||||
function index(handNum, indexNum) {
|
||||
return handNum * NUM_HANDS + indexNum;
|
||||
}
|
||||
|
||||
var app = {};
|
||||
|
||||
|
||||
function setup() {
|
||||
app.spheres = new Array();
|
||||
|
||||
for (var h = 0; h < NUM_HANDS; h++) {
|
||||
for (var s = 0; s < NUM_SPHERES_PER_HAND; s++) {
|
||||
var i = index(h, s);
|
||||
app.spheres[i] = makeSphere(COLORS[h]);
|
||||
print("Added Sphere num " + i + " = " + JSON.stringify(app.spheres[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateHand(handNum) {
|
||||
|
||||
var pose;
|
||||
var handName = "right";
|
||||
if (handNum == LEFT_HAND) {
|
||||
pose = MyAvatar.getLeftHandPose();
|
||||
handName = "left";
|
||||
} else {
|
||||
pose = MyAvatar.getRightHandPose();
|
||||
handName = "right";
|
||||
}
|
||||
|
||||
if (pose.valid) {
|
||||
//print(handName + " hand moving" + JSON.stringify(pose));
|
||||
Overlays.editOverlay(app.spheres[index(handNum, 0)], {
|
||||
position: pose.translation,
|
||||
visible: true,
|
||||
});
|
||||
var vpos = Vec3.sum(pose.velocity, pose.translation);
|
||||
Overlays.editOverlay(app.spheres[index(handNum, 1)], {
|
||||
position: vpos,
|
||||
visible: true,
|
||||
});
|
||||
} else {
|
||||
Overlays.editOverlay(app.spheres[index(handNum, 0)], {
|
||||
visible: false
|
||||
});
|
||||
|
||||
Overlays.editOverlay(app.spheres[index(handNum, 1)], {
|
||||
visible: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
updateHand(LEFT_HAND);
|
||||
updateHand(RIGHT_HAND);
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
print("Removing spheres = " + JSON.stringify(app.spheres));
|
||||
for (var i = 0; i < app.spheres.length; i++) {
|
||||
Overlays.deleteOverlay(app.spheres[i]);
|
||||
}
|
||||
}
|
||||
|
||||
setup();
|
||||
Script.update.connect(update);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
|
@ -121,7 +121,7 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
static const int MAX_NUM_AVERAGING_SAMPLES = 10; // At ~100 updates per seconds this means averaging over ~.1s
|
||||
static const int MAX_NUM_AVERAGING_SAMPLES = 1000; // At ~100 updates per seconds this means averaging over ~.1s
|
||||
using MovingAverageMap = std::map< int, MovingAverage< glm::vec3, MAX_NUM_AVERAGING_SAMPLES> >;
|
||||
MovingAverageMap _collectedSamples;
|
||||
|
||||
|
|
Loading…
Reference in a new issue