Example #1
0
        /// <summary>
        /// Initializes the Gyro.
        /// </summary>
        /// <param name="triggeringAxis">
        /// The gyro that represents the single axis responsible for
        /// the triggering of updates.
        /// </param>
        /// <param name="mode">
        /// The gyro update trigger mode.
        /// </param>
        /// <returns>
        /// Reference to the specified triggering axis, which may or may
        /// not have been modified.
        /// </returns>
        /// <exception cref="System.IO.IOException">
        /// Unable to write to gyro.
        /// </exception>
        /// <exception cref="ObjectDisposedException">
        /// This instance has been disposed.
        /// </exception>
        public IGyroscope Init(IGyroscope triggeringAxis, GyroTriggerMode mode)
        {
            this.Enable();

            if (triggeringAxis == this.aX)
            {
                this.aX.SetReadTrigger(mode);
            }
            else
            {
                this.aX.SetReadTrigger(GyroTriggerMode.ReadNotTriggered);
            }

            if (triggeringAxis == this.aY)
            {
                this.aY.SetReadTrigger(mode);
            }
            else
            {
                this.aY.SetReadTrigger(GyroTriggerMode.ReadNotTriggered);
            }

            if (triggeringAxis == this.aZ)
            {
                this.aZ.SetReadTrigger(mode);
            }
            else
            {
                this.aZ.SetReadTrigger(GyroTriggerMode.ReadNotTriggered);
            }
            return(triggeringAxis);
        }
Example #2
0
        public MainViewModel(IAccelerometer accelerometer = null,
                             IGyroscope gyroscope         = null,
                             IMagnetometer magnetometer   = null,
                             ICompass compass             = null,
                             IAmbientLight ambientLight   = null,
                             IBarometer barometer         = null,
                             IPedometer pedometer         = null,
                             IProximity proximity         = null,
                             IHeartRateMonitor heartRate  = null,
                             IHumidity humidity           = null,
                             ITemperature temperature     = null)
        {
            this.Sensors = new List <ISensorViewModel>();
            this.AddIf(accelerometer, "G");
            this.AddIf(gyroscope, "G");
            this.AddIf(magnetometer, "M");
            this.AddIf(compass, "D");
            this.AddIf(ambientLight, "Light");
            this.AddIf(barometer, "Pressure");
            this.AddIf(pedometer, "Steps");
            this.AddIf(proximity, "Near");

            this.AddIf(heartRate, "Heart Rate (bpm)");
            this.AddIf(humidity, "Humidity");
            this.AddIf(temperature, "Temp");
        }
Example #3
0
        /// <summary>
        /// Creates an instance of <see cref="WindowsDevice" />.
        /// </summary>
        public WindowsDevice()
        {
            _display = new Display();
            _battery = new Battery();

            Query();

            try
            {
                var result = Windows.Devices.Sensors.Accelerometer.GetDefault();

                if (result != null)
                {
                    _accelerometer = new Accelerometer();
                }
            }
            catch (Exception)
            {
            }

            try
            {
                var result = Windows.Devices.Sensors.Gyrometer.GetDefault();

                if (result != null)
                {
                    _gyroscope = new Gyroscope();
                }
            }
            catch (Exception)
            {
            }
        }
Example #4
0
 /// <summary>
 /// Standard constructor of the Core class
 /// </summary>
 public Core()
 {
     m_pServoController = new PCA9685();
     m_pAccelerometer = new LSM303DLHC();
     m_pGyroscope = new L3GD20H();
     m_pTelemetryClient = new Client();
     m_pRemoteControl = new NetworkRemoteControl();
 }
