I have been creating an application on Flutter, using a package "sensors_plus" to retrieve step count when a user is walking or running ([https://pub.dev/packages/sensors_plus]). It is giving me the values of mobile sensor accelerometer but the gravitational force is getting applied all the time which is disturbing the final result is there any way to ignore the gravitational force.
From the values of accelerometer I am calculating the acceleration but as the gravitational force is acting all the time causing a non zero value of acceleration even though the device is in stationary position.
//MARK: - Variables & Constants
List<double>? _accelerometerValues;
final _streamSubscriptions = <StreamSubscription<dynamic>>[];
double? acceleration;
//MARK: -View LifeCycle
@override
void initState() {
super.initState();
_streamSubscriptions.add(
accelerometerEvents.listen(
(AccelerometerEvent event) {
setState(() {
_accelerometerValues = <double>[event.x, event.y, event.z];
acceleration =
sqrt(event.x * event.x + event.y * event.y + event.z * event.z);
});
},
),
);
}
I used the package mentioned, getting the value from accelerometers on x, y and z plane and calculating the net acceleration but because of the gravitational force I am not getting the accurate answer. Can anyone help me in this or put an idea how can we count steps more precisely.