Forum Discussion
Knoxa
11 years agoHonored Guest
Oculus Rift read sensor
Hello,
i'm not really into C++ and want to get the values of the Oculus accelerometers and send them to a Java application.
I searched around 5 hours and with all help (SDK Manual or Guide, other Forums, ...) I couldn't solve the problem.
So my question is: How do i read the sensordatas and export them to Java?
Greeting,
Knoxa
i'm not really into C++ and want to get the values of the Oculus accelerometers and send them to a Java application.
I searched around 5 hours and with all help (SDK Manual or Guide, other Forums, ...) I couldn't solve the problem.
So my question is: How do i read the sensordatas and export them to Java?
Greeting,
Knoxa
6 Replies
- jhericoAdventurerUse the Java bindings for the SDK: https://github.com/jherico/jocular
There's a full example of an application using LWJGL here: https://github.com/OculusRiftInAction/jocular-examples
If you're only interested in fetching the sensor data, you can do that too.
You can also take a look at my book ( http://manning.com/bdavis/ ) which has a chapter devoted to Python and Java development for the Rift. - KnoxaHonored GuestThanks for the fast help!
Now i looked over the java files and i don't get them.
When I start the RiftDemo or RiftDemoRedux a application opens, but freezes.
I don't get how the jocular-examples project is related to the jovr project.
And which java file is responsible for the sensors, so i can read them?
Greeting,
Knoxa - jhericoAdventurer
"Knoxa" wrote:
When I start the RiftDemo or RiftDemoRedux a application opens, but freezes.
I don't get how the jocular-examples project is related to the jovr project.
The jocular examples project is simply a demo of using the JOVR bindings. If you only care about the sensors, you don't need it."Knoxa" wrote:
And which java file is responsible for the sensors, so i can read them?
None of the Java files directly interacts with the hardware. These are C bindings that interact with the Oculus SDK. The SDK in turn communicates with the hardware.
If you want to read the sensors, you can use something like this code:
import static com.oculusvr.capi.OvrLibrary.ovrTrackingCaps.*;
import com.oculusvr.capi.Hmd;
import com.oculusvr.capi.OvrLibrary;
import com.oculusvr.capi.TrackingState;
public class RiftTracker {
public static void main(String[] args) throws InterruptedException {
Hmd.initialize();
Hmd hmd = Hmd.create(0);
if (null == hmd) {
throw new IllegalStateException("Could not open HMD");
}
if (0 == hmd.configureTracking(ovrTrackingCap_Orientation | ovrTrackingCap_Position, 0)) {
throw new IllegalStateException("Could not configure tracking");
}
for (int i = 0; i < 10; ++i) {
TrackingState state = OvrLibrary.INSTANCE.ovrHmd_GetTrackingState(hmd, 0);
System.out.println(state.HeadPose.Pose.Position.x);
System.out.println(state.RawSensorData.Accelerometer.x);
Thread.sleep(1000);
}
hmd.destroy();
hmd = null;
Hmd.shutdown();
}
}; - KnoxaHonored GuestThanks again!
I just forgot to install the Oculus SDK and now everything is clear.
Again thank you very much!
Greeting,
Knoxa - jhericoAdventurerPerhaps you mean you didn't install the Oculus runtime? The Java code has it's own DLL built into the jar file, so it doesn't need the SDK itself.
- Anonymous
Knoxa said:
Hello,
i'm not really into C++ and want to get the values of the Oculus accelerometers and send them to a Java application.
I searched around 5 hours and with all help (SDK Manual or Guide, other Forums, ...) I couldn't solve the problem.
So my question is: How do i read the sensordatas and export them to Java?
Greeting,
Knoxa
Hey, how is going..
i have now the same problem as you back then.
I hope you read this and guide me with my problem some how to fitch the sensor data from Oculus Rift S
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 years ago
- 1 year ago
- 9 years ago