//----------------------------------------------------------------------- void SampleVuzixTracker() { int previous_yaw = YawSample; VuzixAPI.IWRGet6DTracking(out YawSample, out PitchSample, out RollSample, out XSample, out YSample, out ZSample); int delta = YawSample - previous_yaw; int HALF_CIRCLE = 32768; if (Math.Abs(delta) > HALF_CIRCLE) { // We turned across the discontinuity at 180 degrees so modify the delta to // reflect the probable angular motion if (delta > 0) { delta -= (2 * HALF_CIRCLE); } else { delta += (2 * HALF_CIRCLE); } } ContinuousYaw += delta; Sampled = true; }
//----------------------------------------------------------------------- public override Action Start() { // This method is called just before script starts int err = VuzixAPI.IWROpenTracker(); if (err == 0) { // Turn on Vuzix signal filtering // TODO: Expose this to allow scripts to do their own filtering VuzixAPI.IWRSetFilterState(true); // Grab a single test sample just to make sure everything is linked up properly SampleVuzixTracker(); OnStarted(this, new EventArgs()); } else { throw new Exception("Failed to connect to Vuzix Tracker"); } return(null); }
//----------------------------------------------------------------------- public override void Stop() { VuzixAPI.IWRCloseTracker(); }