/// <summary> /// Fuses acceleration and gyroscope data into a single scalar value representing how "stationary" the player is holding /// their device. The resulting value (obtainable as (float)myStillessProvider, myStillnessProvider.Data, or /// myStillnessProvider.StillnessScore, whichever makes more sense) ranges between -20 and +20, with the highest values /// requiring superhuman steadiness, and the lowest ones indicating waving the device around with no attempt at keeping /// it stationary at all. /// </summary> /// <param name="accelbaseline">>The total magnitude of an acceleration vector considered "still *enough*". Optional, /// defaults to 0.25 m/s^2. The ratio of measured value compared to this quantity, rather than the absolute measured /// value, is used as our indicator - recommend calibrating!</param> /// <param name="gyrobaseline">The total magnitude of a gyro vector considered "still *enough*". Optional, /// defaults to 0.05 radians per sec. The ratio of measured value compared to this quantity, rather than the absolute /// measured value, is used as our indicator - recommend calibrating!</param> /// <param name="gyroweight">(Optional, default 0.5) The weighting given to the gyro values as compared to those /// from the accelerometer, after normalizing each of them by its respective Baseline value.</param> /// <param name="maxrangemultiplier">(Optional, default 5.0) How big a range the sensor "gauge" should have, /// as a multiple of the baseline value for that quantity. In a speed, if baseline were (say) 30kph, /// the default 5x here would mean that speeds over 150kph would all be handled the same - just as they pretty much /// would by the passengers!</param> /// <param name="externalToken">A cancellation token to stop the whole shebang. If canceled, will require /// recreating this object anew. Calls Stop() but has no built-in way to trigger Start() again - so don't /// use it for that purpose, use Start()/Stop()!</param> /// public StillnessProvider(float scoreDecayRate = 0.25f, float?accelbaseline = null, float?gyrobaseline = null, float gyroweight = 0.667f, float maxrangemultiplier = 5.0f, CancellationToken?externalToken = null) : base(externalToken ?? CancellationToken.None, new CorrectedAccelerometerProvider(SensorType.LinearAcceleration), //new Vector3Provider(SensorType.LinearAcceleration), new Vector3Provider(SensorType.Gyroscope)) { accelBaseline = accelbaseline ?? defaultAccelBaseline; gyroBaseline = gyrobaseline ?? defaultGyroBaseline; gyroWt = gyroweight; maxRangeMult = maxrangemultiplier; pointsDecayRate = scoreDecayRate; //AccelProvider = new CorrectedAccelerometerProvider(SensorType.LinearAcceleration); //GyroProvider = new Vector3Provider(SensorType.Gyroscope); AccelProvider = providers[0] as CorrectedAccelerometerProvider; //AccelProvider = providers[0] as Vector3Provider; GyroProvider = providers[1] as Vector3Provider; Activate(); }
public GravAxisAccelerometerProvider() : base(new Vector3Provider(SensorType.LinearAcceleration), new Vector3Provider(SensorType.Gravity)) { linearAccelProvider = (IVector3Provider)providers[0]; gravProvider = (IVector3Provider)providers[1]; }