RU | EN
flutter_rotation_sensor_aurora
Original Readme.
Description
flutter_rotation_sensor_aurora is the Aurora OS implementation of the flutter_rotation_sensor plugin, which provides easy access to the device's physical orientation in three distinct representations: rotation matrix, quaternion, and Euler angles (azimuth, pitch, roll). This is ideal for applications requiring precise tracking of the device's movement or orientation in space, such as augmented reality, gaming, navigation, and more.
Quickstart: Basic Usage Example
import 'package:flutter_rotation_sensor/flutter_rotation_sensor.dart';
// Using StreamBuilder for real-time updates
StreamBuilder<OrientationData>(
stream: RotationSensor.orientationStream,
builder: (context, snapshot) {
if (snapshot.hasData) {
final data = snapshot.data!;
return Text('''
Quaternion: ${data.quaternion}
Euler Angles: ${data.eulerAngles}
Rotation Matrix: ${data.rotationMatrix}
''');
} else if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
} else {
return const CircularProgressIndicator();
}
},
);
// Direct stream subscription
final subscription = RotationSensor.orientationStream.listen((data) {
print('Azimuth: ${data.eulerAngles.azimuth}');
print('Pitch: ${data.eulerAngles.pitch}');
print('Roll: ${data.eulerAngles.roll}');
});
Features
- Real-time Rotation Data: Access to real-time rotation data with customizable update intervals
- Multiple Formats Supported: Provides rotation matrix, quaternion, and Euler angles (azimuth, pitch, roll)
- Coordinate System Remapping: Supports orientation coordinate system remapping
- Customizable Sampling Rates: Set precise update intervals for optimal performance
Limitations
- Qt 5.6 Limitation: In the current Aurora OS and Qt 5.6 implementation, it is not possible to programmatically obtain the sensor accuracy for orientation sensors (e.g., no “high”, “medium”, “low” accuracy levels). Accuracy values are always reported as -1, meaning no accuracy information is available.
- Limitation when switching device orientation mode: When switching the device's orientation mode (from dynamic to fixed), it is necessary to receive orientation data several times in order to establish the correct orientation mode.
Contents
- Installation and build
- Detailed description
- Compatibility
- Terms of use and participation in development
Installation and build
pubspec.yaml
dependencies:
flutter_rotation_sensor: ^0.1.1
flutter_rotation_sensor_aurora:
git:
url: https://developer.auroraos.ru/git/flutter/flutter-community-plugins/flutter_rotation_sensor_aurora.git
*main.cpp
#include <flutter/flutter_compatibility_qt.h> // add this line
int main(int argc, char *argv[]) {
...
aurora::FlutterApp app(argc, argv);
aurora::EnableQtCompatibility(); // add this line
...
}
Detailed description
Implementation Features
This Aurora OS implementation uses a sophisticated sensor fusion approach to provide stable and accurate orientation data:
Sensors Used:
- Gyroscope - Provides precise angular velocity measurements for smooth rotation tracking
- Accelerometer - Detects gravity vector for absolute orientation reference
- Magnetometer - Provides Earth's magnetic field data for heading correction
- Orientation Sensor - Detects device screen orientation for coordinate system correction
Fusion Algorithm: The plugin implements the Madgwick Filter - an advanced sensor fusion algorithm that combines data from all three sensors (gyroscope, accelerometer, magnetometer) to produce a stable orientation quaternion. Key features of the implementation:
- Adaptive Gain Control: Dynamically adjusts filter parameters based on motion intensity
- Sensor Reliability Validation: Automatically detects and handles unreliable sensor data
- Gyro-Only Integration: Falls back to gyroscope integration during high-acceleration periods
- Orientation Correction: Applies screen orientation-specific coordinate transformations
- Quaternion Output: Provides orientation as quaternions for smooth interpolation and minimal gimbal lock
Coordinate System: The implementation uses a right-handed coordinate system where:
- X-axis: Points east
- Y-axis: Points north
- Z-axis: Points up
Sensor Synchronization:
- All sensors are synchronized within a 50ms time window
- Default sampling rate: 100Hz (10ms intervals)
- Automatic timestamp alignment for precise data fusion
Configuration
Configure the rotation sensor with custom sampling periods:
// Set the sampling period for the rotation sensor
RotationSensor.samplingPeriod = SensorInterval.uiInterval;
// Set custom duration
RotationSensor.samplingPeriod = Duration(milliseconds: 100);
// Set coordinate system transformation
RotationSensor.coordinateSystem = CoordinateSystem.transformed(Axis3.X, Axis3.Z);
Available Sampling Periods:
-
SensorInterval.normal(200ms): Default rate, suitable for general use -
SensorInterval.ui(66ms): Suitable for UI updates -
SensorInterval.game(20ms): Suitable for games and smooth motion -
SensorInterval.fastest(0ms): Updates as fast as possible
Compatibility
The application has been working correctly since the 5.0.0 version of the Aurora OS.
Terms of Use and Participation
The source code of the project is provided under the license, that allows it to be used in third-party applications.
To participate in the development of the project, please read the contributor agreement. If you plan to contribute your own source code to the project, you will need to accept the CLA agreement.
For information about contributors see AUTHORS.
Code of conduct is a current set of rules of the Open Mobile Platform which informs you how we expect the members of the community will interact while contributing and communicating.