Example #5
0
        public SensorGroup(ISuperSonic sonic, IGyroscope gyrescope)
        {
            Sonic = sonic;

            Gyroscope = gyrescope;
            Gyroscope.Initialize();
            Gyroscope.GyroscopeUpdate += Gyroscope_OnInterrupt;
        }
        public ComplementaryFilter(IAccelerometer accelerometer, IGyroscope gyroscope, int samplePeriodMs = 10, bool usePerformanceTimer = false)
        {
            this.accel = accelerometer;
            this.gyro = gyroscope;

            accelPoller = new Poller<IAccelerometer>(accelerometer, samplePeriodMs, usePerformanceTimer);
            accelPoller.OnSensorValueChanged += PollerEvent;
            if (accelerometer != gyroscope) // if we have two different sensors
            {
                gyroPoller = new Poller<IAccelerometer>(accelerometer, samplePeriodMs, usePerformanceTimer);
                gyroPoller.OnSensorValueChanged += PollerEvent;
            }
                
        }
   public TankDriveShaftEncodersAndYawGyroscopeBasedPositionTracker(
    string name,
    IGyroscope gyroscope, 
    IIncrementalRotaryEncoder leftShaftEncoder, 
    IIncrementalRotaryEncoder rightShaftEncoder,
    float wheelMetersPerShaftRadian
 )
       : base(name, DeviceType.PositionTracker)
   {
       this.gyroscope = gyroscope;
        this.leftShaftEncoder = leftShaftEncoder;
        this.rightShaftEncoder = rightShaftEncoder;
        this.wheelMetersPerShaftRadian = wheelMetersPerShaftRadian;
   }
Example #8
0
 public TankDriveShaftEncodersAndYawGyroscopeBasedPositionTracker(
     string name,
     IGyroscope gyroscope,
     IIncrementalRotaryEncoder leftShaftEncoder,
     IIncrementalRotaryEncoder rightShaftEncoder,
     float wheelMetersPerShaftRadian
     )
     : base(name, DeviceType.PositionTracker)
 {
     this.gyroscope = gyroscope;
      this.leftShaftEncoder = leftShaftEncoder;
      this.rightShaftEncoder = rightShaftEncoder;
      this.wheelMetersPerShaftRadian = wheelMetersPerShaftRadian;
 }
Example #9
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        /// <filterpriority>2</filterpriority>
        /// <remarks>Call <see cref="Dispose"/> when you are finished using the
        /// <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/>. The <see cref="Dispose"/> method
        /// leaves the <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/> in an unusable state. After
        /// calling <see cref="Dispose"/>, you must release all references to the
        /// <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/> so the garbage collector can reclaim
        /// the memory that the <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/> was occupying.</remarks>
        public override void Dispose()
        {
            if (base.IsDisposed)
            {
                return;
            }

            if (this._device != null)
            {
                this._device.Dispose();
                this._device = null;
            }

            if (this._aX != null)
            {
                this._aX.Dispose();
                this._aX = null;
            }

            if (this._aY != null)
            {
                this._aY.Dispose();
                this._aY = null;
            }

            if (this._aZ != null)
            {
                this._aZ.Dispose();
                this._aZ = null;
            }

            if (this._x != null)
            {
                this._x.Dispose();
                this._x = null;
            }

            if (this._y != null)
            {
                this._y.Dispose();
                this._y = null;
            }

            if (this._z != null)
            {
                this._z.Dispose();
                this._z = null;
            }
            base.Dispose();
        }
        /// <summary>
        ///     Construct a new Complementary filter with the specified accelerometer and gyroscope (which is often the same IC)
        /// </summary>
        /// <param name="accelerometer">The accelerometer to use</param>
        /// <param name="gyroscope">The gyroscope to use</param>
        /// <param name="samplePeriodMs">The sample period to poll these devices at</param>
        /// <param name="useHighResolutionTimer">Whether to use an accurate (but CPU-hungry) timer</param>
        public ComplementaryFilter(IAccelerometer accelerometer, IGyroscope gyroscope, int samplePeriodMs = 10,
                                   bool useHighResolutionTimer = false)
        {
            //RollQuaternion = new Quaternion(Xaxis, 0);
            //PitchQuaternion = new Quaternion(Yaxis, 0);

            accel = accelerometer;
            gyro  = gyroscope;

            accelPoller = new Poller <IAccelerometer>(accelerometer, samplePeriodMs, useHighResolutionTimer);
            accelPoller.OnNewSensorValue += PollerEvent;
            if (accelerometer != gyroscope) // if we have two different sensors
            {
                gyroPoller = new Poller <IAccelerometer>(accelerometer, samplePeriodMs, useHighResolutionTimer);
                gyroPoller.OnNewSensorValue += PollerEvent;
            }
        }
