Gyro¶
As previously mentioned, the BMI160 is a 6-axis IMU that has both an accelerometer and gyroscope. The gyro sensor on this device is represented by the IGyroBmi160 interface and uses the Coriolis effect to measure angular velocity .
using MbientLab.MetaWear.Sensor;
IGyroBmi160 gyro = metawear.GetModule<IGyroBmi160>();
Configuration¶
Like the accelerometer, the gyro also has a configurable output data rate and range. Use the gyro’s Configure. method to set these parameters.
using MbientLab.MetaWear.Sensor;
using MbientLab.MetaWear.Sensor.GyroBmi160;
// set the data rat to 50Hz and the
// data range to +/- 2000 degrees/s
gyro.Configure(OutputDataRate._50Hz, DataRange._2000dps);
Angular Velocity Data¶
To retrieve angular velocity data, add a data route to the async data producer returned by the AngularVelocity property. Data values from that async producer are represented by the AngularVelocity class.
await gyro.AngularVelocity.AddRouteAsync(source =>
source.Stream(data => Console.WriteLine("angular velocity = " + data.Value<AngularVelocity>()))
);