Forum Discussion

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

DK2 - ovrHmd_BeginFrameTiming called multiple times.

Hey guys!

first post here, so I apologize if Im posting in the wrong topic.

I´m trying to build an application using both libcinder and the oculus rift sdk2 by following the "Minimal Oculus Application" tutorial. After some tries linking the libraries I managed to make the application build. Now the problem is that, following the code from the tutorial I get this exception: Assert: ovrHmd_BeginFrameTiming called multiple times.

If I run on release mode, the exception is not thrown, but I dont get any info from the device either.

here is my code:
#include "cinder/app/AppNative.h"
#include "cinder/gl/gl.h"

#include "OVR_CAPI.h"
#include "Kernel\OVR_Math.h"

using namespace ci;
using namespace ci::app;
using namespace std;

class OculusApp : public AppNative {
public:
void setup();
void shutdown();
void mouseDown( MouseEvent event );
void update();
void draw();


// Oculur Objects ------
ovrHmd mHmd;
ovrFrameTiming frameTiming;

};

void OculusApp::setup()
{
// cinder setup class, this is called once at the begining

ovr_Initialize();
mHmd = ovrHmd_Create(0);

if(!mHmd){

console() << "could not initialize" << endl;
return;
}

ovrHmd_ConfigureTracking(mHmd, 1, 0);


while(mHmd){
frameTiming = ovrHmd_BeginFrameTiming(mHmd, 0);
ovrTrackingState ts = ovrHmd_GetTrackingState(mHmd, frameTiming.ScanoutMidpointSeconds);

if (ts.StatusFlags & (ovrStatus_OrientationTracked | ovrStatus_PositionTracked)) {
// The cpp compatibility layer is used to convert ovrPosef to Posef (see OVR_Math.h)
OVR::Posef pose = ts.HeadPose.ThePose;
float yaw, pitch, roll;
pose.Rotation.GetEulerAngles<OVR::Axis_Y, OVR::Axis_X, OVR::Axis_Z>(&yaw, &pitch, &roll);

console() << "yaw: " << OVR::RadToDegree(yaw) << endl;
console() << "pitch: " << OVR::RadToDegree(pitch) << endl;
console() << "roll: " << OVR::RadToDegree(roll) << endl;


Sleep(150);

ovrHmd_EndFrameTiming(mHmd);

}
}

}


the same happens if I put ovrHmd_EndFrameTiming(mHmd) outside the "if" bracket. the exception is not thrown, but no info either...

any help?
thanks!

3 Replies

  • DiCon's avatar
    DiCon
    Honored Guest
    I would think, the the problem is the combination of
    ovrHmd_ConfigureTracking(mHmd, 1, 0);

    and
    if (ts.StatusFlags & (ovrStatus_OrientationTracked | ovrStatus_PositionTracked)) {


    I am not sure, which flag corresponds to "1" in ovrHmd_ConfigureTracking, but I doubt that it will request orientation and psoition tracking. Therefore the status flag cannot have ovrStatus_OrientationTracked and ovrStatus_PositionTracked set and the condition neve becomes true. You should try
    ovrHmd_ConfigureTracking(hmd, ovrTrackingCap_Orientation | ovrTrackingCap_Position, 0);

    instead.

    (There is also the ovrTrackingCap_MagYawCorrection flag, which is not documented, but it sounds worth testing)
  • thanks, it worked!

    that´s a detail that should be fixed in the tutorial...

    but, anyway! thanks again!
    bye bye
  • I also had difficulties not only with the incorrect ovrHmd_ConfigureTracking flags, but with the ts.StatusFlags not matching the requested ovrStatus flags. I'm guessing that on the basic sample, the sensors aren't initializing fast enough and the ts.StatusFlags doesn't match the ovrStatus flags. I ended up adding a roughly 500 ms delay before calling the ovrTrackingState in a conditional statement with the boolean being flipped once the StatusFlags matches the required ovrStatus. It seems to be working pretty well for now...

    This is using 0.4.2 beta btw...