mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
Update submodule to solarxr-protocol
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -18,3 +18,4 @@ vrconfig.yml
|
||||
*.log.lck
|
||||
|
||||
BVH Recordings
|
||||
Recordings
|
||||
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -4,3 +4,6 @@
|
||||
[submodule "slimevr_protocol"]
|
||||
path = slimevr_protocol
|
||||
url = https://github.com/Futurabeast/slimevr_protocol.git
|
||||
[submodule "solarxr-protocol"]
|
||||
path = solarxr-protocol
|
||||
url = git@github.com:SlimeVR/SolarXR-Protocol.git
|
||||
|
||||
@@ -42,10 +42,12 @@ allprojects {
|
||||
|
||||
dependencies {
|
||||
implementation project(':slime-java-commons')
|
||||
implementation project(":slimevr-protocol")
|
||||
implementation project(":solarxr-protocol")
|
||||
|
||||
implementation group: 'com.google.flatbuffers', name: 'flatbuffers-java', version: '2.0.3'
|
||||
|
||||
implementation group: 'commons-cli', name: 'commons-cli', version: '1.3.1'
|
||||
|
||||
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
|
||||
implementation 'org.apache.commons:commons-math3:3.6.1'
|
||||
implementation 'net.java.dev.jna:jna:5.10.0'
|
||||
|
||||
@@ -11,5 +11,5 @@ rootProject.name = 'SlimeVR Server'
|
||||
include ':slime-java-commons'
|
||||
|
||||
|
||||
include ':slimevr-protocol'
|
||||
project(':slimevr-protocol').projectDir = new File('slimevr_protocol/protocol/java')
|
||||
include ':solarxr-protocol'
|
||||
project(':solarxr-protocol').projectDir = new File('solarxr-protocol/protocol/java')
|
||||
|
||||
Submodule slimevr_protocol deleted from 9402454707
1
solarxr-protocol
Submodule
1
solarxr-protocol
Submodule
Submodule solarxr-protocol added at 32725b8363
@@ -7,6 +7,7 @@ import java.net.ServerSocket;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import dev.slimevr.websocketapi.WebsocketAPI;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.apache.commons.lang3.JavaVersion;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
|
||||
@@ -24,6 +25,33 @@ public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("awt.useSystemAAFontSettings", "on");
|
||||
System.setProperty("swing.aatext", "true");
|
||||
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
HelpFormatter formatter = new HelpFormatter();
|
||||
CommandLine cmd = null;
|
||||
|
||||
Options options = new Options();
|
||||
|
||||
Option noGui = new Option("g", "no-gui", false, "disable swing gui (allow for other gui to be used)");
|
||||
Option help = new Option("h", "help", false, "Show help");
|
||||
|
||||
|
||||
options.addOption(noGui);
|
||||
options.addOption(help);
|
||||
try {
|
||||
cmd = parser.parse(options, args);
|
||||
} catch (ParseException e) {
|
||||
System.out.println(e.getMessage());
|
||||
formatter.printHelp("slimevr.jar", options);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (cmd.hasOption("help")) {
|
||||
formatter.printHelp("slimevr.jar", options);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
File dir = new File("").getAbsoluteFile();
|
||||
try {
|
||||
@@ -52,7 +80,8 @@ public class Main {
|
||||
vrServer = new VRServer();
|
||||
vrServer.start();
|
||||
new Keybinding(vrServer);
|
||||
new VRServerGUI(vrServer);
|
||||
if (!cmd.hasOption("no-gui"))
|
||||
new VRServerGUI(vrServer);
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
|
||||
@@ -20,8 +20,8 @@ import dev.slimevr.platform.windows.WindowsNamedPipeBridge;
|
||||
import dev.slimevr.bridge.VMCBridge;
|
||||
import dev.slimevr.poserecorder.BVHRecorder;
|
||||
import dev.slimevr.serial.SerialHandler;
|
||||
import dev.slimevr.protocol.ProtocolAPI;
|
||||
import dev.slimevr.vr.trackers.*;
|
||||
import dev.slimevr.gui.protocol.ProtocolAPI;
|
||||
import dev.slimevr.websocketapi.WebSocketVRBridge;
|
||||
import dev.slimevr.util.ann.VRServerThread;
|
||||
import dev.slimevr.vr.processor.HumanPoseProcessor;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.autobone;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -10,11 +11,7 @@ import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Vector3f;
|
||||
|
||||
import dev.slimevr.VRServer;
|
||||
import dev.slimevr.poserecorder.PoseFrameSkeleton;
|
||||
import dev.slimevr.poserecorder.PoseFrameTracker;
|
||||
import dev.slimevr.poserecorder.PoseFrames;
|
||||
import dev.slimevr.poserecorder.TrackerFrame;
|
||||
import dev.slimevr.poserecorder.TrackerFrameData;
|
||||
import dev.slimevr.poserecorder.*;
|
||||
import dev.slimevr.vr.processor.HumanPoseProcessor;
|
||||
import dev.slimevr.vr.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfig;
|
||||
@@ -22,8 +19,10 @@ import dev.slimevr.vr.processor.skeleton.SkeletonConfigValue;
|
||||
import dev.slimevr.vr.trackers.TrackerPosition;
|
||||
import dev.slimevr.vr.trackers.TrackerRole;
|
||||
import dev.slimevr.vr.trackers.TrackerUtils;
|
||||
import io.eiren.util.StringUtils;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
import io.eiren.util.collections.FastList;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class AutoBone {
|
||||
|
||||
@@ -42,6 +41,10 @@ public class AutoBone {
|
||||
return "Epoch: " + epoch + ", Epoch Error: " + epochError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static File saveDir = new File("Recordings");
|
||||
private static File loadDir = new File("LoadRecordings");
|
||||
|
||||
public int cursorIncrement = 1;
|
||||
|
||||
@@ -60,6 +63,9 @@ public class AutoBone {
|
||||
public float heightErrorFactor = 0.1f;
|
||||
public float positionErrorFactor = 0.0f;
|
||||
public float positionOffsetErrorFactor = 0.0f;
|
||||
|
||||
public boolean calcInitError = false;
|
||||
public float targetHeight = -1;
|
||||
|
||||
// TODO Needs much more work, probably going to rethink how the errors work to avoid this barely functional workaround @ButterscotchV
|
||||
// For scaling distances, since smaller sizes will cause smaller distances
|
||||
@@ -91,6 +97,25 @@ public class AutoBone {
|
||||
public AutoBone(VRServer server) {
|
||||
this.server = server;
|
||||
reloadConfigValues();
|
||||
|
||||
this.minDataDistance = server.config.getInt("autobone.minimumDataDistance", this.minDataDistance);
|
||||
this.maxDataDistance = server.config.getInt("autobone.maximumDataDistance", this.maxDataDistance);
|
||||
|
||||
this.numEpochs = server.config.getInt("autobone.epochCount", this.numEpochs);
|
||||
|
||||
this.initialAdjustRate = server.config.getFloat("autobone.adjustRate", this.initialAdjustRate);
|
||||
this.adjustRateDecay = server.config.getFloat("autobone.adjustRateDecay", this.adjustRateDecay);
|
||||
|
||||
this.slideErrorFactor = server.config.getFloat("autobone.slideErrorFactor", this.slideErrorFactor);
|
||||
this.offsetSlideErrorFactor = server.config.getFloat("autobone.offsetSlideErrorFactor", this.offsetSlideErrorFactor);
|
||||
this.offsetErrorFactor = server.config.getFloat("autobone.offsetErrorFactor", this.offsetErrorFactor);
|
||||
this.proportionErrorFactor = server.config.getFloat("autobone.proportionErrorFactor", this.proportionErrorFactor);
|
||||
this.heightErrorFactor = server.config.getFloat("autobone.heightErrorFactor", this.heightErrorFactor);
|
||||
this.positionErrorFactor = server.config.getFloat("autobone.positionErrorFactor", this.positionErrorFactor);
|
||||
this.positionOffsetErrorFactor = server.config.getFloat("autobone.positionOffsetErrorFactor", this.positionOffsetErrorFactor);
|
||||
|
||||
this.calcInitError = server.config.getBoolean("autobone.calculateInitialError", true);
|
||||
this.targetHeight = server.config.getFloat("autobone.manualTargetHeight", -1f);
|
||||
}
|
||||
|
||||
public void reloadConfigValues() {
|
||||
@@ -597,4 +622,64 @@ public class AutoBone {
|
||||
skeleton2.skeletonConfig.setConfig(config, newLength);
|
||||
skeleton2.updatePoseAffectedByConfig(config);
|
||||
}
|
||||
|
||||
public String getLengthsString() {
|
||||
final StringBuilder configInfo = new StringBuilder();
|
||||
this.configs.forEach((key, value) -> {
|
||||
if(configInfo.length() > 0) {
|
||||
configInfo.append(", ");
|
||||
}
|
||||
|
||||
configInfo.append(key.stringVal + ": " + StringUtils.prettyNumber(value * 100f, 2));
|
||||
});
|
||||
|
||||
return configInfo.toString();
|
||||
}
|
||||
|
||||
|
||||
public void saveRecording(PoseFrames frames) {
|
||||
if(saveDir.isDirectory() || saveDir.mkdirs()) {
|
||||
File saveRecording;
|
||||
int recordingIndex = 1;
|
||||
do {
|
||||
saveRecording = new File(saveDir, "ABRecording" + recordingIndex++ + ".pfr");
|
||||
} while(saveRecording.exists());
|
||||
|
||||
LogManager.log.info("[AutoBone] Exporting frames to \"" + saveRecording.getPath() + "\"...");
|
||||
if(PoseFrameIO.writeToFile(saveRecording, frames)) {
|
||||
LogManager.log.info("[AutoBone] Done exporting! Recording can be found at \"" + saveRecording.getPath() + "\".");
|
||||
} else {
|
||||
LogManager.log.severe("[AutoBone] Failed to export the recording to \"" + saveRecording.getPath() + "\".");
|
||||
}
|
||||
} else {
|
||||
LogManager.log.severe("[AutoBone] Failed to create the recording directory \"" + saveDir.getPath() + "\".");
|
||||
}
|
||||
}
|
||||
|
||||
public List<Pair<String, PoseFrames>> loadRecordings() {
|
||||
List<Pair<String, PoseFrames>> recordings = new FastList<Pair<String, PoseFrames>>();
|
||||
if(loadDir.isDirectory()) {
|
||||
File[] files = loadDir.listFiles();
|
||||
if(files != null) {
|
||||
for(File file : files) {
|
||||
if(file.isFile() && org.apache.commons.lang3.StringUtils.endsWithIgnoreCase(file.getName(), ".pfr")) {
|
||||
LogManager.log.info("[AutoBone] Detected recording at \"" + file.getPath() + "\", loading frames...");
|
||||
PoseFrames frames = PoseFrameIO.readFromFile(file);
|
||||
|
||||
if(frames == null) {
|
||||
LogManager.log.severe("Reading frames from \"" + file.getPath() + "\" failed...");
|
||||
} else {
|
||||
recordings.add(Pair.of(file.getName(), frames));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return recordings;
|
||||
}
|
||||
|
||||
public static File getLoadDir() {
|
||||
return loadDir;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package dev.slimevr.bridge;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import dev.slimevr.vr.trackers.ShareableTracker;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
|
||||
public class VMCBridge extends Thread implements Bridge {
|
||||
|
||||
|
||||
@@ -30,10 +30,7 @@ import dev.slimevr.poserecorder.PoseRecorder;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfigValue;
|
||||
|
||||
public class AutoBoneWindow extends JFrame {
|
||||
|
||||
private static File saveDir = new File("Recordings");
|
||||
private static File loadDir = new File("LoadRecordings");
|
||||
|
||||
|
||||
private EJBox pane;
|
||||
|
||||
private final transient VRServer server;
|
||||
@@ -66,83 +63,11 @@ public class AutoBoneWindow extends JFrame {
|
||||
build();
|
||||
}
|
||||
|
||||
private String getLengthsString() {
|
||||
final StringBuilder configInfo = new StringBuilder();
|
||||
autoBone.configs.forEach((key, value) -> {
|
||||
if(configInfo.length() > 0) {
|
||||
configInfo.append(", ");
|
||||
}
|
||||
|
||||
configInfo.append(key.stringVal + ": " + StringUtils.prettyNumber(value * 100f, 2));
|
||||
});
|
||||
|
||||
return configInfo.toString();
|
||||
}
|
||||
|
||||
private void saveRecording(PoseFrames frames) {
|
||||
if(saveDir.isDirectory() || saveDir.mkdirs()) {
|
||||
File saveRecording;
|
||||
int recordingIndex = 1;
|
||||
do {
|
||||
saveRecording = new File(saveDir, "ABRecording" + recordingIndex++ + ".pfr");
|
||||
} while(saveRecording.exists());
|
||||
|
||||
LogManager.log.info("[AutoBone] Exporting frames to \"" + saveRecording.getPath() + "\"...");
|
||||
if(PoseFrameIO.writeToFile(saveRecording, frames)) {
|
||||
LogManager.log.info("[AutoBone] Done exporting! Recording can be found at \"" + saveRecording.getPath() + "\".");
|
||||
} else {
|
||||
LogManager.log.severe("[AutoBone] Failed to export the recording to \"" + saveRecording.getPath() + "\".");
|
||||
}
|
||||
} else {
|
||||
LogManager.log.severe("[AutoBone] Failed to create the recording directory \"" + saveDir.getPath() + "\".");
|
||||
}
|
||||
}
|
||||
|
||||
private List<Pair<String, PoseFrames>> loadRecordings() {
|
||||
List<Pair<String, PoseFrames>> recordings = new FastList<Pair<String, PoseFrames>>();
|
||||
if(loadDir.isDirectory()) {
|
||||
File[] files = loadDir.listFiles();
|
||||
if(files != null) {
|
||||
for(File file : files) {
|
||||
if(file.isFile() && org.apache.commons.lang3.StringUtils.endsWithIgnoreCase(file.getName(), ".pfr")) {
|
||||
LogManager.log.info("[AutoBone] Detected recording at \"" + file.getPath() + "\", loading frames...");
|
||||
PoseFrames frames = PoseFrameIO.readFromFile(file);
|
||||
|
||||
if(frames == null) {
|
||||
LogManager.log.severe("Reading frames from \"" + file.getPath() + "\" failed...");
|
||||
} else {
|
||||
recordings.add(Pair.of(file.getName(), frames));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return recordings;
|
||||
}
|
||||
|
||||
|
||||
private float processFrames(PoseFrames frames) {
|
||||
autoBone.minDataDistance = server.config.getInt("autobone.minimumDataDistance", autoBone.minDataDistance);
|
||||
autoBone.maxDataDistance = server.config.getInt("autobone.maximumDataDistance", autoBone.maxDataDistance);
|
||||
|
||||
autoBone.numEpochs = server.config.getInt("autobone.epochCount", autoBone.numEpochs);
|
||||
|
||||
autoBone.initialAdjustRate = server.config.getFloat("autobone.adjustRate", autoBone.initialAdjustRate);
|
||||
autoBone.adjustRateDecay = server.config.getFloat("autobone.adjustRateDecay", autoBone.adjustRateDecay);
|
||||
|
||||
autoBone.slideErrorFactor = server.config.getFloat("autobone.slideErrorFactor", autoBone.slideErrorFactor);
|
||||
autoBone.offsetSlideErrorFactor = server.config.getFloat("autobone.offsetSlideErrorFactor", autoBone.offsetSlideErrorFactor);
|
||||
autoBone.offsetErrorFactor = server.config.getFloat("autobone.offsetErrorFactor", autoBone.offsetErrorFactor);
|
||||
autoBone.proportionErrorFactor = server.config.getFloat("autobone.proportionErrorFactor", autoBone.proportionErrorFactor);
|
||||
autoBone.heightErrorFactor = server.config.getFloat("autobone.heightErrorFactor", autoBone.heightErrorFactor);
|
||||
autoBone.positionErrorFactor = server.config.getFloat("autobone.positionErrorFactor", autoBone.positionErrorFactor);
|
||||
autoBone.positionOffsetErrorFactor = server.config.getFloat("autobone.positionOffsetErrorFactor", autoBone.positionOffsetErrorFactor);
|
||||
|
||||
boolean calcInitError = server.config.getBoolean("autobone.calculateInitialError", true);
|
||||
float targetHeight = server.config.getFloat("autobone.manualTargetHeight", -1f);
|
||||
return autoBone.processFrames(frames, calcInitError, targetHeight, (epoch) -> {
|
||||
return autoBone.processFrames(frames, autoBone.calcInitError, autoBone.targetHeight, (epoch) -> {
|
||||
processLabel.setText(epoch.toString());
|
||||
lengthsLabel.setText(getLengthsString());
|
||||
lengthsLabel.setText(autoBone.getLengthsString());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -179,7 +104,7 @@ public class AutoBoneWindow extends JFrame {
|
||||
|
||||
if(server.config.getBoolean("autobone.saveRecordings", false)) {
|
||||
setText("Saving...");
|
||||
saveRecording(frames);
|
||||
autoBone.saveRecording(frames);
|
||||
}
|
||||
} else {
|
||||
setText("Not Ready...");
|
||||
@@ -238,7 +163,7 @@ public class AutoBoneWindow extends JFrame {
|
||||
}
|
||||
|
||||
setText("Saving...");
|
||||
saveRecording(frames);
|
||||
autoBone.saveRecording(frames);
|
||||
|
||||
setText("Recording Saved!");
|
||||
try {
|
||||
@@ -281,7 +206,7 @@ public class AutoBoneWindow extends JFrame {
|
||||
add(adjustButton = new JButton("Auto-Adjust") {
|
||||
{
|
||||
// If there are files to load, enable the button
|
||||
setEnabled(poseRecorder.hasRecording() || (loadDir.isDirectory() && loadDir.list().length > 0));
|
||||
setEnabled(poseRecorder.hasRecording() || (AutoBone.getLoadDir().isDirectory() && AutoBone.getLoadDir().list().length > 0));
|
||||
addMouseListener(new MouseInputAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
@@ -295,7 +220,7 @@ public class AutoBoneWindow extends JFrame {
|
||||
public void run() {
|
||||
try {
|
||||
setText("Load...");
|
||||
List<Pair<String, PoseFrames>> frameRecordings = loadRecordings();
|
||||
List<Pair<String, PoseFrames>> frameRecordings = autoBone.loadRecordings();
|
||||
|
||||
if(!frameRecordings.isEmpty()) {
|
||||
LogManager.log.info("[AutoBone] Done loading frames!");
|
||||
@@ -316,7 +241,7 @@ public class AutoBoneWindow extends JFrame {
|
||||
frameRecordings.add(Pair.of("<Recording>", frames));
|
||||
} else {
|
||||
setText("No Recordings...");
|
||||
LogManager.log.severe("[AutoBone] No recordings found in \"" + loadDir.getPath() + "\" and no recording was done...");
|
||||
LogManager.log.severe("[AutoBone] No recordings found in \"" + AutoBone.getLoadDir().getPath() + "\" and no recording was done...");
|
||||
try {
|
||||
Thread.sleep(3000); // Wait for 3 seconds
|
||||
} catch(Exception e1) {
|
||||
@@ -353,7 +278,7 @@ public class AutoBoneWindow extends JFrame {
|
||||
|
||||
LogManager.log.info("[AutoBone] Ratios: [{Neck-Torso: " + StringUtils.prettyNumber(neckTorso) + "}, {Chest-Torso: " + StringUtils.prettyNumber(chestTorso) + "}, {Torso-Waist: " + StringUtils.prettyNumber(torsoWaist) + "}, {Leg-Torso: " + StringUtils.prettyNumber(legTorso) + "}, {Leg-Body: " + StringUtils.prettyNumber(legBody) + "}, {Knee-Leg: " + StringUtils.prettyNumber(kneeLeg) + "}]");
|
||||
|
||||
String lengthsString = getLengthsString();
|
||||
String lengthsString = autoBone.getLengthsString();
|
||||
LogManager.log.info("[AutoBone] Length values: " + lengthsString);
|
||||
lengthsLabel.setText(lengthsString);
|
||||
}
|
||||
@@ -406,7 +331,7 @@ public class AutoBoneWindow extends JFrame {
|
||||
if(!isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
autoBone.applyConfig();
|
||||
// Update GUI values after applying
|
||||
skeletonConfig.refreshAll();
|
||||
@@ -427,7 +352,7 @@ public class AutoBoneWindow extends JFrame {
|
||||
pane.add(new EJBox(BoxLayout.LINE_AXIS) {
|
||||
{
|
||||
setBorder(new EmptyBorder(i(5)));
|
||||
add(lengthsLabel = new JLabel(getLengthsString()));
|
||||
add(lengthsLabel = new JLabel(autoBone.getLengthsString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package dev.slimevr.gui;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.JButton;
|
||||
@@ -15,12 +14,8 @@ import com.jme3.math.FastMath;
|
||||
|
||||
import dev.slimevr.VRServer;
|
||||
import dev.slimevr.gui.swing.EJBagNoStretch;
|
||||
import dev.slimevr.vr.trackers.IMUTracker;
|
||||
import dev.slimevr.vr.trackers.ReferenceAdjustedTracker;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.vr.trackers.TrackerFilters;
|
||||
import io.eiren.util.StringUtils;
|
||||
import io.eiren.util.collections.FastList;
|
||||
|
||||
public class TrackersFiltersGUI extends EJBagNoStretch {
|
||||
|
||||
@@ -68,7 +63,7 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
|
||||
add(new AdjButton("-", 0, true), c(3, row, 2));
|
||||
row++;
|
||||
|
||||
filterTicks = (int) FastMath.clamp(server.config.getInt("filters.tickCount", 2), 0, 80);
|
||||
filterTicks = (int) FastMath.clamp(server.config.getInt("filters.tickCount", 1), 0, 80);
|
||||
|
||||
add(new JLabel("Ticks"), c(0, row, 2));
|
||||
add(new AdjButton("+", 1, false), c(1, row, 2));
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.awt.GridBagConstraints;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
@@ -199,22 +200,19 @@ public class TrackersList extends EJBoxNoStretch {
|
||||
});
|
||||
if(realTracker instanceof IMUTracker) {
|
||||
IMUTracker imu = (IMUTracker) realTracker;
|
||||
TrackerMountingRotation tr = imu.getMountingRotation();
|
||||
JComboBox<String> mountSelect;
|
||||
add(mountSelect = new JComboBox<>(), s(c(2, row, 2, GridBagConstraints.FIRST_LINE_START), 2, 1));
|
||||
for(TrackerMountingRotation p : TrackerMountingRotation.values) {
|
||||
mountSelect.addItem(p.name());
|
||||
}
|
||||
if(tr != null) {
|
||||
mountSelect.setSelectedItem(tr.name());
|
||||
} else {
|
||||
mountSelect.setSelectedItem(TrackerMountingRotation.BACK.name());
|
||||
}
|
||||
|
||||
TrackerMountingRotation selected = TrackerMountingRotation.fromQuaternion(imu.getMountingRotation());
|
||||
mountSelect.setSelectedItem(Objects.requireNonNullElse(selected, TrackerMountingRotation.BACK).name());
|
||||
mountSelect.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
TrackerMountingRotation tr = TrackerMountingRotation.valueOf(String.valueOf(mountSelect.getSelectedItem()));
|
||||
imu.setMountingRotation(tr);
|
||||
imu.setMountingRotation(tr.quaternion);
|
||||
server.trackerUpdated(t);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -13,14 +13,10 @@ import dev.slimevr.gui.swing.EJBagNoStretch;
|
||||
import dev.slimevr.gui.swing.EJBox;
|
||||
import dev.slimevr.gui.swing.EJBoxNoStretch;
|
||||
import dev.slimevr.vr.trackers.TrackerRole;
|
||||
import dev.slimevr.posestreamer.BVHFileStream;
|
||||
import dev.slimevr.posestreamer.PoseDataStream;
|
||||
import dev.slimevr.posestreamer.ServerPoseStreamer;
|
||||
import io.eiren.util.MacOSX;
|
||||
import io.eiren.util.OperatingSystem;
|
||||
import io.eiren.util.StringUtils;
|
||||
import io.eiren.util.ann.AWTThread;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
@@ -33,7 +29,6 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -4,14 +4,6 @@ import java.awt.Container;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.MouseInputAdapter;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.gui.protocol;
|
||||
package dev.slimevr.protocol;
|
||||
|
||||
import slimevr_protocol.data_feed.DataFeedConfigT;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.gui.protocol;
|
||||
package dev.slimevr.protocol;
|
||||
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.jme3.math.Quaternion;
|
||||
@@ -60,7 +60,7 @@ public class DataFeedBuilder {
|
||||
if (tracker instanceof IMUTracker) {
|
||||
IMUTracker imuTracker = (IMUTracker) tracker;
|
||||
if (imuTracker.getMountingRotation() != null) {
|
||||
Quaternion quaternion = imuTracker.getMountingRotation().quaternion;
|
||||
Quaternion quaternion = imuTracker.getMountingRotation();
|
||||
TrackerInfo.addMountingOrientation(fbb,
|
||||
Quat.createQuat(fbb,
|
||||
quaternion.getX(),
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.gui.protocol;
|
||||
package dev.slimevr.protocol;
|
||||
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.gui.protocol;
|
||||
package dev.slimevr.protocol;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.UUID;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.gui.protocol;
|
||||
package dev.slimevr.protocol;
|
||||
|
||||
import dev.slimevr.VRServer;
|
||||
import slimevr_protocol.MessageBundle;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.gui.protocol;
|
||||
package dev.slimevr.protocol;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.gui.protocol;
|
||||
package dev.slimevr.protocol;
|
||||
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import slimevr_protocol.MessageBundle;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.gui.protocol;
|
||||
package dev.slimevr.protocol;
|
||||
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import dev.slimevr.vr.processor.HumanPoseProcessor;
|
||||
@@ -1,7 +1,8 @@
|
||||
package dev.slimevr.gui.protocol;
|
||||
package dev.slimevr.protocol;
|
||||
|
||||
import com.fazecast.jSerialComm.SerialPort;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.jme3.math.Quaternion;
|
||||
import dev.slimevr.platform.windows.WindowsNamedPipeBridge;
|
||||
import dev.slimevr.serial.SerialListener;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfigValue;
|
||||
@@ -164,11 +165,18 @@ public class RPCHandler extends ProtocolHandler<RpcMessageHeader> implements Ser
|
||||
return ;
|
||||
|
||||
tracker.setBodyPosition(TrackerPosition.getById(req.bodyPosition()));
|
||||
if (tracker instanceof IMUTracker) {
|
||||
IMUTracker imu = (IMUTracker) tracker;
|
||||
// TrackerMountingRotation rot = TrackerMountingRotation.fromAngle(req.mountingRotation());
|
||||
// if (rot != null)
|
||||
// imu.setMountingRotation(rot);
|
||||
|
||||
if (tracker instanceof ReferenceAdjustedTracker) {
|
||||
ReferenceAdjustedTracker refTracker = (ReferenceAdjustedTracker)tracker;
|
||||
if (refTracker.getTracker() instanceof IMUTracker) {
|
||||
IMUTracker imu = (IMUTracker) refTracker.getTracker();
|
||||
imu.setMountingRotation(new Quaternion(
|
||||
req.mountingRotation().x(),
|
||||
req.mountingRotation().y(),
|
||||
req.mountingRotation().z(),
|
||||
req.mountingRotation().w()
|
||||
));
|
||||
}
|
||||
}
|
||||
this.api.server.trackerUpdated(tracker);
|
||||
}
|
||||
@@ -190,7 +198,7 @@ public class RPCHandler extends ProtocolHandler<RpcMessageHeader> implements Ser
|
||||
fbb,
|
||||
TrackerFilters.valueOf(this.api.server.config.getString("filters.type", "NONE")).id,
|
||||
(int)(this.api.server.config.getFloat("filters.amount", 0.3f) * 100),
|
||||
this.api.server.config.getInt("filters.tickCount", 2)
|
||||
this.api.server.config.getInt("filters.tickCount", 1)
|
||||
);
|
||||
|
||||
int settings = SettingsResponse.createSettingsResponse(fbb, steamvrTrackerSettings, filterSettings);
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.slimevr.serial;
|
||||
|
||||
import com.fazecast.jSerialComm.SerialPort;
|
||||
import com.fazecast.jSerialComm.SerialPortDataListener;
|
||||
import com.fazecast.jSerialComm.SerialPortEvent;
|
||||
import com.fazecast.jSerialComm.SerialPortMessageListener;
|
||||
|
||||
|
||||
@@ -104,4 +104,4 @@ public class CircularArrayList<E>
|
||||
head = wrapIndex(head + 1);
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class IMUTracker implements Tracker, TrackerWithTPS, TrackerWithBattery {
|
||||
private final Quaternion buffQuat = new Quaternion();
|
||||
public int movementFilterTickCount = 0;
|
||||
public float movementFilterAmount = 1f;
|
||||
protected TrackerMountingRotation mounting = null;
|
||||
protected Quaternion mounting = null;
|
||||
protected TrackerStatus status = TrackerStatus.OK;
|
||||
protected final int trackerId;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class IMUTracker implements Tracker, TrackerWithTPS, TrackerWithBattery {
|
||||
@Override
|
||||
public void saveConfig(TrackerConfig config) {
|
||||
config.setDesignation(bodyPosition == null ? null : bodyPosition.designation);
|
||||
config.mountingRotation = mounting != null ? mounting.name() : null;
|
||||
config.mountingRotation = mounting != null ? mounting : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,18 +71,8 @@ public class IMUTracker implements Tracker, TrackerWithTPS, TrackerWithBattery {
|
||||
// Loading a config is an act of user editing, therefore it shouldn't not be allowed if editing is not allowed
|
||||
if (userEditable()) {
|
||||
if(config.mountingRotation != null) {
|
||||
try{
|
||||
mounting = TrackerMountingRotation.valueOf(config.mountingRotation);
|
||||
}
|
||||
catch (Exception e){ // FORWARD was renamed to FRONT
|
||||
mounting = TrackerMountingRotation.FRONT;
|
||||
config.mountingRotation = "FRONT";
|
||||
}
|
||||
if(mounting != null) {
|
||||
rotAdjust.set(mounting.quaternion);
|
||||
} else {
|
||||
rotAdjust.loadIdentity();
|
||||
}
|
||||
mounting = config.mountingRotation;
|
||||
rotAdjust.set(config.mountingRotation);
|
||||
} else {
|
||||
rotAdjust.loadIdentity();
|
||||
}
|
||||
@@ -116,14 +106,14 @@ public class IMUTracker implements Tracker, TrackerWithTPS, TrackerWithBattery {
|
||||
}
|
||||
previousRots = new CircularArrayList<Quaternion>(movementFilterTickCount + 1);
|
||||
}
|
||||
public TrackerMountingRotation getMountingRotation() {
|
||||
public Quaternion getMountingRotation() {
|
||||
return mounting;
|
||||
}
|
||||
|
||||
public void setMountingRotation(TrackerMountingRotation mr) {
|
||||
public void setMountingRotation(Quaternion mr) {
|
||||
mounting = mr;
|
||||
if(mounting != null) {
|
||||
rotAdjust.set(mounting.quaternion);
|
||||
rotAdjust.set(mounting);
|
||||
} else {
|
||||
rotAdjust.loadIdentity();
|
||||
}
|
||||
|
||||
@@ -11,8 +11,9 @@ public class TrackerConfig {
|
||||
public String description;
|
||||
public boolean hide;
|
||||
public Quaternion adjustment;
|
||||
public String mountingRotation;
|
||||
|
||||
public String oldMountingRotation;
|
||||
public Quaternion mountingRotation;
|
||||
|
||||
public TrackerConfig(Tracker tracker) {
|
||||
this.trackerName = tracker.getName();
|
||||
this.description = tracker.getDescriptiveName();
|
||||
@@ -24,10 +25,29 @@ public class TrackerConfig {
|
||||
this.description = node.getString("description");
|
||||
this.designation = node.getString("designation");
|
||||
this.hide = node.getBoolean("hide", false);
|
||||
this.mountingRotation = node.getString("rotation");
|
||||
this.oldMountingRotation = node.getString("rotation");
|
||||
YamlNode mountingRotationNode = node.getNode("mountingRotation");
|
||||
if (mountingRotationNode != null) {
|
||||
mountingRotation = new Quaternion(
|
||||
mountingRotationNode.getFloat("x", 0),
|
||||
mountingRotationNode.getFloat("y", 0),
|
||||
mountingRotationNode.getFloat("z", 0),
|
||||
mountingRotationNode.getFloat("w", 1)
|
||||
);
|
||||
}
|
||||
|
||||
if (mountingRotationNode == null && oldMountingRotation != null) {
|
||||
mountingRotation = TrackerMountingRotation.valueOf(oldMountingRotation).quaternion;
|
||||
}
|
||||
|
||||
YamlNode adjNode = node.getNode("adjustment");
|
||||
if(adjNode != null) {
|
||||
adjustment = new Quaternion(adjNode.getFloat("x", 0), adjNode.getFloat("y", 0), adjNode.getFloat("z", 0), adjNode.getFloat("w", 0));
|
||||
adjustment = new Quaternion(
|
||||
adjNode.getFloat("x", 0),
|
||||
adjNode.getFloat("y", 0),
|
||||
adjNode.getFloat("z", 0),
|
||||
adjNode.getFloat("w", 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,11 +73,19 @@ public class TrackerConfig {
|
||||
} else {
|
||||
configNode.removeProperty("adj");
|
||||
}
|
||||
if(mountingRotation != null) {
|
||||
configNode.setProperty("rotation", mountingRotation);
|
||||
} else {
|
||||
if(oldMountingRotation != null) {
|
||||
configNode.removeProperty("rotation");
|
||||
}
|
||||
|
||||
if(mountingRotation != null) {
|
||||
configNode.setProperty("mountingRotation.x", mountingRotation.getX());
|
||||
configNode.setProperty("mountingRotation.y", mountingRotation.getY());
|
||||
configNode.setProperty("mountingRotation.z", mountingRotation.getZ());
|
||||
configNode.setProperty("mountingRotation.w", mountingRotation.getW());
|
||||
} else {
|
||||
configNode.removeProperty("mountingRotation");
|
||||
}
|
||||
|
||||
if(description != null) {
|
||||
configNode.setProperty("description", description);
|
||||
} else {
|
||||
|
||||
@@ -3,30 +3,27 @@ package dev.slimevr.vr.trackers;
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Quaternion;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public enum TrackerMountingRotation {
|
||||
|
||||
FRONT(180),
|
||||
LEFT(90),
|
||||
BACK(0),
|
||||
RIGHT(-90);
|
||||
|
||||
public final float angle;
|
||||
public final Quaternion quaternion = new Quaternion();
|
||||
|
||||
|
||||
public final Quaternion quaternion;
|
||||
|
||||
public static final TrackerMountingRotation[] values = values();
|
||||
|
||||
private TrackerMountingRotation(float angle) {
|
||||
this.angle = angle;
|
||||
quaternion.fromAngles(0, angle * FastMath.DEG_TO_RAD, 0);
|
||||
TrackerMountingRotation(float angle) {
|
||||
this.quaternion = new Quaternion().fromAngles(0, angle * FastMath.DEG_TO_RAD, 0);
|
||||
}
|
||||
|
||||
public static TrackerMountingRotation fromAngle(float angle) {
|
||||
for (TrackerMountingRotation val : values) {
|
||||
if (val.angle == angle)
|
||||
return val;
|
||||
public static TrackerMountingRotation fromQuaternion(Quaternion q) {
|
||||
for (TrackerMountingRotation r : values()) {
|
||||
if (r.quaternion.equals(q))
|
||||
return r;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import dev.slimevr.vr.trackers.IMUTracker;
|
||||
import dev.slimevr.vr.trackers.ReferenceAdjustedTracker;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.vr.trackers.TrackerStatus;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import com.jme3.math.FastMath;
|
||||
@@ -29,10 +33,6 @@ import com.jme3.math.Vector3f;
|
||||
|
||||
import dev.slimevr.Main;
|
||||
import dev.slimevr.NetworkProtocol;
|
||||
import dev.slimevr.vr.trackers.IMUTracker;
|
||||
import dev.slimevr.vr.trackers.ReferenceAdjustedTracker;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.vr.trackers.TrackerStatus;
|
||||
import io.eiren.util.Util;
|
||||
import io.eiren.util.collections.FastList;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
package dev.slimevr.websocketapi;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import dev.slimevr.bridge.Bridge;
|
||||
import org.java_websocket.WebSocket;
|
||||
import org.java_websocket.drafts.Draft;
|
||||
import org.java_websocket.drafts.Draft_6455;
|
||||
import org.java_websocket.handshake.ClientHandshake;
|
||||
import org.java_websocket.server.WebSocketServer;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package dev.slimevr.websocketapi;
|
||||
|
||||
import dev.slimevr.VRServer;
|
||||
import dev.slimevr.gui.protocol.GenericConnection;
|
||||
import dev.slimevr.gui.protocol.ProtocolAPI;
|
||||
import dev.slimevr.gui.protocol.ProtocolAPIServer;
|
||||
import dev.slimevr.protocol.GenericConnection;
|
||||
import dev.slimevr.protocol.ProtocolAPI;
|
||||
import dev.slimevr.protocol.ProtocolAPIServer;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
import org.java_websocket.WebSocket;
|
||||
import org.java_websocket.drafts.Draft;
|
||||
@@ -64,7 +64,6 @@ public class WebsocketAPI extends WebSocketServer implements ProtocolAPIServer {
|
||||
public void onStart() {
|
||||
LogManager.log.info("[WebSocketAPI] Web Socket API started on port " + getPort());
|
||||
setConnectionLostTimeout(0);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.slimevr.websocketapi;
|
||||
|
||||
import dev.slimevr.gui.protocol.ConnectionContext;
|
||||
import dev.slimevr.gui.protocol.GenericConnection;
|
||||
import dev.slimevr.protocol.ConnectionContext;
|
||||
import dev.slimevr.protocol.GenericConnection;
|
||||
import org.java_websocket.WebSocket;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
Reference in New Issue
Block a user