Example #11
0
 public MainViewModel(IAccelerometer accelerometer = null,
                      IGyroscope gyroscope         = null,
                      IMagnetometer magnetometer   = null,
                      ICompass compass             = null,
                      IAmbientLight ambientLight   = null,
                      IBarometer barometer         = null,
                      IPedometer pedometer         = null,
                      IProximity proximity         = null)
 {
     this.Sensors = new List <ISensorViewModel>();
     this.AddIf(accelerometer, "G");
     this.AddIf(gyroscope, "G");
     this.AddIf(magnetometer, "M");
     this.AddIf(compass, "D");
     this.AddIf(ambientLight, "Light");
     this.AddIf(barometer, "Pressure");
     this.AddIf(pedometer, "Steps");
     this.AddIf(proximity, "Near");
 }
Example #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/>
        /// class with the I2C device that represents the physical connection
        /// to the gyro.
        /// </summary>
        /// <param name="device">
        /// The I2C device that represents the physical connection to the gyro.
        /// If null, then it is assumed that the host is a revision 2 or higher
        /// board and a default <see cref="CyrusBuilt.MonoPi.IO.I2C.I2CBus"/>
        /// using the rev 2 I2C bus path will be used instead.
        /// </param>
        /// <exception cref="IOException">
        /// Unable to open the specified I2C bus device.
        /// </exception>
        /// <exception cref="ObjectDisposedException">
        /// The specified device instance has been disposed.
        /// </exception>
        public ADXL345(II2CBus device)
            : base()
        {
            if (device == null)
            {
                device = new I2CBus(BoardRevision.Rev2);
            }

            this._device = device;
            if (!this._device.IsOpen)
            {
                this._device.Open();
            }

            this._x = new AxisGyroscope(this, 20f);
            this._y = new AxisGyroscope(this, 20f);
            this._z = new AxisGyroscope(this, 20f);

            this._aX = (AxisGyroscope)this._x;
            this._aY = (AxisGyroscope)this._y;
            this._aZ = (AxisGyroscope)this._z;
        }
