protected void OnLightSaberCalibration(CalibrationState state) { if (state == CalibrationState.Complete && calibrationState == -1) { return; } // getting fill amount from calibration state float fillAmount = ((int)state + 1) * .25f; // setting calibration bar CalibrationBar.fillAmount = fillAmount; // displaying calibration complete CalibrationComplete.SetActive(state == CalibrationState.Complete); // playing sound if (state == CalibrationState.Complete && calibrationState != (int)state) { AudioEvent.Play(AudioEventName.Ftue.Stereo.CalibrationSuccess, gameObject); } else { AudioEvent.Play(AudioEventName.Ftue.Stereo.Calibration, gameObject); } // setting calibration state calibrationState = (int)state; }
/// <summary> /// Start collecting gaze samples for current calibration point. /// </summary> /// <param name="collectionId">Current ID.</param> /// <param name="screenPoint">The actual screen target.</param> private void CollectSamples(int collectionId, Point2D screenPoint) { this.goToNextPointTimer.Stop(); this.state = CalibrationState.CollectingSamples; var x = screenPoint.X * PresentationScreen.GetPresentationResolution().Width; var y = screenPoint.Y * PresentationScreen.GetPresentationResolution().Height; try { this.client.RpcClient.StartCollectSamplesObject(collectionId, this.screenName, x, y, 0, this.calibTime * 2); } catch (Exception ex) { if (this.settings.SilentMode) { ExceptionMethods.HandleExceptionSilent(ex); } else { ExceptionMethods.HandleException(ex); this.HasShownMessage = true; } this.AbortCalibration(); return; } this.collectSamplesStopwatch = new Stopwatch(); this.collectSamplesStopwatch.Start(); this.collectSamplesTimer.Start(); }
private void Train(double[] rawData) { int count = Math.Min(_nChannels, rawData.Length); for (int index = 0; index < count; index++) { double filtered = _bandPassFilters[index].filterData(rawData[index]); double value = FullWaveRectification(filtered)[0]; if (_baselineDataCounters[index] < _baselineThrowOut) { //throw these first few away } else if (_baselineDataCounters[index] < _baselineDataLength + _baselineThrowOut) { _baselineData[index].Add(value); } else if (_baselineDataCounters[index] == _baselineDataLength + _baselineThrowOut) { _baselineMean[index] = Mean(_baselineData[index]); _baselineStdev[index] = StandardDeviation(_baselineData[index], _baselineMean[index]); OnCalibrationChanged(CalibrationResults.Finished); _calibrationState = CalibrationState.Calibrated; } _baselineDataCounters[index]++; } }
public async Task CalibrateAsync(MoveDirection initialDir) { State = CalibrationState.PreparingToCalibrate; clearUpperAndLowerPos(); var maxMoveDistance = convertGridUnitToSteps(gridMax - gridMin); int initialMove = locator.Position + maxMoveDistance / 2; if (initialDir == MoveDirection.Backward) { initialMove = locator.Position - maxMoveDistance / 2; } var finalPos = await mover.GoToPositionAsync(initialMove); if (hasAllPositionEstimates()) { await calibrateFirstAndSecondPassAsync(); return; } int secondMove = locator.Position - maxMoveDistance; if (initialDir == MoveDirection.Backward) { secondMove = locator.Position + maxMoveDistance; } await mover.GoToPositionAsync(secondMove); await calibrateFirstAndSecondPassAsync(); }
// On update, start listening to tilt input. void Update() { Vector3 newAxis = Vector3.Normalize(Input.acceleration); switch (cali) { case CalibrationState.NON_TILT_DEVICE: if (Vector3.Magnitude(newAxis) > Threshold) { tiltAxis = newAxis; cali = CalibrationState.UNCALIBRATED; tiltRenderer.enabled = true; player.enableTiltControls = true; } break; case CalibrationState.UNCALIBRATED: if (Input.GetButtonDown("Fire1")) { cali = CalibrationState.NON_TILT_DEVICE; player.enableTiltControls = false; } break; } }
private void AbortCalibration() { if (this._calibrationState == CalibrationState.PrologSent) { this.SendCalibrationEpilogue(); } this._calibrationState = CalibrationState.UnCalibrated; }
void Start() { tiltRenderer = GetComponent <LineRenderer>(); tiltRenderer.enabled = false; cali = CalibrationState.NON_TILT_DEVICE; player = GameObject.FindObjectOfType <Playerrr>(); tiltAxis = Vector3.Normalize(Input.acceleration); }
/// <summary> /// Return true if the calibration state is failure /// </summary> public static bool IsFailure(this CalibrationState state) { return(state == CalibrationState.Failed_Aborted || state == CalibrationState.Failed_InaccurateData || state == CalibrationState.Failed_NoRenderer || state == CalibrationState.Failed_NoRenderer || state == CalibrationState.Failed_NoUser || state == CalibrationState.Failed_Unknown); }
private void StateEnter(CalibrationState stateEnter) { if (OnStateEnter != null) { OnStateEnter(stateEnter); } ActiveItem((int)stateEnter); }
public void GetCenterScales(Controller controller) { // Gather current stick positions and assume the player is not pressing anything. StickCenters[0] = 127 - controller.LEFT_STICK_X; StickCenters[1] = 127 - controller.LEFT_STICK_Y; StickCenters[2] = 127 - controller.C_STICK_X; StickCenters[3] = 127 - controller.C_STICK_Y; CurrentState = CalibrationState.SticksCentered; }
/// <summary> /// Returns true if "Service Instrument Soon" should be displayed on the docking station's /// LCD screen due to the state of the docked instrument. /// </summary> public bool ShouldServiceSoon(bool singleSensorMode) { if (!singleSensorMode) { return(false); } // CalibrationState.Failed = this should never happen, the DS should go into Calibration Failure before going idle CalibrationState calState = GetInstrumentCalibrationState(singleSensorMode, null, null); // instrument not docked if (calState == CalibrationState.Unknown) { return(false); } // we already know the instrument needs serviced so don't go farther if (calState == CalibrationState.RedundantSensorPassed || calState == CalibrationState.Failed) { return(true); } // evaluate O2 bump status for instruments capable of combining O2 sensors for DualSense if (this.Type == DeviceType.VPRO || this.Type == DeviceType.SC) { foreach (InstalledComponent ic in this.InstalledComponents) { if (!(ic.Component is Sensor)) { continue; } if (ic.Component.Type.Code != SensorCode.O2) { continue; } // Ventis Pro sensors cannot be disabled, but we check because SafeCore sensors can. if (!ic.Component.Enabled) { continue; } Sensor sensor = (Sensor)ic.Component; // if we found a bump failed O2 sensor than just return true if (sensor.BumpTestStatus == false) { return(true); } } } return(false); }
private void SendCalibrationEpilogue() { if (this._calibrationState == CalibrationState.PrologSent) { NativeMethods.airspy_r820t_write(this._dev, 11, this._old_0x0b_value); NativeMethods.airspy_r820t_write(this._dev, 15, this._old_0x0f_value); this._old_0x0b_value = 0; this._old_0x0f_value = 0; this._calibrationState = CalibrationState.EpilogueSent; } }
private void HandleMenuStateEnter(MenuState state) { if (state == MenuState.Calibration) { currentState = CalibrationState.BPose; } if (state != MenuState.Calibration) { currentState = CalibrationState.Exit; } }
private void HandleCalibrationStateEnter(CalibrationState state) { // Restart and Load the Calibration data if (state == CalibrationState.BPose) { HI5_Calibration.ResetCalibration(); } if (state == CalibrationState.Exit) { } }
public void Calibrate() { _baselineDataCounters = new int[2] { 0, 0 }; _baselineData = new List <double>[2] { new List <double>(), new List <double>() }; _baselineMean = new double[] { -1, -1 }; _baselineStdev = new double[] { -1, -1 }; _calibrationState = CalibrationState.Calibrating; OnCalibrationChanged(CalibrationResults.Started); }
public SerializableBody(Body body, MovingState movingState, CalibrationState calibrationState, RaisedHand raisedHand, bool gestureDetected) { if (body != null) { this.IsTracked = body.IsTracked; this.Joints = body.Joints; this.MovingState = movingState; this.CalibrationState = calibrationState; this.RaisedHand = raisedHand; this.GestureDetected = gestureDetected; this.TrackingID = body.TrackingId; } }
public void DiscoverAnchors() { //Discover button pressed, send a IPS command to search for anchors dicoveredAnchors.text = ""; if (state != CalibrationState.DISCOVERING && (clientUnity.client != null) && clientUnity.client.isConnected) { clientUnity.client.SendCommand((byte)Modules.POSITIONING_MODULE, (byte)PositioningCommandType.IPS_SYSTEM); state = CalibrationState.DISCOVERING; discoverButton.SetActive(false); configAnchorsButton.SetActive(true); startingLabel.SetActive(false); searchingLabel.SetActive(true); } }
/// <summary> /// All gaze samples are collected, prepare asynchronous processing. /// </summary> private void StartProcessing() { this.state = CalibrationState.Calculating; this.smartEyeCalibrationForm.ShowMessage("Calculating Calibration...", this.settings.CalibPointColor); Cursor.Current = Cursors.WaitCursor; this.calibrationWorker = new BackgroundWorker(); this.calibrationWorker.DoWork += this.PerformCalibration; this.calibrationWorker.RunWorkerCompleted += this.CalibrationCompleted; this.calibrationWorker.WorkerSupportsCancellation = true; ////this.calibrationWorker.WorkerReportsProgress = true; ////this.calibrationworker.ProgressChanged += CalibrationChanged; this.calibrationWorker.RunWorkerAsync(); }
} // end-BumpInstrument /// <summary> /// Returns a list of sensors that are "working"; i.e., are not in a cal-fault /// or zero-fault state. These working sensors are the ones that will be bump tested. /// </summary> /// <returns></returns> protected List <InstalledComponent> GetWorkingSensorList() { List <InstalledComponent> workingSensorList = _returnEvent.DockedInstrument.InstalledComponents; if (Configuration.IsSingleSensorMode()) { List <InstalledComponent> passedSensors = new List <InstalledComponent>(); CalibrationState calState = Master.Instance.SwitchService.Instrument.GetInstrumentCalibrationState(Configuration.IsSingleSensorMode(), passedSensors, null); if (calState == CalibrationState.RedundantSensorPassed) { workingSensorList = passedSensors; } } return(workingSensorList); }
private void SendCalibrationProlog() { if (this._calibrationState == CalibrationState.UnCalibrated) { airspy_error airspy_error = NativeMethods.airspy_r820t_read(this._dev, (byte)15, out this._old_0x0f_value); if (airspy_error >= airspy_error.AIRSPY_SUCCESS) { airspy_error = NativeMethods.airspy_r820t_read(this._dev, (byte)11, out this._old_0x0b_value); if (airspy_error >= airspy_error.AIRSPY_SUCCESS) { NativeMethods.airspy_r820t_write(this._dev, 15, (byte)((this._old_0x0f_value & -5) | 4)); NativeMethods.airspy_r820t_write(this._dev, 11, (byte)((this._old_0x0b_value & -17) | 0x10)); this._calibrationState = CalibrationState.PrologSent; } } } }
public void UpdateMinMax(Controller controller) { // There is probably a better way of getting min-max values for the sticks, but this is the easiest way I think. if (_LeftStickMinMax[0] > controller.LEFT_STICK_X) { _LeftStickMinMax[0] = controller.LEFT_STICK_X; } if (_LeftStickMinMax[1] < controller.LEFT_STICK_X) { _LeftStickMinMax[1] = controller.LEFT_STICK_X; } if (_LeftStickMinMax[2] > controller.LEFT_STICK_Y) { _LeftStickMinMax[2] = controller.LEFT_STICK_Y; } if (_LeftStickMinMax[3] < controller.LEFT_STICK_Y) { _LeftStickMinMax[3] = controller.LEFT_STICK_Y; } if (_CStickMinMax[0] > controller.C_STICK_X) { _CStickMinMax[0] = controller.C_STICK_X; } if (_CStickMinMax[1] < controller.C_STICK_X) { _CStickMinMax[1] = controller.C_STICK_X; } if (_CStickMinMax[2] > controller.C_STICK_Y) { _CStickMinMax[2] = controller.C_STICK_Y; } if (_CStickMinMax[3] < controller.C_STICK_Y) { _CStickMinMax[3] = controller.C_STICK_Y; } CurrentState = CalibrationState.Calibrating; }
void OnButtonOkClicked(object sender, EventArgs args) { switch (state) { case CalibrationState.Init: state = CalibrationState.Run; btnOk.IsEnabled = false; soundProvider.Play(SoundId.calibration); Device.StartTimer(TimeSpan.FromMilliseconds(SAMPLE_INTERVAL_MS), OnTimer); break; case CalibrationState.Run: break; case CalibrationState.End: ExitPage(); break; } }
public void OnCalibrationStateChanged(CalibrationState newState) { // setting calibration flag if (newState == CalibrationState.Complete && calibrationState == 2) { IsPeripheralCalibrated = true; Controller.StopCalibrating(); } // saving calibration state calibrationState = (int)newState; // dispatching calibration event if (StereoSetupEvents.OnLightSaberCalibration != null) { StereoSetupEvents.OnLightSaberCalibration.Invoke(newState); } }
private void OnEnable() { m_MenuSM.OnStateEnter += HandleMenuStateEnter; OnStateEnter += HandleCalibrationStateEnter; if (!IsEnvironmentGood()) { currentState = CalibrationState.Warning; } else { currentState = CalibrationState.BPose; } this.State = currentState; HI5_Calibration.ResetCalibration(); }
public PageCalibration(DataItemVehicle item, IDeviceAcceleromter accelerometer, IDeviceSound sound, PageMain parentPage) { InitializeComponent(); Debug.LogToFileMethod(); NavigationPage.SetHasBackButton(this, false); NavigationPage.SetHasNavigationBar(this, false); vehicle = item; accelerometerProvider = accelerometer; soundProvider = sound; state = CalibrationState.Init; timeMilliSeconds = 0; calibrationFilter = new MovingAverage(SAMPLE_DURATION_MS / SAMPLE_INTERVAL_MS); calibration = 0; pageNavigation = parentPage; accelerometerRecorder = new AccelerometerRecorder(false); // false: do not use queue mode InitLayout(); }
void OnCalibrationClick(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { if (IsDone() || !otState.IsReady()) { return; } Debug.Log(state); switch (state) { case CalibrationState.Start: calibrationMessageText.text = "Point straight down at the floor"; state = CalibrationState.Down; break; case CalibrationState.Down: logManager.LogCalibration(); participant.SetHandIndexDist(otState.goHand.transform.position, otState.goIndexfinger.transform.position); // SetHandSize(); calibrationMessageText.text = "Point straight to the right"; state = CalibrationState.Side; break; case CalibrationState.Side: logManager.LogCalibration(); calibrationMessageText.text = "Point straight in front of you"; state = CalibrationState.Front; break; case CalibrationState.Front: logManager.LogCalibration(); calibrationMessageText.text = "You are now done calibrating"; state = CalibrationState.End; break; case CalibrationState.End: calibrationMessage.SetActive(false); continueMessage.SetActive(true); done = true; break; } }
private async Task calibrateFirstAndSecondPassAsync() { calibrateFirstPass(); var distToMove = (top.StepPosition - bottom.StepPosition) + mover.EstimatedOvershoot * 2; if (locator.Position > top.StepPosition) { // Move down for second pass await mover.GoToPositionAsync(locator.Position - distToMove); } else { // Move up for second pass await mover.GoToPositionAsync(locator.Position + distToMove); } calibrateSecondPass(); State = CalibrationState.Ready; }
/// <summary> /// Reset values before starting new calibration. /// </summary> private void ResetValues() { this.state = CalibrationState.Uncalibrated; this.goodTrackingCount = 0; this.id = 0; this.calibTime = 750 * (4 - this.settings.CalibPointSpeed); this.CreatePointList(); this.calibrationResult = new List <CalibrationResult>(); int i = 0; foreach (var point in this.calibrationPoints) { this.calibrationResult.Add(new CalibrationResult(point, i)); i++; } try { this.client.RpcClient.ClearGazeCalibration(); this.client.RpcClient.ClearAllTargetSamples(); } catch (Exception ex) { if (this.settings.SilentMode) { ExceptionMethods.HandleExceptionSilent(ex); } else { ExceptionMethods.HandleException(ex); this.HasShownMessage = true; } this.AbortCalibration(); return; } }
private void previewElement_Tapped(object sender, TappedRoutedEventArgs e) { if (_calState == CalibrationState.CalibrationFirstPoint) { var point = e.GetPosition(previewElement); Settings.CalibrationLeft = point.X; Settings.CalibreationTop = point.Y; _calState = CalibrationState.CalibrationSecondPoint; fps.Text = "Click Lower Right Corner of Calibration Box on Preview"; return; } if (_calState == CalibrationState.CalibrationSecondPoint) { var point = e.GetPosition(previewElement); Settings.CalibrationWidth = point.X - Settings.CalibrationLeft; Settings.CalibrationHeight = point.Y - Settings.CalibreationTop; _calState = CalibrationState.NotCalibrating; ShowCalibrationBox(); UpdateStatus("Calibration Completed"); } }
private void Train(double[][] rawData) { int count = Math.Min(_nChannels, rawData.Length); for (int channel = 0; channel < count; channel++) { double[] filtered = _bandPassFilters[channel].filterData(rawData[channel]); for (int i = 0; i < rawData[channel].Length; i++) { double value = FullWaveRectification(filtered[i])[0]; if (_baselineDataCounters[channel] < _baselineThrowOut) { //throw these first few away } else if (_baselineDataCounters[channel] < _baselineDataLength + _baselineThrowOut) { _baselineData[channel].Add(value); } else if (_baselineDataCounters[channel] == _baselineDataLength + _baselineThrowOut) { _baselineMean[channel] = Mean(_baselineData[channel]); _baselineStdev[channel] = StandardDeviation(_baselineData[channel], _baselineMean[channel]); OnCalibrationChanged(CalibrationResults.Finished); _calibrationState = CalibrationState.Calibrated; } else { break; } _baselineDataCounters[channel]++; } } }
/// <summary> /// The post-processing method to complete calibration. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The event arguments.</param> private void CalibrationCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e != null && e.Result != null && this.state != CalibrationState.Abort) { var res = e.Result as JsonRpcAsyncResult; if (res != null && res.Response.ErrorCode == TrackerErrorId.Success) // && res.Response.Result.HasValues) { this.state = CalibrationState.Done; this.GetCalibrationStatistics(); } } if (this.client != null) { this.client.IsCalibrating = false; } this.smartEyeCalibrationForm.ShowMessage("The Calibration has been calculated successfully.", this.settings.CalibPointColor); Cursor.Current = Cursors.Default; this.client.UdpSocket.PacketReceived -= this.BaseClientOnPacketReceived; this.smartEyeCalibrationForm.BeginInvoke(new Action(() => this.smartEyeCalibrationForm.Dispose())); }
/// <summary> /// All gaze samples are collected, prepare asynchronous processing. /// </summary> private void StartProcessing() { this.state = CalibrationState.Calculating; this.smartEyeCalibrationForm.ShowMessage("Calculating Calibration...", this.settings.CalibPointColor); Cursor.Current = Cursors.WaitCursor; this.calibrationWorker = new BackgroundWorker(); this.calibrationWorker.DoWork += this.PerformCalibration; this.calibrationWorker.RunWorkerCompleted += this.CalibrationCompleted; this.calibrationWorker.WorkerSupportsCancellation = true; ////this.calibrationWorker.WorkerReportsProgress = true; ////this.calibrationworker.ProgressChanged += CalibrationChanged; this.calibrationWorker.RunWorkerAsync(); }
/// <summary> /// Stop collecting samples after calibration time over and move on to next point. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The event arguments.</param> private void CheckCollectSamples(object sender, EventArgs e) { if (this.collectSamplesStopwatch.Elapsed.TotalMilliseconds < this.calibTime) { return; } this.collectSamplesTimer.Stop(); try { this.client.RpcClient.StopCollectSamples(); } catch (Exception ex) { if (this.settings.SilentMode) { ExceptionMethods.HandleExceptionSilent(ex); } else { ExceptionMethods.HandleException(ex); this.HasShownMessage = true; } this.AbortCalibration(); return; } this.smartEyeCalibrationForm.ClearCalibrationPoint(); this.state = CalibrationState.Idle; this.id++; this.GoToNextPoint(); }
/// <summary> /// Start collecting gaze samples for current calibration point. /// </summary> /// <param name="collectionId">Current ID.</param> /// <param name="screenPoint">The actual screen target.</param> private void CollectSamples(int collectionId, Point2D screenPoint) { this.goToNextPointTimer.Stop(); this.state = CalibrationState.CollectingSamples; var x = screenPoint.X * PresentationScreen.GetPresentationResolution().Width; var y = screenPoint.Y * PresentationScreen.GetPresentationResolution().Height; try { this.client.RpcClient.StartCollectSamplesObject(collectionId, this.screenName, x, y, 0, this.calibTime * 2); } catch (Exception ex) { if (this.settings.SilentMode) { ExceptionMethods.HandleExceptionSilent(ex); } else { ExceptionMethods.HandleException(ex); this.HasShownMessage = true; } this.AbortCalibration(); return; } this.collectSamplesStopwatch = new Stopwatch(); this.collectSamplesStopwatch.Start(); this.collectSamplesTimer.Start(); }
/// <summary> /// Reset values before starting new calibration. /// </summary> private void ResetValues() { this.state = CalibrationState.Uncalibrated; this.goodTrackingCount = 0; this.id = 0; this.calibTime = 750 * (4 - this.settings.CalibPointSpeed); this.CreatePointList(); this.calibrationResult = new List<CalibrationResult>(); int i = 0; foreach (var point in this.calibrationPoints) { this.calibrationResult.Add(new CalibrationResult(point, i)); i++; } try { this.client.RpcClient.ClearGazeCalibration(); this.client.RpcClient.ClearAllTargetSamples(); } catch (Exception ex) { if (this.settings.SilentMode) { ExceptionMethods.HandleExceptionSilent(ex); } else { ExceptionMethods.HandleException(ex); this.HasShownMessage = true; } this.AbortCalibration(); return; } }
private void SetCalibrationStates(CalibrationState state) { foreach (ObservableKeyValuePair<KinectClient, CalibrationState> observableKeyValuePair in clientCalibrationStates) { observableKeyValuePair.Value = state; } }
/// <summary> /// Aborts calibration. /// </summary> public void AbortCalibration() { if (this.state == CalibrationState.Done) { return; } if (this.initTimer != null) { this.initTimer.Dispose(); } if (this.collectSamplesTimer != null) { this.collectSamplesTimer.Dispose(); } if (this.goToNextPointTimer != null) { this.goToNextPointTimer.Dispose(); } if (this.state == CalibrationState.CollectingSamples) { try { this.client.RpcClient.StopCollectSamples(); } catch (Exception ex) { if (this.settings.SilentMode) { ExceptionMethods.HandleExceptionSilent(ex); } else { ExceptionMethods.HandleException(ex); } } } if (this.state == CalibrationState.Calculating) { this.calibrationWorker.RunWorkerCompleted -= this.CalibrationCompleted; this.calibrationWorker.CancelAsync(); } this.state = CalibrationState.Abort; if (this.client != null) { this.client.IsCalibrating = false; } if (this.client != null && this.client.UdpSocket != null) { this.client.UdpSocket.PacketReceived -= this.BaseClientOnPacketReceived; } if (this.client != null && this.client.RpcClient != null) { if (!this.client.PingRPC()) { // Reconnect to RPC this.client.ConnectRPC(); } } this.calibrationResult = null; this.smartEyeCalibrationForm.BeginInvoke(new Action(() => this.smartEyeCalibrationForm.Dispose())); }
private void SetCalibrationState(KinectClient client, CalibrationState state) { foreach (ObservableKeyValuePair<KinectClient, CalibrationState> observableKeyValuePair in clientCalibrationStates) { if (client.Equals(observableKeyValuePair.Key)) { observableKeyValuePair.Value = state; } } }