Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Knoxa's avatar
Knoxa
Honored Guest
11 years ago

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

6 Replies

  • Knoxa's avatar
    Knoxa
    Honored Guest
    Thanks 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
  • "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();
    }
    };
  • Knoxa's avatar
    Knoxa
    Honored Guest
    Thanks again!

    I just forgot to install the Oculus SDK and now everything is clear.
    Again thank you very much!

    Greeting,
    Knoxa
  • Perhaps 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's avatar
    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