ViveSoftware / ViveInputUtility-Unity

A toolkit that helps developing/prototyping VR apps.
http://u3d.as/uF7
Other
353 stars 82 forks source link

Tracker Vibration behaves differently then controller vibration using SteamVR #31

Closed wirelessdreamer closed 6 years ago

wirelessdreamer commented 6 years ago

Here is the test scenario:

Load the role binding example create a game object and put 2 copies of the attached script on it set one of them to Bodyrole->Right hand, and one of them to TrackerRole->Tracker1 bind a vive controller to right hand, and bind a tracker to tracker 1 a hyperblaster is a simple device to test with, but an oscilloscope will show the same results, and a multi meter will verify them as well.

the vive controller behaves as expected and vibrates at proper intervals.

The tracker though, vibrates when it should be still, and doesn't vibrate when it should vibrate, it also skips 1/4 of its times it should vibrate.

Watching the voltages coming off a reading between pin 1 and 2 the voltage is inverted, it stays high at ~ 3.7v, and drops low when it should be vibrating. From the look of The vive tracker documentation it is designed to directly drive a small vibration motor, but the signal its sending does the opposite, and always keeps it vibrating, then stops vibrating when it should vibrate.

I also tested hooking up a 3v vibration motor directly to the tracker, and received the same results.

Let me know if any additional testing is needed.

using System.Collections; using System.Collections.Generic; using UnityEngine; using HTC.UnityPlugin.Vive;

public class VibrationTest : MonoBehaviour {

public ViveRoleProperty viveRole;
public bool pulled = false;
public float counter = 0;
public float interval = 0.5f;
public ushort strength = 2000;
public bool active = true;

IEnumerator HeartBeat()
{
    while (true) 
    {
        counter += Time.deltaTime;
        if (counter > interval && active)
        {
            Debug.Log("Vibrate");
            ViveInput.TriggerHapticPulse(viveRole, strength);
            counter = 0;
        }
        yield return null;
    }
}

void Start()
{
    StartCoroutine(HeartBeat());
}

void Update()
{
    if ((ViveInput.GetAxis(viveRole, ControllerAxis.Trigger) == 1) && (!pulled))
    {
        pulled = true;
        active = !active;
        Debug.Log("Trigger Pressed");
    }
    else if ((ViveInput.GetAxis(viveRole, ControllerAxis.Trigger) < 0.5) && pulled)
    {
        pulled = false;
        Debug.Log("Trigger let go");
    }

    if (ViveInput.GetAxis(viveRole, ControllerAxis.PadY) > 0.07f)
    {
        interval = ViveInput.GetAxis(viveRole, ControllerAxis.PadY) * 2;
    }
}

}

lawwong commented 6 years ago

Thanks, I've forwarded this issue to hardware related team. Will reply later.

lawwong commented 6 years ago

https://dl.vive.com/Tracker/Guideline/HTC_Vive_Tracker_Developer_Guidelines_v1.6.pdf page 27 Turns out that strength(duration) for tracker is in millisecond, instead of microsecond.

lawwong commented 6 years ago

So 2 second duration with 0.5 second interval causes the raising signal overlapped, which its behavior have't been defined.

wirelessdreamer commented 6 years ago

that was my issue. strength == duration. I didn't see they were the same thing. making sure strength is always less then the interval, and I have no issues. Ran tests on an o-scope with .2 second interval and .1 second pulse length and saw what I expected. Thanks.