ValveSoftware / openvr

OpenVR SDK
http://steamvr.com
BSD 3-Clause "New" or "Revised" License
6.08k stars 1.28k forks source link

getControllerStateWithPose and getControllerState changes the output of getDeviceToAbsoluteTrackingPose #883

Open mganglb opened 6 years ago

mganglb commented 6 years ago

Hello i am mgangl and quite new to openvr, so pl excuse my little knowledge.

Setup:

Ubuntu: 16.04

SteamVR beta, (up2date) Steam Beta, (up2date) 2 Main stations with Sync cable (Main stations are not up2date) 1 generic tracker (up2date) No HMD (Null driver) openvr 1.0.16

Issue

All works fine as long i do not use getControllerStateWithPose or getControllerState.

Using the mentioned function changes the Transformation Matrix of getDeviceToAbsoluteTrackingPose (This change is only temporary, while the Tracker is in Motion and about 2 seconds after it stopped motion) -> the orientation is flipping (position is constant) ... something like [90,90,0] ... i have to look it up again.

(x) The setting of the origin do not has any influence on that effect. (TrackingUniverseSeated, TrackingUniverseRawAndUncalibrated, TrackingUniverseStanding)

(x) The Origin has anyway no impact on the Pose of the generic tracker. But it impacts the pose of the controller etc.

(x) the Controller does not show that behavior

(x) Other functions like "GetControllerRoleForTrackedDeviceIndex" do not show that behavior.

(x) but the use of the function "getControllerState" does change the output of "GetControllerRoleForTrackedDeviceIndex" as well.

(x) Same issue with python openvr (what is using openvr 1.0.13) https://github.com/cmbruns/pyopenvr/issues/51

(x) In "steamvr -> developer -> Room overview" i can not see that behavior.

Questions

(x) Is that a bug (i looked throw the last 3 to 5 pages of issues and could not find it)? (x) Has it something to do with controller bindings / action manifest? (Sadly i have to less understanding about that) (x) Further i have something in mind about changing properties of the tracker by a USB HID feature report.

thank you in advance

Output

output without GetControllerState (in motion or at standstill has no impact):

// vr_pointer->GetControllerState(index_tracker, m_pControllerState, vr::k_unMaxTrackedDeviceCount);

0.937954 -0.341695 -0.0540555 0.023757 invalid left right optout

output with GetControllerState:

vr_pointer->GetControllerState(index_tracker, m_pControllerState, vr::k_unMaxTrackedDeviceCount);

You can see the switch in the orientation (quaternions) and the controller role is changing as well.

0.24864    0.669797    0.659447    0.233837
right
optout
0.248639    0.669831    0.659393    0.233893
right
optout
0.248655    0.669812    0.659408    0.233886
right
optout
0.248621    0.669814    0.659441    0.233827
invalid
left
right
optout
0.939921    -0.341152    -0.0104682    0.00736682
invalid
left
right
optout
0.939907    -0.34119    -0.0104803    0.00738399
invalid
left
right
optout

Code

    std::cout << "start main \n";

    std::cout << "init vr \n";
    vr::EVRInitError eError = vr::VRInitError_None;
    vr::IVRSystem* vr_pointer = vr::VR_Init(&eError, vr::VRApplication_Background);

    if (eError != vr::VRInitError_None)
    {
          vr_pointer = NULL;
          printf("Unable to init VR runtime: %s \n", vr::VR_GetVRInitErrorAsEnglishDescription(eError));
          //exit(EXIT_FAILURE);
    }

    std::cout << "i dont exit \n";
    bool run = true;

    unsigned int index_hmd = 0;
    unsigned int index_station = 0;
    unsigned int index_tracker = 0;
    unsigned int index_controller = 0;

    for (unsigned int count = 0; count < 64; count++)
    {
        std::cout << "index: " << count << "\n";

        if ( vr::TrackedDeviceClass_GenericTracker == vr_pointer->GetTrackedDeviceClass(count)){
            std::cout << "index generic" << count;
            index_tracker = count;
        }
        if ( vr::TrackedDeviceClass_HMD == vr_pointer->GetTrackedDeviceClass(count)){
            std::cout << "index hmd" << count;
            index_hmd = count;
        }
        if ( vr::TrackedDeviceClass_TrackingReference == vr_pointer->GetTrackedDeviceClass(count)){
            std::cout << "index station" << count;
            index_station = count;
        }
        if ( vr::TrackedDeviceClass_Controller == vr_pointer->GetTrackedDeviceClass(count)){
            std::cout << "index controller" << count;
            index_controller = count;
        }

    }

    while (run == true){

            vr::TrackedDevicePose_t m_rTrackedDevicePose[ vr::k_unMaxTrackedDeviceCount ];
            vr_pointer->GetDeviceToAbsoluteTrackingPose(vr::TrackingUniverseStanding, 0,  m_rTrackedDevicePose, vr::k_unMaxTrackedDeviceCount);
            vr::HmdQuaternion_t results;
            results = GetRotation(m_rTrackedDevicePose[index_tracker].mDeviceToAbsoluteTracking);
            std::cout << results.x << "    " << results.y << "    " << results.z << "    " << results.w;
            std::cout << std::endl ;

            switch (vr_pointer->GetControllerRoleForTrackedDeviceIndex(index_tracker)) {
            case vr::TrackedControllerRole_Invalid:
                std::cout << "invalid" << std::endl ;

            case vr::TrackedControllerRole_LeftHand:
                std::cout << "left" << std::endl ;

            case vr::TrackedControllerRole_RightHand:
                std::cout << "right" << std::endl ;

            case vr::TrackedControllerRole_OptOut:
                std::cout << "optout" << std::endl ;
            }

            vr::VRControllerState_t m_pControllerState[ vr::k_unMaxTrackedDeviceCount ];
            vr_pointer->GetControllerState(index_tracker, m_pControllerState, vr::k_unMaxTrackedDeviceCount);

            std::this_thread::sleep_for(std::chrono::milliseconds(100));
mganglb commented 6 years ago

The problem was the action manifest / binding.

Gregwar commented 5 years ago

Hello, We are facing similar issue, can you explain more ?

mganglb commented 5 years ago

hi, fix for the flipping: -> SteamVR -> Devices -> Controller Input Binding -> then you have to choose your application (if it is a Background app, i think you dont have to choose your app) -> click "add Action pose" -> Change "left_pose", "right_pose" to "Unused"

This fixed it for me. But if you want to do it "right", i guess the best way is to create an own Action manifest (the procedure above changes the default file i think)

Gregwar commented 5 years ago

The button "Configure controller" has no effect for me I'm using vive setting without headset, SteamVR on Linux

Gregwar commented 5 years ago

Actually I got a message in my vrserver.txt:

Thu Apr 04 2019 17:19:34.737092 - App system.generated.python3 (vive_tracker_handed) loaded default binding [HOME]/.steam/steam/steamapps/common/SteamVR/drivers/htc/resources/input/tracker/legacy_bindings_vive_tracker_handed_rotated.json

If I edit this file and remove whatever is under the poses section it seems OK