Example #13
0
		/// <summary>
		/// Initializes the Gyro.
		/// </summary>
		/// <param name="triggeringAxis">
		/// The gyro that represents the single axis responsible for
		/// the triggering of updates.
		/// </param>
		/// <param name="mode">
		/// The gyro update trigger mode.
		/// </param>
		/// <returns>
		/// Reference to the specified triggering axis, which may or may
		/// not have been modified.
		/// </returns>
		/// <exception cref="System.IO.IOException">
		/// Unable to write to gyro.
		/// </exception>
		/// <exception cref="ObjectDisposedException">
		/// This instance has been disposed.
		/// </exception>
		public IGyroscope Init(IGyroscope triggeringAxis, GyroTriggerMode mode) {
			this.Enable();

			if (triggeringAxis == this.aX) {
				this.aX.SetReadTrigger(mode);
			}
			else {
				this.aX.SetReadTrigger(GyroTriggerMode.ReadNotTriggered);
			}

			if (triggeringAxis == this.aY) {
				this.aY.SetReadTrigger(mode);
			}
			else {
				this.aY.SetReadTrigger(GyroTriggerMode.ReadNotTriggered);
			}

			if (triggeringAxis == this.aZ) {
				this.aZ.SetReadTrigger(mode);
			}
			else {
				this.aZ.SetReadTrigger(GyroTriggerMode.ReadNotTriggered);
			}
			return triggeringAxis;
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="AcceleratorSensorPage"/> class.
        /// </summary>
        public GyroscopePage()
        {
            var device = Resolver.Resolve<IDevice> ();

            Title ="Accelerator Sensor";
          
            if (device.Gyroscope == null)
            {
                Content = new Label () 
                {
                    TextColor = Color.Red,
                    Text = "Device does not have gyroscope sensor or it is not enabled."
                };

                return;
            }

            this.gyroscope = device.Gyroscope;

            var grid = new StackLayout ();

            this.xsensor = new SensorBarView () 
            {
                HeightRequest = 75,
                WidthRequest = 250,
                MinimumHeightRequest = 10,
                MinimumWidthRequest = 50,
                BackgroundColor = BackgroundColor
//                VerticalOptions = LayoutOptions.Fill,
//                HorizontalOptions = LayoutOptions.Fill
            };

            this.ysensor = new SensorBarView()
            {
                HeightRequest = 75,
                WidthRequest = 250,
                MinimumHeightRequest = 10,
                MinimumWidthRequest = 50,
                BackgroundColor = BackgroundColor
//                VerticalOptions = LayoutOptions.Fill,
//                HorizontalOptions = LayoutOptions.Fill
            };

            this.zsensor = new SensorBarView()
            {
                HeightRequest = 75,
                WidthRequest = 250,
                MinimumHeightRequest = 10,
                MinimumWidthRequest = 50,
                BackgroundColor = BackgroundColor
//                VerticalOptions = LayoutOptions.Fill,
//                HorizontalOptions = LayoutOptions.Fill
            };


            grid.Children.Add (new Label () { Text = string.Format ("Accelerometer data for {0}", device.Name) });
            grid.Children.Add (new Label () { Text = "X", XAlign = TextAlignment.Center });
            grid.Children.Add (this.xsensor);
            grid.Children.Add (new Label () { Text = "Y", XAlign = TextAlignment.Center });
            grid.Children.Add (this.ysensor);
            grid.Children.Add (new Label () { Text = "Z", XAlign = TextAlignment.Center });
            grid.Children.Add (this.zsensor);

            Content = grid;
        }
Example #15
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/>
		/// class with the I2C device that represents the physical connection
		/// to the gyro.
		/// </summary>
		/// <param name="device">
		/// The I2C device that represents the physical connection to the gyro.
		/// If null, then it is assumed that the host is a revision 2 or higher
		/// board and a default <see cref="CyrusBuilt.MonoPi.IO.I2C.I2CBus"/>
		/// using the rev 2 I2C bus path will be used instead.
		/// </param>
		/// <exception cref="IOException">
		/// Unable to open the specified I2C bus device.
		/// </exception>
		/// <exception cref="ObjectDisposedException">
		/// The specified device instance has been disposed.
		/// </exception>
		public ADXL345(II2CBus device)
			: base() {
			if (device == null) {
				device = new I2CBus(BoardRevision.Rev2);
			}

			this._device = device;
			if (!this._device.IsOpen) {
				this._device.Open();
			}

			this._x = new AxisGyroscope(this, 20f);
			this._y = new AxisGyroscope(this, 20f);
			this._z = new AxisGyroscope(this, 20f);

			this._aX = (AxisGyroscope)this._x;
			this._aY = (AxisGyroscope)this._y;
			this._aZ = (AxisGyroscope)this._z;
		}
Example #16
0
		/// <summary>
		/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
		/// </summary>
		/// <filterpriority>2</filterpriority>
		/// <remarks>Call <see cref="Dispose"/> when you are finished using the
		/// <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/>. The <see cref="Dispose"/> method
		/// leaves the <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/> in an unusable state. After
		/// calling <see cref="Dispose"/>, you must release all references to the
		/// <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/> so the garbage collector can reclaim
		/// the memory that the <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/> was occupying.</remarks>
		public override void Dispose() {
			if (base.IsDisposed) {
				return;
			}

			if (this._device != null) {
				this._device.Dispose();
				this._device = null;
			}

			if (this._aX != null) {
				this._aX.Dispose();
				this._aX = null;
			}

			if (this._aY != null) {
				this._aY.Dispose();
				this._aY = null;
			}

			if (this._aZ != null) {
				this._aZ.Dispose();
				this._aZ = null;
			}

			if (this._x != null) {
				this._x.Dispose();
				this._x = null;
			}

			if (this._y != null) {
				this._y.Dispose();
				this._y = null;
			}

			if (this._z != null) {
				this._z.Dispose();
				this._z = null;
			}
			base.Dispose();
		}
Example #17
0
 /**
  * Set the delegate implementation.
  *
  * @param _delegate The delegate implementing platform specific functions.
  */
 public void SetDelegate(IGyroscope _delegate)
 {
     this._delegate = _delegate;
 }
Example #18
0
 /**
  * Constructor with delegate.
  *
  * @param _delegate The delegate implementing platform specific functions.
  */
 public GyroscopeBridge(IGyroscope _delegate) : base()
 {
     this._delegate = _delegate;
 }
Example #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AcceleratorSensorPage"/> class.
        /// </summary>
        public GyroscopePage()
        {
            var device = Resolver.Resolve <IDevice> ();

            Title = "Accelerator Sensor";

            if (device.Gyroscope == null)
            {
                Content = new Label()
                {
                    TextColor = Color.Red,
                    Text      = "Device does not have gyroscope sensor or it is not enabled."
                };

                return;
            }

            this.gyroscope = device.Gyroscope;

            var grid = new StackLayout();

            this.xsensor = new SensorBarView()
            {
                HeightRequest        = 75,
                WidthRequest         = 250,
                MinimumHeightRequest = 10,
                MinimumWidthRequest  = 50,
                BackgroundColor      = BackgroundColor
//                VerticalOptions = LayoutOptions.Fill,
//                HorizontalOptions = LayoutOptions.Fill
            };

            this.ysensor = new SensorBarView()
            {
                HeightRequest        = 75,
                WidthRequest         = 250,
                MinimumHeightRequest = 10,
                MinimumWidthRequest  = 50,
                BackgroundColor      = BackgroundColor
//                VerticalOptions = LayoutOptions.Fill,
//                HorizontalOptions = LayoutOptions.Fill
            };

            this.zsensor = new SensorBarView()
            {
                HeightRequest        = 75,
                WidthRequest         = 250,
                MinimumHeightRequest = 10,
                MinimumWidthRequest  = 50,
                BackgroundColor      = BackgroundColor
//                VerticalOptions = LayoutOptions.Fill,
//                HorizontalOptions = LayoutOptions.Fill
            };


            grid.Children.Add(new Label()
            {
                Text = string.Format("Accelerometer data for {0}", device.Name)
            });
            grid.Children.Add(new Label()
            {
                Text = "X", XAlign = TextAlignment.Center
            });
            grid.Children.Add(this.xsensor);
            grid.Children.Add(new Label()
            {
                Text = "Y", XAlign = TextAlignment.Center
            });
            grid.Children.Add(this.ysensor);
            grid.Children.Add(new Label()
            {
                Text = "Z", XAlign = TextAlignment.Center
            });
            grid.Children.Add(this.zsensor);

            Content = grid;
        }
Example #20
0
 public MotionStateSnapshotLog(IPositionTracker positionTracker, IGyroscope yawGyroscope, TimeSpan snapshotCullingExpiration) : base(snapshotCullingExpiration)
 {
     this.positionTracker = positionTracker;
     this.yawGyroscope    = yawGyroscope;
 }