AndreGilerson / rviz_vive

View RVIZ on the HTC Vive
14 stars 10 forks source link

Fix orientation in vive_display.cpp #1

Open akashjinandra opened 6 years ago

akashjinandra commented 6 years ago

Hello,

First of all thank you so much for making this plug in. I noticed that in this part of the code if (_steamVrPose[vr::k_unTrackedDeviceIndex_Hmd].bPoseIsValid) { Ogre::Vector3 vivePos = _trackedDevicePose[vr::k_unTrackedDeviceIndex_Hmd].getTrans(); Ogre::Quaternion viveOri = _trackedDevicePose[vr::k_unTrackedDeviceIndex_Hmd].extractQuaternion();

_pCameraNode->setPosition(vivePos);
_pCameraNode->setOrientation(ori);
}

you use the vivePos for the pCameraNode but not the orientation. If you change the pCameranode Orientation to be the viveOri, that seems to track orientation as well.

Using this change Ogre::Quaternion viveOri = _trackedDevicePose[vr::k_unTrackedDeviceIndex_Hmd].extractQuaternion().Inverse();

getting the inverse of the quaternion, makes the vive sync up in Rviz.

The other issue I noticed is that rviz will not close after starting the plugin.

Thanks,

Akash Jinandra

AndreGilerson commented 6 years ago

I will look into this tomorrow. Edit: Never going to make timed promises again. This issue is part of a larger problem where tilting the head adds a weird translation to the position inside the simulated world. Working on a fix

akashjinandra commented 6 years ago

Has there been any leeway on this? I was wondering if there was an advantage of using _pCameraNode vs the _pScene node? As the scene node will allow the user to move around in the world where as the camera node moves around the pscene node. Thanks,

Akash Jinandra