fluttercommunity / fluttercommunity/plus_plugins

[Request][sensors_plus]: Get absolute values of Gyroscope readings

Open
#1,954 2 comments 2 reactions 0 assignees View on GitHub
enhancement triage
Dominant language
Dart
Stars
1.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

### Plugin

sensors_plus

### Use case

From `gyroscopeEvents` I can get the delta of orientation of a device (I guess it's in `radians/second`). So if the device is currently not rotating the reading is zero.

In some cases, the developer needs to have absolute values (e.g. in `radians`). For example in my scenario when I want to show an image to a user, where user can move the image just by rotating his device. The image needs to be centered when the device is pointing straight, and that's when the absolute values are needed.

Another example of a use case could be those games where you need to tilt your phone to get a ball to a hole through obstacles. The app needs to know when the device is completely flat.

The only package that has this functionality is [aeyrium_sensor](https://pub.dev/packages/aeyrium_sensor) (it's very poorly maintained). I went through the code and there is a little heuristic to be able to get those absolute readings, but I tested it, and it works well on both iOS and Android. Therefore I would suggest taking the platform code from there.

I'm not that much skilled in the platform code, but if needed I can make the PR. Just let me know.

### Proposal

Current `gyroscopeEvents` readings :
```
device pointing straight: pitch = 0, roll...
device pointing down: pitch = 0, roll...
```

Example of the requested `gyroscopeAbsoluteEvents` readings:
```
device pointing straight: pitch = 0, roll...
device pointing down: pitch = -1.57, roll...
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.