/// <summary> /// _dos the track camera for one rect for all trackable objects. /// </summary> private void _doTrackCameraForOneRectForAllTrackableObjects() { // Rect allTrackableObjects_rect = _getRectForAllTrackableObjects(_currentCameraTrackingPriority); //UPDATE TARGET _xPosition_lerptarget.targetValue = allTrackableObjects_rect.center.x; _yPosition_lerptarget.targetValue = allTrackableObjects_rect.center.y; DebugDraw.DrawCenterPointCross(allTrackableObjects_rect, _zPlaneCoordinate_float, Constants.DEBUG_COLOR_VIEWPORT_CENTERPOINT); //STORE IF ITS TRACKING if (Mathf.Abs(_xPosition_lerptarget.deltaCurrentToTargetValue) < 0.5f && Mathf.Abs(_yPosition_lerptarget.deltaCurrentToTargetValue) < 0.5f) { _trackingMode = TrackingMode.CurrentlyNotTracking; } else { _trackingMode = TrackingMode.CurrentlyTracking; } //DO LERP _xPosition_lerptarget.lerpCurrentToTarget(Time.deltaTime); _yPosition_lerptarget.lerpCurrentToTarget(Time.deltaTime); //WITH EASING transform.position = new Vector3(_xPosition_lerptarget.current, _yPosition_lerptarget.current, transform.position.z); }
public bool SetTrackingMode(TrackingMode mode) { NativeResult result = NativeApi.NRTrackingInitSetTrackingMode(m_TrackingHandle, mode); NativeErrorListener.Check(result, this, "SetTrackingMode"); return(result == NativeResult.Success); }
public void CreateSession(NRSessionBehaviour session) { if (IsInitialized || session == null) { return; } if (NRSessionBehaviour != null) { NRDebugger.LogError("Multiple SessionBehaviour components cannot exist in the scene. " + "Destroying the newest."); GameObject.DestroyImmediate(session.gameObject); return; } NRDevice.Instance.Init(); NativeAPI = new NativeInterface(); #if !UNITY_EDITOR_OSX NativeAPI.NativeTracking.Create(); #endif NRSessionBehaviour = session; NRHMDPoseTracker = session.GetComponent <NRHMDPoseTracker>(); TrackingMode mode = NRHMDPoseTracker.TrackingMode == TrackingType.Tracking3Dof ? TrackingMode.MODE_3DOF : TrackingMode.MODE_6DOF; SetTrackingMode(mode); this.DeployData(); NRKernalUpdater.Instance.OnUpdate += NRFrame.OnUpdate; }
/// <summary> /// Get rate on Azm axis in (deg/sec) /// </summary> /// <param name="rate">Curent DriveRate</param> /// <param name="mode">Current TrackingMode</param> /// <returns></returns> public double GetRateRa(DriveRates rate, TrackingMode mode) { if (mode <= TrackingMode.AltAzm) { return 0; } double Rate; switch (rate) { case DriveRates.driveSidereal: Rate = Const.TRACKRATE_SIDEREAL; break; case DriveRates.driveSolar: Rate = Const.TRACKRATE_SOLAR; break; case DriveRates.driveLunar: Rate = Const.TRACKRATE_LUNAR; break; default: throw new ValueNotAvailableException("Wring tracking rate value"); } Rate += this.tp.RightAscensionRateOffset * Const.SiderealRate; if (mode == TrackingMode.EQS) Rate = -Rate; return Rate; }
private void UseOptitrack() { var pos = OptitrackTracker.GetPosition(); var rot = VrTracker.GetRotation(); switch (CurrentMode) { case TrackingMode.Optitrack: ApplyTransform(pos, rot); break; case TrackingMode.ArMarker: CurrentMode = TrackingMode.TransitionToOptitrack; StartAnimations(pos, rot); ApplyTransform(_positionAnimation.CurrentValue, _rotationAnimation.CurrentValue); break; case TrackingMode.TransitionToArMarker: CurrentMode = TrackingMode.TransitionToOptitrack; RestartAnimations(pos, rot); ApplyTransform(_positionAnimation.CurrentValue, _rotationAnimation.CurrentValue); break; case TrackingMode.TransitionToOptitrack: AdjustAnimations(pos, rot); ApplyTransform(_positionAnimation.CurrentValue, _rotationAnimation.CurrentValue); break; } }
private void Initialize(TextBuffer buffer, ITextVersion bufferVersion, Int32 position, TrackingMode trackingMode) { _version = bufferVersion; _textBuffer = buffer; _position = position; _trackingMode = trackingMode; }
public void ResetState() { //mTrackingMode = TrackingMode.DEVICE_ORIENTATION; mTrackingMode = TrackingMode.CONSTRAINED_TO_CAMERA; mBuildingUDT = false; // place the penguin relative to camera position and direction Vector3 direction = new Vector3(cam.transform.forward.x * -1.0f, 0, cam.transform.forward.z * -1.0f); Vector3 position = new Vector3(cam.transform.position.x, 0.2f, cam.transform.position.z); this.transform.position = position + direction * mInitialDistance; this.transform.rotation = Quaternion.identity; // Update message and mode text //DisplayMessage(msgFindThePenguin); DisplayModeLabel(msgModeDT); // Hide the quality indicator udtEventHandler.ShowQualityIndicator(true); // Show the penguin ShowPenguin(false); // Make the proximity detector sleep if (proximityDetector) { proximityDetector.Sleep(true); } }
public bool SetTrackingMode(TrackingMode mode) { NativeResult result = NativeApi.NRTrackingInitSetTrackingMode(m_TrackingHandle, mode); NRDebugger.Log("[NativeSession SetTrackingMode :]" + mode.ToString() + " result:" + result.ToString()); return(result == NativeResult.Success); }
private void SetHorizontalAutoscaleIndex(TrackingMode modeOrIndex, bool @override) { if (@override == false && graph.TrackHorizontalTraceIndex == (int)modeOrIndex && graph.TrackHorizontalTrace == true) { modeOrIndex = TrackingMode.None; } bool anyChecked = false; for (int i = 0; i < horizontalTrackItems.Count; i++) { if (i == 0) { horizontalTrackItems[i].Checked = (int)modeOrIndex >= horizontalTrackItems.Count; } else { horizontalTrackItems[i].Checked = i - 1 == (int)modeOrIndex; } anyChecked |= horizontalTrackItems[i].Checked; } horizontalAutoscaleMenuItem.Checked = anyChecked; graph.LockXZoom = anyChecked; horizonatalZoomOutMenuItem.Enabled = !anyChecked; horizonatalZoomInMenuItem.Enabled = !anyChecked; graph.TrackHorizontalTraceIndex = (int)modeOrIndex; graph.TrackHorizontalTrace = modeOrIndex >= 0; graphSettings.HorizontalAutoscaleIndex = (int)modeOrIndex; }
/// <summary> /// Start the device /// </summary> public static void Start(TrackingMode _trackingMode) { trackingMode = _trackingMode; PupilTools.OnConnected += OnConnected; PupilTools.OnDisconnecting += OnDisconnecting; //PupilTools.OnReceiveData += CustomReceiveData; }
/// <summary>Initializes a new instance of the <see cref="T:Microsoft.OData.Client.DataServiceCollection`1" /> class based on query execution and with the supplied change method delegates.</summary> /// <param name="items">A <see cref="T:Microsoft.OData.Client.DataServiceQuery`1" /> or LINQ query that returns an <see cref="T:System.Collections.Generic.IEnumerable`1" /> collection of objects that are used to initialize the collection.</param> /// <param name="trackingMode">A <see cref="T:Microsoft.OData.Client.TrackingMode" /> value that indicated whether or not changes made to items in the collection are automatically tracked.</param> /// <param name="entitySetName">The entity set of the objects in the collection.</param> /// <param name="entityChangedCallback">A delegate that encapsulates a method that is called when an entity changes.</param> /// <param name="collectionChangedCallback">A delegate that encapsulates a method that is called when the collection of entities changes.</param> public DataServiceCollection( IEnumerable <T> items, TrackingMode trackingMode, string entitySetName, Func <EntityChangedParams, bool> entityChangedCallback, Func <EntityCollectionChangedParams, bool> collectionChangedCallback) : this(null, items, trackingMode, entitySetName, entityChangedCallback, collectionChangedCallback) { }
private void HandleStartStopTrackingButton(TrackingMode mode, GameControllerUpdateNotification notification) { if (notification == GameControllerUpdateNotification.CommandUp) { if (StartTrackingCommand.CanExecute(mode)) { StartTrackingCommand.Execute(mode); } } }
private void ReturnMaskToNeutralState() { if (CurrentMode != TrackingMode.Gravity) { InitializeGravity(); CurrentMode = TrackingMode.Gravity; } ApplyGravityToParams(); }
private void ProcessFaceData() { if (!_isInitialized) { _isInitialized = true; InitializeUserData(); } CurrentMode = TrackingMode.UserFace; }
public async Task SetTrackingMode(TrackingMode mode) { var modeStr = (char)(int)mode; var result = await Interact($"T{modeStr}"); if (result != "") { throw new Exception($"Set tracking mode failed: {result}"); } }
/// <summary> /// Get an IQueryable of TEntity with the correct tracking and any eager loading. /// </summary> /// <typeparam name="TEntity"></typeparam> /// <param name="mode"></param> /// <param name="includes"></param> /// <returns></returns> public IQueryable <TEntity> GetEntityQueryAndInclude <TEntity>(TrackingMode mode = TrackingMode.Automatic, params Expression <Func <TEntity, object> >[] includes) where TEntity : class { var set = mode == TrackingMode.Automatic ? Set <TEntity>() : Set <TEntity>().AsNoTracking(); return((includes != null && includes.Any()) ? includes.Aggregate <Expression <Func <TEntity, object> >, IQueryable <TEntity> >(set, (current, expression) => current.Include(expression)) : set); }
private void AnimationFinished() { if (CurrentMode == TrackingMode.TransitionToArMarker) { CurrentMode = TrackingMode.ArMarker; } else if (CurrentMode == TrackingMode.TransitionToOptitrack) { CurrentMode = TrackingMode.Optitrack; } }
void Start() { mTrackingMode = TrackingMode.DEVICE_ORIENTATION; VuforiaARController.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted); udtEventHandler.ShowQualityIndicator(false); // don't show at start penguinModel = GameObject.Find("PenguinModel"); penguinShadow = GameObject.Find("Penguin_Shadow"); }
/// <summary> /// Converts a <see cref="TrackingMode"/> to a <c>UnityEngine.XR.ARSubsystems.Feature</c>. /// </summary> /// <param name="self">The <see cref="TrackingMode"/> being extended.</param> /// <returns>A <c>Feature</c> with the appropriate tracking mode bits set.</returns> public static Feature ToFeature(this TrackingMode self) { switch (self) { case TrackingMode.RotationOnly: return(Feature.RotationOnly); case TrackingMode.PositionAndRotation: return(Feature.PositionAndRotation); default: return(Feature.None); } }
/// <summary> /// Initializes a new instance of the <see cref="TextPoint"/> class. /// </summary> /// <exception cref="ArgumentNullException"> /// <para><paramref name="buffer"/> is <see langword="null"/>.</para> /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// <para><paramref name="position"/> is less than zero or greater than buffer.Length.</para> /// </exception> public TextPoint(TextBuffer buffer, Int32 position, TrackingMode trackingMode) { if (buffer == null) { throw new ArgumentNullException("buffer"); } if ((position < 0) || (position > buffer.Length)) { throw new ArgumentOutOfRangeException("position"); } this.Initialize(buffer, buffer.Version, position, trackingMode); }
public override void EnterState(SceneManager context, int idx = 0) { base.EnterState(context); SoundManager.Instance.SetAmbientTrack(0, ambientTrack.data, ambientTrack.targetVolume); VRInput.Instance.ReticleColor = new Color(0, 0, 0, 0); VRInput.Instance.MaxReticleDistance = 6; tracking = TrackingMode.On; windmillTargetSpeed = windmillCurrentSpeed = windmillSpeed; windmillAcceleration = 0; targetWarningAlpha = currentWarningAlpha = 0; StartCoroutine(AllowDisableHeadTracking(0.6f)); }
void StopTracking() { if (canStopHeadTracking) { canStopHeadTracking = false; src.Play(); windmillTargetSpeed = 0; tracking = TrackingMode.Off; head.trackRotation = false; trackingTimer = 0; } }
public CameraTrackingSwitcher() { MarkerTracker = new ArMarkerCamTracker(); VrTracker = new DelayedVrCamTracker(); OptitrackTracker = new OptitrackCamTracker(); CurrentMode = TrackingMode.Optitrack; _positionAnimation = new VectorAnimation(SwitchTransitionSpeed); _rotationAnimation = new QuaternionAnimation(SwitchTransitionSpeed); _positionAnimation.Finished += AnimationFinished; _rotationAnimation.Finished += AnimationFinished; }
public void SetTrackingMode(TrackingMode mode) { if (trackingMode != mode) { TrackingComponent trackingComponent; if (TrackingComponents.TryGetValue(mode, out trackingComponent)) { currentTrackingComp.enabled = false; currentTrackingComp = trackingComponent; currentTrackingComp.enabled = true; trackingMode = mode; } } }
public void ResetState() { mTrackingMode = TrackingMode.DEVICE_ORIENTATION; mBuildingUDT = false; DisplayModeLabel(msgModeDT); // Hide the quality indicator udtEventHandler.ShowQualityIndicator(false); // Show the penguin ShowPenguin(true); }
private void SwitchToCameraMode() { if (mTrackingMode == TrackingMode.DEVICE_ORIENTATION) { mTrackingMode = TrackingMode.CONSTRAINED_TO_CAMERA; DisplayModeLabel(msgModeUDT); // Show the quality indicator udtEventHandler.ShowQualityIndicator(true); // Hide the penguin ShowPenguin(false); } }
// Perform random faces automatically to fill the gaps whenever we do not have any input data from kinect. private void ManipulateMaskAutomatically() { CurrentMode = TrackingMode.ComputerControlled; _waitTimer -= Time.deltaTime; if (_waitTimer > 0) { return; } _waitTimer = 3f; _rotation = new Vector3(Random.Range(-10f, 10f), Random.Range(-10f, 10f), Random.Range(-10f, 10f)); _targetAnimUnits = new AnimationUnits(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f)); }
private void TrackingModesSelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBox comboBox = sender as ComboBox; if (comboBox == null) { return; } if (this.Kinect != null && this.Kinect.Status == KinectStatus.Connected && comboBox.SelectedItem != null) { TrackingMode newMode = (TrackingMode)comboBox.SelectedItem; this.Kinect.SkeletonStream.AppChoosesSkeletons = newMode != TrackingMode.DefaultSystemTracking; this.DiagViewer.KinectSkeletonViewerOnColor.TrackingMode = newMode; this.DiagViewer.KinectSkeletonViewerOnDepth.TrackingMode = newMode; } }
private bool sendSetTrackingModeCommand(out string error) { TrackingMode mode = rbTrackingModeLine.Checked ? TrackingMode.Line : TrackingMode.Object; SetTrackingModeCommand cmd = new SetTrackingModeCommand(_appState, _commsPort, mode); cmd.Execute(); bool isOk = cmd.IsSuccessful; if (isOk) { //save the settings SetTrackingModeCommand.SetModeInConfig(Settings.Default, mode); Settings.Default.Save(); } error = cmd.ErrorDescription; return(isOk); }
/// <summary> /// Initializes a new instance of the <see cref="TextPoint"/> class. /// </summary> /// <exception cref="ArgumentNullException"> /// <para><paramref name="buffer"/> is <see langword="null"/>.</para> /// -or- /// <para><paramref name="version"/> is <see langword="null"/>.</para> /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// <para><paramref name="line"/> is less than zero or greater than or equal to buffer.GetLengthOfLineFromLineNumber(line).</para> /// -or- /// <para><paramref name="offset"/> is less than zero or greater than buffer.GetLengthOfLineFromLineNumber(line).</para> /// </exception> /// <exception cref="ArgumentException"> /// The specified <paramref name="version"/> doesn't belong to the specified <paramref name="buffer"/>. /// </exception> public TextPoint(TextBuffer buffer, Int32 line, Int32 offset, TrackingMode trackingMode) { if (buffer == null) { throw new ArgumentNullException("buffer"); } if ((line < 0) || (line >= buffer.LineCount)) { throw new ArgumentOutOfRangeException("line"); } if ((offset < 0) || (offset > buffer.GetLengthOfLineFromLineNumber(line))) { throw new ArgumentOutOfRangeException("offset"); } Int32 position = buffer.GetStartOfLineFromLineNumber(line) + offset; this.Initialize(buffer, buffer.Version, position, trackingMode); }
/// <summary> /// Start ghosting along the route if tracking is lost. restore arcore tracking as soon as available. /// </summary> public void trackingLost() { if (routeProgress.route.Length > 0 && trackingMode == TrackingMode.tracking) { FindObjectOfType <messageController>().message("Ghosting aktiviert...", 8.0f, "ghostingStatus"); //start ghosting trackingMode = TrackingMode.ghosting; ghostingProgressStart = routeProgress.progress; ghostingProgressSpeed = statProgress; ghostingTimeStart = Time.time; ARCoreDevice.GetComponent <RelativeOrientation>().trackingType = RelativeOrientation.TrackingType.none; ARCoreDevice.GetComponent <RelativeOrientation>().enabled = false; Input.gyro.enabled = true; } }
/// <summary> /// Initializes a new instance of the <see cref="FullTracking"/> class. /// </summary> private FullTracking() { _trackingMode = TrackingMode.None; }
/// <summary> /// Get rate on Azm axis in (deg/sec) /// </summary> /// <param name="rate">Curent DriveRate</param> /// <param name="mode">Current TrackingMode</param> /// <returns></returns> public double GetRateRa(DriveRates rate, TrackingMode mode) { return this.two.GetRateRa(rate, mode); }
public void SetTrackingRate(DriveRates rate, TrackingMode mode) { lock (_sync) { setTrackingRate(rate, mode); } }
private void setTrackingRate(DriveRates rate, TrackingMode mode) { if (mode > TrackingMode.AltAzm) this.tp.IsAtHome = false; this.two.SetTrackingRate(rate, mode); }
private void moveAxis(SlewAxes axis, double rate, bool isFixed = false) { this.CheckPark(); if (this.telescopeMode != TelescopeMode.Normal && this.telescopeMode != TelescopeMode.MovingAxis) return; this.tp.IsAtHome = false; if (axis == SlewAxes.DecAlt) this.tp.MovingAltAxes = !rate.Equals(0); if (axis == SlewAxes.RaAzm) this.tp.MovingAzmAxes = !rate.Equals(0); if (!rate.Equals(0)) { if (axis == SlewAxes.RaAzm) { if (this.telescopeMode != TelescopeMode.MovingAxis) this.moveAxisTrackingMode = this.tp.TrackingMode; this.checkRateTrackingState(); //SetTracking(TrackingMode.Off); //tp.TrackingMode = TrackingMode.Off; } this.two.MoveAxis(axis, rate, isFixed); this.telescopeMode = TelescopeMode.MovingAxis; } else // rate == 0 { if (axis == SlewAxes.RaAzm) { this.setTrackingRate(this.tp.TrackingRate, this.moveAxisTrackingMode); this.tp.TrackingMode = this.moveAxisTrackingMode; } else { this.setTrackingDec(); } if (!this.tp.MovingAltAxes && !this.tp.MovingAzmAxes) { this.telescopeMode = TelescopeMode.Normal; } } }
public override void DoUpdate(SceneManager context) { if((VRInput.Instance.Pitch) < -30){ VRInput.Instance.ReticleColor = new Color(0,0,0,0.5f); } else{ VRInput.Instance.ReticleColor = new Color(0,0,0,0); } if(menu.IsClicked){ SceneManager.Instance.StateTransition(SceneManager.Instance.menuScene); } else if(restart.IsClicked){ SceneManager.Instance.StateTransition(SceneManager.Instance.trackingScene); } else if(nextLab.IsClicked){ SceneManager.Instance.StateTransition(SceneManager.Instance.redwoodScene, Color.black, -1); } else{ if(VRInput.Instance.PrimaryButton.Pressed){ StopTracking(); } } if(tracking == TrackingMode.Off){ targetWarningAlpha = 1; trackingTimer += Time.deltaTime; if(trackingTimer >disabledTime){ head.trackRotation = true; tracking = TrackingMode.On; StartCoroutine(AllowDisableHeadTracking(1.5f)); windmillTargetSpeed = windmillSpeed ; StartCoroutine(Popup()); } src.volume += Time.deltaTime; } else{ targetWarningAlpha = 0; if(src.volume > 0){ src.volume -= 2f*Time.deltaTime; } else{ src.Stop(); } } currentWarningAlpha = Smoothing.SpringSmooth(currentWarningAlpha, targetWarningAlpha, ref alphaSpeed, 0.2f, Time.deltaTime); Color c = warningText.color; c.a = currentWarningAlpha; warningText.color = c; c = warningBacking.material.color; c.a = currentWarningAlpha; warningBacking.material.color = c; windmillCurrentSpeed = Smoothing.SpringSmooth(windmillCurrentSpeed, windmillTargetSpeed, ref windmillAcceleration, 0.25f, Time.deltaTime); for(int i=0; i<windmills.Length; i++){ Windmill windmill = windmills[i]; windmill.RotationSpeed = windmillCurrentSpeed; } }
void StopTracking() { if(canStopHeadTracking){ canStopHeadTracking = false; src.Play(); windmillTargetSpeed = 0; tracking = TrackingMode.Off; head.trackRotation = false; trackingTimer = 0; } }
/// <summary> /// _dos the track camera for one rect for all trackable objects. /// </summary> private void _doTrackCameraForOneRectForAllTrackableObjects() { // Rect allTrackableObjects_rect = _getRectForAllTrackableObjects(_currentCameraTrackingPriority); //UPDATE TARGET _xPosition_lerptarget.targetValue = allTrackableObjects_rect.center.x; _yPosition_lerptarget.targetValue = allTrackableObjects_rect.center.y; DebugDraw.DrawCenterPointCross (allTrackableObjects_rect, _zPlaneCoordinate_float, Constants.DEBUG_COLOR_VIEWPORT_CENTERPOINT); //STORE IF ITS TRACKING if (Mathf.Abs (_xPosition_lerptarget.deltaCurrentToTargetValue) < 0.5f && Mathf.Abs (_yPosition_lerptarget.deltaCurrentToTargetValue) < 0.5f) { _trackingMode = TrackingMode.CurrentlyNotTracking; } else { _trackingMode = TrackingMode.CurrentlyTracking; } //DO LERP _xPosition_lerptarget.lerpCurrentToTarget (Time.deltaTime); _yPosition_lerptarget.lerpCurrentToTarget (Time.deltaTime); //WITH EASING transform.position = new Vector3 (_xPosition_lerptarget.current, _yPosition_lerptarget.current, transform.position.z); }
/// <summary> /// Initializes a new instance of the <see cref="TextPoint"/> class. /// </summary> /// <exception cref="ArgumentNullException"> /// <para><paramref name="buffer"/> is <see langword="null"/>.</para> /// -or- /// <para><paramref name="version"/> is <see langword="null"/>.</para> /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// <para><paramref name="position"/> is less than zero or greater than buffer.GetLengthOfVersion(version).</para> /// </exception> /// <exception cref="ArgumentException"> /// The specified <paramref name="version"/> doesn't belong to the specified <paramref name="buffer"/>. /// </exception> public TextPoint(TextBuffer buffer, ITextVersion version, Int32 position, TrackingMode trackingMode) { if (buffer == null) { throw new ArgumentNullException("buffer"); } if (version == null) { throw new ArgumentNullException("version"); } if (!buffer.VersionBelongsToBuffer(version)) { throw new ArgumentException("The specified version doesn't belong to the specified buffer."); } if ((position < 0) || (position > buffer.GetLengthOfVersion(version))) { throw new ArgumentOutOfRangeException("position"); } this.Initialize(buffer, version, position, trackingMode); }
public MockTelescope(double firmwareVersion, TelescopeType telescopeType) { this.FirmwareVersion = firmwareVersion; this.TelescopeType = telescopeType; _tracking = TrackingMode.EQN; }
public byte[] exchange(byte[] input) { var ans = new List<byte>(); if(input == null || !input.Any()) throw new Exception("Empty transfer"); var t = input[0]; switch (t) { case (byte)'V': return this.makeVersion(); case (byte)'Z': return "12AB,4000#".ToBytes(); case (byte)'z': return "12AB0500,40000500#".ToBytes(); case (byte)'E': return "34AB,12CE#".ToBytes(); case (byte)'e': return "34AB0500,12CE0500#".ToBytes(); case (byte)'S': //Sync case (byte)'s': case (byte)'B': //Slew AltAzm case (byte)'b': case (byte)'R': //Slew RaDec case (byte)'r': return "#".ToBytes(); case (byte)'t': return new byte[]{(byte)_tracking, (byte)(char)GeneralCommands.TERMINATOR}; case (byte)'T': _tracking = (TrackingMode)input[1]; return new byte[] { (byte)(char)GeneralCommands.TERMINATOR }; case (byte)'P': return this.SendCommand(input[1], (DeviceID)input[2], (DeviceCommands)input[3], input.Skip(4).ToArray()); case (byte)'w': { var lat = Location.Lat.ToDMS(); var lon = Location.Lon.ToDMS(); return new byte[] { (byte)lat.D, (byte)lat.M, (byte)lat.S, (byte)(lat.Sign > 0 ? 0 : 1), (byte)lon.D, (byte)lon.M, (byte)lon.S, (byte)(lon.Sign > 0 ? 0 : 1), (byte)(char)GeneralCommands.TERMINATOR }; } case (byte)'W': { var lat = new DMS(input[1], input[2], input[3], input[4] > 0 ? -1 : 1); var lon = new DMS(input[5], input[6], input[7], input[8] > 0 ? -1 : 1); Location = new LatLon(lat.Deg, lon.Deg); return "#".ToBytes(); } case (byte)'h': { var tm = DateTime.Now; var tz = (int)(TimeZone.CurrentTimeZone.GetUtcOffset(tm).TotalHours + 0.5); var dlst = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? 1 : 0; return new byte[] { (byte)tm.Hour, (byte)tm.Minute, (byte)tm.Second, (byte)tm.Month, (byte)tm.Day, (byte)(tm.Year - 2000), (byte)tz, (byte)dlst, (byte)(char)GeneralCommands.TERMINATOR }; } case (byte)'H': return "#".ToBytes(); default: return "#".ToBytes(); } ans.Add((byte)(char)GeneralCommands.TERMINATOR); return ans.ToArray(); }
public override void OnFrame(Controller controller) { // Get the most recent frame and report some basic information Frame frame = controller.Frame(); //SafeWriteLine("Frame id: " + frame.Id // + ", timestamp: " + frame.Timestamp // + ", hands: " + frame.Hands.Count // + ", fingers: " + frame.Fingers.Count // + ", tools: " + frame.Tools.Count // + ", gestures: " + frame.Gestures().Count); if (!frame.Hands.IsEmpty) { if (_trackingHands.Count == 0) { Debug.Assert(_trackingMode == TrackingMode.Idle); // Track the first hand _trackingHands.Add(frame.Hands[0].Id); _trackingMode = TrackingMode.Locking; CalcLockTimeout(frame.Timestamp); } // Get the first hand int firstHandId = _trackingHands.First(); Hand hand = frame.Hands.FirstOrDefault(tmpHand => tmpHand.Id == firstHandId); if (hand == null) { ResetTrackingMode(); return; } if (_trackingMode == TrackingMode.Locking && hand.TimeVisible >= _lockTimeout) { _trackingMode = TrackingMode.Tracking; } Frame oldFrame = controller.Frame(5); Vector translation = hand.Translation(oldFrame); // Get the hand's normal vector and direction Vector normal = hand.PalmNormal; Vector direction = hand.Direction; float x, y, z, pitch, yaw, roll; x = y = z = pitch = yaw = roll = 0.0f; //if (hand.Fingers.Count == 5) GetSmoothedValue(SmoothedValues.X, translation.x); GetSmoothedValue(SmoothedValues.Y, translation.y); GetSmoothedValue(SmoothedValues.Z, translation.z); if (hand.TranslationProbability(oldFrame) >= 0.8) { if (CoreSettings.CoreSettings.Default.Leap_TranslationSmoothing) { x = GetSmoothedValue(SmoothedValues.X); y = GetSmoothedValue(SmoothedValues.Y); z = GetSmoothedValue(SmoothedValues.Z); } else { x = translation.x; y = translation.y; z = translation.z; } } GetSmoothedValue(SmoothedValues.Pitch, direction.Pitch); GetSmoothedValue(SmoothedValues.Roll, normal.Roll); GetSmoothedValue(SmoothedValues.Yaw, direction.Yaw); if (CoreSettings.CoreSettings.Default.Leap_RotationSmoothing) { pitch = GetSmoothedValue(SmoothedValues.Pitch); roll = GetSmoothedValue(SmoothedValues.Roll); yaw = GetSmoothedValue(SmoothedValues.Yaw); } else { pitch = direction.Pitch; roll = normal.Roll; yaw = direction.Yaw; } if (_trackingMode == TrackingMode.Tracking) { _mainWindow.UiState.ActiveTab.ActiveCameraController.LeapInput(x, y, z, pitch, roll, yaw); _lastHandSeen = frame.Timestamp; } //test of fist recognition //SafeWriteLine(hand.SphereRadius.ToString()); //// Check if the hand has any fingers //FingerList fingers = hand.Fingers; //if (!fingers.Empty) //{ // // Calculate the hand's average finger tip position // Vector avgPos = Vector.Zero; // foreach (Finger finger in fingers) // { // avgPos += finger.TipPosition; // } // avgPos /= fingers.Count; // SafeWriteLine("Hand has " + fingers.Count // + " fingers, average finger tip position: " + avgPos); //} //// Get the hand's sphere radius and palm position //SafeWriteLine("Hand sphere radius: " + hand.SphereRadius.ToString("n2") // + " mm, palm position: " + hand.PalmPosition); //// Get the hand's normal vector and direction //Vector normal = hand.PalmNormal; //Vector direction = hand.Direction; //// Calculate the hand's pitch, roll, and yaw angles //SafeWriteLine("Hand pitch: " + direction.Pitch * 180.0f / (float)Math.PI + " degrees, " // + "roll: " + normal.Roll * 180.0f / (float)Math.PI + " degrees, " // + "yaw: " + direction.Yaw * 180.0f / (float)Math.PI + " degrees"); } else if(_trackingHands.Count != 0) { ResetTrackingMode(); } //// Get gestures //GestureList gestures = frame.Gestures(); //for (int i = 0; i < gestures.Count; i++) //{ // Gesture gesture = gestures[i]; // switch (gesture.Type) // { // case Gesture.GestureType.TYPECIRCLE: // CircleGesture circle = new CircleGesture(gesture); // // Calculate clock direction using the angle between circle normal and pointable // String clockwiseness; // if (circle.Pointable.Direction.AngleTo(circle.Normal) <= Math.PI / 4) // { // //Clockwise if angle is less than 90 degrees // clockwiseness = "clockwise"; // } // else // { // clockwiseness = "counterclockwise"; // } // float sweptAngle = 0; // // Calculate angle swept since last frame // if (circle.State != Gesture.GestureState.STATESTART) // { // CircleGesture previousUpdate = new CircleGesture(controller.Frame(1).Gesture(circle.Id)); // sweptAngle = (circle.Progress - previousUpdate.Progress) * 360; // } // SafeWriteLine("Circle id: " + circle.Id // + ", " + circle.State // + ", progress: " + circle.Progress // + ", radius: " + circle.Radius // + ", angle: " + sweptAngle // + ", " + clockwiseness); // break; // case Gesture.GestureType.TYPESWIPE: // SwipeGesture swipe = new SwipeGesture(gesture); // SafeWriteLine("Swipe id: " + swipe.Id // + ", " + swipe.State // + ", position: " + swipe.Position // + ", direction: " + swipe.Direction // + ", speed: " + swipe.Speed); // break; // case Gesture.GestureType.TYPEKEYTAP: // KeyTapGesture keytap = new KeyTapGesture(gesture); // SafeWriteLine("Tap id: " + keytap.Id // + ", " + keytap.State // + ", position: " + keytap.Position // + ", direction: " + keytap.Direction); // break; // case Gesture.GestureType.TYPESCREENTAP: // ScreenTapGesture screentap = new ScreenTapGesture(gesture); // SafeWriteLine("Tap id: " + screentap.Id // + ", " + screentap.State // + ", position: " + screentap.Position // + ", direction: " + screentap.Direction); // break; // default: // SafeWriteLine("Unknown gesture type."); // break; // } //} //if (!frame.Hands.IsEmpty || !frame.Gestures().IsEmpty) //{ // SafeWriteLine(""); //} }
/// <summary> /// Reset to default mode /// </summary> private void ResetTrackingMode() { _trackingHands.Clear(); _trackingMode = TrackingMode.Idle; }
public override void EnterState(SceneManager context, int idx = 0) { base.EnterState(context); SoundManager.Instance.SetAmbientTrack(0, ambientTrack.data,ambientTrack.targetVolume ); VRInput.Instance.ReticleColor = new Color(0,0,0,0); VRInput.Instance.MaxReticleDistance = 6; tracking = TrackingMode.On; windmillTargetSpeed = windmillCurrentSpeed = windmillSpeed; windmillAcceleration = 0; targetWarningAlpha = currentWarningAlpha = 0; StartCoroutine(AllowDisableHeadTracking(0.6f)); }
public void SetTrackingRate(DriveRates rate, TrackingMode mode) { double Rate = this.GetRateRa(rate, mode); this.CheckRateTrackingState(); this.ti.SlewHighRate(SlewAxes.RaAzm, Rate); this.tp.MovingAzmAxes = false; }