Improve controller haptic feedback
I've noticed the haptic feedback of the controllers is really soft: much softer than it would be in the oculus menu or when streaming the same game using SteamVR and another streaming app (for example Virtual Desktop Streamer).
I also noticed that the haptic feedback sometimes starts drifting and the latency of the feedback increases. But when I restart ALVR on the headset or simply press the Oculus button twice to go out and in theALVR streamer app it resets the latency back to no perceived delay.
@JackD83 Is haptic feedback working in latest experimentals? I haven't felt any feedback, even soft one and wasn't missing it until I noticed it working in Virtual Desktop :)
Haptic feedback works differently on the quest than in SteamVr and there are some calculations to convert the values. In general, haptic feedback works, but it is different from game to game.
I did not have the time to check it out yet. You need two headsets to be able to compare how it should be. The code is not very complicated.
As for the latency mentioned by @SnyderTheOne, that probably a network issue, same as delayed audi, mic and video
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
It seems that the haptics is a hit/miss when it comes to triggering the vibration. I'm using the Beat Saber menu as a test. Hovering over each of the menu buttons should trigger a vibration. I tested between moving slowly and moving quickly and it mostly works when moving quickly over the menu items. Moving slowly usually only results in the first item working and subsequent items not working.
I'm not very familiar with the ALVR code and how anything works yet but I think its more than just converting the values? Is there some way of printing the debug values of the haptics to monitor what is happening? I'm not very familiar with C++ and VS.
I have two headsets, one Samsung Odyssey+ (WMR) and an Oculus Quest that I am using with ALVR. So if tests need to be made to compare, I can do that.
I've been playing around with some of the values in the haptic feedback and adding multipliers to the haptic feedback has been assisting in the delivering of the feedback. Most significantly improved is when increasing the duration of the feedback. Please pardon the hackish method of testing the values.
if (m_leftController->getHapticComponent() == vrEvent.data.hapticVibration.componentHandle) {
hapticFeedbackLeft[0] = vrEvent.data.hapticVibration.fAmplitude * (Settings::Instance().m_hapticsIntensity * 2.0);
hapticFeedbackLeft[1] = vrEvent.data.hapticVibration.fDurationSeconds * 10.0;
hapticFeedbackLeft[2] = vrEvent.data.hapticVibration.fFrequency;
} else if (m_rightController->getHapticComponent() == vrEvent.data.hapticVibration.componentHandle) {
hapticFeedbackRight[0] = vrEvent.data.hapticVibration.fAmplitude * (Settings::Instance().m_hapticsIntensity * 2.0);
hapticFeedbackRight[1] = vrEvent.data.hapticVibration.fDurationSeconds * 10.0;
hapticFeedbackRight[2] = vrEvent.data.hapticVibration.fFrequency;
}
I messed around with the frequency but increasing it actually made the vibration weaker.
I think playing around with the numbers can provide a better haptic feedback experience but the haptic feedback is still inconsistent which is very weird. I'm testing it by moving the laser pointer around the Beat Saber menu as there is a vibration every time the cursor passes over a menu item. This feedback should be consistent each time the laser pointer passes over a menu item. However, the feedback is inconsistent in strength and duration. This suggests that there is something else that is causing the feedback to be inconsistent, either data is lost or not parsed correctly. If it is just scaling then all haptic pulses should still be consistent.
Is it possible to print the output of the server to take a look at the haptic data that is being received and sent? I tried turning on the DebugLog in the Debug panel but it failed to produce any logs.
Inside the folder ALVR you need to create the folder "logs", and then inside create the file "driver.log".
I've been doing some logs and tests. There appears to be quite a number of haptic messages with a duration of 0 which are received by the server and sent to the client. I'm thinking if it is a good idea to filter out these messages to optimise the network traffic since they would have no effect for the player. It is easy to implement but I'm thinking if it is a good idea.
@heclak you can test for it. If you see it that it makes a difference then you can submit a pull request. If not, it would be better to leave the code as is to avoid adding complexity.
@heclak could you check if these 0 length messages happen if multiple haptic events are generated in one frame?
There is this comment in the code:
https://github.com/JackD83/ALVR/blob/20cf82ae6b2b55ace0575194d3b2858873cc84ac/alvr_server/OvrHMD.cpp#L451
Maybe we are discarding useful messages and keep the zero one. 0 duration can most likely stop the haptics on the quest
I did more investigative work and it turns out the 0 duration messages only occur when hand tracking is enabled on the Quest. Turning off hand-tracking resolves the creation of messages with 0 duration. I think code of the hand tracking is triggering some extra haptic messages but also scaling it down to 0. I think the better approach for haptic messages when in hand tracking mode would be to disable sending them in the first place.
However, this doesn't resolve the reliability issue of the haptic messages. Haptic feedback is still a hit or miss. I suspect the duration of the haptic feedback might be affected at the client end. However, android dev is something that I've never done before. Not sure if I'm able to figure that out yet.
So I looked into this issue (tried Beat Saber for the first time through ALVR and it's really apparent there) and it turns out it's entirely a client-side issue (considering a good network connection where packet loss will occur only rarely). Actually, it's two separate issues, one make haptics go missing completely, the other makes them weak or weakly pulsing.
The missing haptics issue is caused by the delay between receiving the haptics packet and when the client would play it. This is because the haptics get assigned a start/end time immediately upon arrival, which can be long before rendering the next frame, which is when the client would check and play waiting (and not yet ended) haptics. It can look somewhat like this:
For Beat Saber, a typical menu haptic feedback will be a 5ms vibration.
This gets correctly sent to the client and received.
server sends haptics client renders frame
v v
|---------------|---------------------------|
^<------{about 8 ms}------->
client receives haptics, sets start time to now, end time to now + 5ms
When the client renders a frame, it checks for haptics to play. It will only find already ended haptics though. This doesn't happen always, but it happens very often with short haptics.
The haptics intensity issue is because of the client generating an incorrect haptics buffer. It uses the sine function with appropriate frequency, which is fine, but uses the default range [-1, +1] which then gets truncated to [0, +1] (multiplied by the haptics amplitude). This means we effectively only get half the haptics (when we get any haptics at all).
I will make a PR with fixes for these issues soon.
Fixed and closed!