Jump to content
 
Sign in to follow this  
stevensu1838@gmail.com

Cannot get the Transform(position and rotation) and velocity of the HTC vive controller in Unity

Recommended Posts

Hi all,

I am trying to use the movement of my vive controller to control something. So I want to read the Transform(position and rotation) and velocity of my HTC vive controller precisely. After I set up the steamvr plugin by selecting and dragging the [CameraRig] and [steamVR] prefabs from the SteamVR\Prefabs folder to the Hierarchy, everything works well. However, when the controller is firmly placed on the table without moving, the position keeps changing up and down slightly around the value. Like Position X, the number keeps changing between 0.3727 1587 and 0.3728456. The number is roughly around 0.3727, rough. As I explained in the beginning, I'd love to get the value of the position and velocity precisely. Do you have any suggestions?  

When it comes to the velocity of the HTC vive controller, I made the following script and attached it to the Controller(right) game object. It does read the velocity but I have two problems here:

1. The velocity keeps changing up and down slightly around the value. Like Velocity Y, the number keeps changing between -0.004792385 and -0.004795785.

2. Sometimes really big values appear. Like Velocity x, it reached around 9.35334. Again, this happens when the controller is firmly placed on the table without moving.

I've been trying on different PCs with different Vive devices. The same thing happens. I guess it is a problem with the device. 

 

Can any of you kindly show me a way out? Thanks a million

 

Please see fig1 and 2 to learn about the unstable data reading of the controller when the actual controller is not moving at all. 

Please see my velocity reader script to check out how I get the velocity of the controller 

 

 

 

My velocity reader script:

using System.Collections;using System.Collections.Generic;using UnityEngine;public class ViveControllerInput : MonoBehaviour{//[HideInInspector]public Vector3 velocity; //[HideInInspector]public Vector3 angularVelocity;private SteamVR_TrackedObject trackedObj;private SteamVR_Controller.Device Controller{get { return SteamVR_Controller.Input((int)trackedObj.index); }}void Awake(){trackedObj = GetComponent<SteamVR_TrackedObject>();}private void UpdateVelocity(){velocity = Controller.velocity;angularVelocity = Controller.angularVelocity;Debug.Log("Controller Velocity!" + velocity);}// Update is called once per framevoid FixedUpdate(){UpdateVelocity();}}

Share this post


Link to post
Share on other sites

 ,

Like Position X, the number keeps changing between 0.3727 1587 and 0.3728456.

The position info looks accurate to me. The changes you're seeing between those values is less than 100th of a centimeter and I would expect to see such small variations even if the base stations and controller were solidly mounted.

 

1. The velocity keeps changing up and down slightly around the value. Like Velocity Y, the number keeps changing between -0.004792385 and -0.004795785.

Similar response as the positoin accuracy. If you want you can round the values to a significant digit and not see the variations.

 

2. Sometimes really big values appear. Like Velocity x, it reached around 9.35334. Again, this happens when the controller is firmly placed on the table without moving.

Position/Velocity values may jump around when tracking is lost or interrupted. Is your controller placed in a location with clear line of sight to both base stations? Did you step between the controller and base station or is there any other possible occlusion?

Share this post


Link to post
Share on other sites

Please sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...