Small adjustments to filter

-renamed frame to tick
- increased max intensity
This commit is contained in:
Louka committed 2022-03-19 13:33:54 -04:00
1 parent 256e5079cf
commit 8c74071e30
2 files changed
+23 -23

No files matched your search

@@ -27,9 +27,9 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
private final VRServer server;
String filterType;
float filterAmount;
int filterFrames;
int filterTicks;
private List<Tracker> allTrackers = new FastList<>();
private JLabel amountLabel, framesLabel;
private JLabel amountLabel, ticksLabel;
public TrackersFiltersGUI(VRServer server, VRServerGUI gui) {
@@ -78,11 +78,11 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
add(new AdjButton("-", 0, true), c(3, row, 2));
row++;
filterFrames = (int) FastMath.clamp(server.config.getInt("filters.frameCount", 3), 0, 80);
filterTicks = (int) FastMath.clamp(server.config.getInt("filters.tickCount", 3), 0, 80);
add(new JLabel("Frames"), c(0, row, 2));
add(new JLabel("Ticks"), c(0, row, 2));
add(new AdjButton("+", 1, false), c(1, row, 2));
add(framesLabel = new JLabel(StringUtils.prettyNumber(filterFrames)), c(2, row, 2));
add(ticksLabel = new JLabel(StringUtils.prettyNumber(filterTicks)), c(2, row, 2));
add(new AdjButton("-", 1, true), c(3, row, 2));
}
@@ -96,7 +96,7 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
realTracker = ((ReferenceAdjustedTracker<? extends Tracker>) t).getTracker();
if(realTracker instanceof IMUTracker){
imu = (IMUTracker)realTracker;
imu.setFilter(filterType, filterAmount, filterFrames);
imu.setFilter(filterType, filterAmount, filterTicks);
}
}
}
@@ -114,13 +114,13 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
}
else if(cat == 1){
if(neg){
filterFrames = (int) FastMath.clamp(filterFrames - 1, 0, 80);
filterTicks = (int) FastMath.clamp(filterTicks - 1, 0, 80);
}
else{
filterFrames = (int) FastMath.clamp(filterFrames + 1, 0, 80);
filterTicks = (int) FastMath.clamp(filterTicks + 1, 0, 80);
}
framesLabel.setText((StringUtils.prettyNumber(filterFrames)));
server.config.setProperty("filters.frameCount", filterFrames);
ticksLabel.setText((StringUtils.prettyNumber(filterTicks)));
server.config.setProperty("filters.tickCount", filterTicks);
}
server.saveConfig();
@@ -21,7 +21,7 @@ public class IMUTracker implements Tracker, TrackerWithTPS, TrackerWithBattery {
public final Quaternion rotAdjust = new Quaternion();
protected final Quaternion correction = new Quaternion();
protected LinkedList<Quaternion> previousRots = new LinkedList<Quaternion>();
public float movementFilterFrameCount = 0;
public float movementFilterTickCount = 0;
public float movementFilterAmount = 1f;
protected TrackerMountingRotation mounting = null;
protected TrackerStatus status = TrackerStatus.OK;
@@ -82,26 +82,25 @@ public class IMUTracker implements Tracker, TrackerWithTPS, TrackerWithBattery {
rotAdjust.loadIdentity();
}
bodyPosition = TrackerPosition.getByDesignation(config.designation);
setFilter(vrserver.config.getString("filters.type"), vrserver.config.getFloat("filters.amount", 0.5f), vrserver.config.getInt("filters.frameCount", 3));
setFilter(vrserver.config.getString("filters.type"), vrserver.config.getFloat("filters.amount", 0.5f), vrserver.config.getInt("filters.tickCount", 3));
}
}
public void setFilter(String type, float amount, int frames){
public void setFilter(String type, float amount, int ticks){
amount = FastMath.clamp(amount, 0, 1f);
frames = (int) FastMath.clamp(frames, 0, 80);
ticks = (int) FastMath.clamp(ticks, 0, 80);
switch(type){
case "INTERPOLATION":
movementFilterAmount = 1f - (amount / 2f);
movementFilterFrameCount = frames;
movementFilterAmount = 1f - (amount / 1.75f);
movementFilterTickCount = ticks;
break;
case "EXTRAPOLATION":
movementFilterAmount = amount + 1;
movementFilterFrameCount = frames;
movementFilterAmount = 1f + (amount * 1.1f);
movementFilterTickCount = ticks;
break;
case "NONE":
default:
movementFilterAmount = 1f;
movementFilterFrameCount = 0;
movementFilterTickCount = 0;
break;
}
}
@@ -128,9 +127,9 @@ public class IMUTracker implements Tracker, TrackerWithTPS, TrackerWithBattery {
calculateLiveMagnetometerCorrection();
}
}
if(movementFilterFrameCount != 0){
if(movementFilterTickCount != 0){
previousRots.addLast(new Quaternion(rotQuaternion));
if(previousRots.size() > movementFilterFrameCount){
if(previousRots.size() > movementFilterTickCount){
previousRots.removeFirst();
}
}
@@ -149,7 +148,7 @@ public class IMUTracker implements Tracker, TrackerWithTPS, TrackerWithBattery {
@Override
public boolean getRotation(Quaternion store) {
if(movementFilterFrameCount > 0 && movementFilterAmount != 1){
if(movementFilterTickCount > 0 && movementFilterAmount != 1){
store.set(getFilteredRotation(rotQuaternion, previousRots.getFirst(), movementFilterAmount));
}
else{
@@ -162,6 +161,7 @@ public class IMUTracker implements Tracker, TrackerWithTPS, TrackerWithBattery {
// Original code: https://answers.unity.com/questions/168779/extrapolating-quaternion-rotation.html
Quaternion getFilteredRotation(Quaternion latestRot, Quaternion oldRot, float factor){
// TODO use more points of reference if possible
Quaternion rot = oldRot.mult(latestRot.inverse());
while (factor > 1){
oldRot = latestRot;