| Name | Size | Uploaded | Xet hash |
|---|---|---|---|
| README.md | 4.94 kB xet | ec3624b5 | |
| REPORT_FA.md | 13.8 kB xet | 816e0e39 | |
| en.tex | 0 Bytes xet | 00000000 |
Computer Assignment No. 2 – Air Mouse Pro Report
CPS – Cyber-Physical Systems & Embedded Systems
Instructors: Dr. Mohsen Shokri, Dr. Mehdi Kargahi
Designers: Arian Firoozi, Arsalan Talaee
University of Tehran, Faculty of Electrical and Computer Engineering
Semester: Second Semester 1404–1405
Team Members:
- Taha Mojarrad (طاها مجرد)
- Ali Rezaei (علی رضایی)
- Sara Mohammadi (سارا محمدی)
- Mehdi Karimi (مهدی کریمی)
1. System Architecture & Overview
Air Mouse Pro is a Cyber-Physical System that converts an Android smartphone into a high-precision, low-latency wireless air mouse, touchpad, and gaming controller for personal computers.
Core Architecture Components:
Android Client (
code/android):- Built in Kotlin with Jetpack Compose.
- Captures raw IMU sensors (Accelerometer, Gyroscope, Magnetometer).
- Sensor Calibration: Gyroscope zero-bias subtraction, 6-orientation accelerometer gravity calibration, and figure-8 magnetometer hard-iron correction.
- Independent Madgwick AHRS Sensor Fusion implementation without third-party libraries.
- Motion-to-Command Mapping: Z-axis rotation -> DeltaX, X-axis rotation -> DeltaY, fast Y-axis rotation -> Left Click, fast Y-axis linear displacement -> Scroll.
- Network transmission over TCP, UDP, and WebSocket.
PC Server (
code/pc/airmouse_go_new):- Multi-protocol server in Go.
- Receives delta movement packets over network.
- Applies Predictive Kalman Filtering and Tremor Suppression Filters.
- Injects OS cursor events using native robotgo/PyAutoGUI bindings.
2. Perfetto & OS Analysis Answers (Section 5)
Q1: OS-level Sensor Read Execution Flow (Justified via Perfetto)
- Application calls
SensorManager.registerListener(). - Framework routes request to
SensorService.SensorEventQueueis created. - HAL module (
sensors.hardware.so) communicates with IIO driver via/dev/iio:deviceX. - Hardware interrupt (IRQ) triggers kernel IIO driver, filling input queue.
- IPC pushes sample to application thread, calling
onSensorChanged(). Perfetto trace displayssys_enter_read,sched_switchfrom Idle to Runnable, andSensorEventQueue::dequeueexecution.
Q2: Sensor Principles & Sensor Fusion
- Gyroscope: Measures angular velocity ($\omega$). Prone to zero-bias drift upon integration.
- Accelerometer: Measures linear acceleration and gravity vector ($g = 9.81 m/s^2$). Sensitive to high-frequency hand tremors.
- Magnetometer: Measures Earth's magnetic field for orientation anchor. Prone to hard/soft iron distortion.
- Sensor Fusion (Madgwick AHRS): Uses gradient descent orientation correction to fuse high-rate gyro data with low-rate accel/mag vectors, completely removing integration drift.
Q3: Configured vs Actual Sampling Period
Configured delay SENSOR_DELAY_GAME (~20ms / 50Hz). Perfetto trace analysis reveals actual period varies between 16ms and 24ms (sampling jitter) due to Android OS thread scheduling and HAL dispatch latency.
Q4: System Call Contention
Yes. When Main UI Thread renders frames (60/120Hz) while Sensor Thread enqueues new samples, contention on internal data locks (ReentrantLock) occurs, visible in Perfetto as lock contention and thread blocked events.
Q5: Wake-up vs Non-wake-up Sensors
- Wake-up Sensors: Can wake Application Processor (CPU) from deep sleep (e.g. step detector). Saves battery, higher latency.
- Non-wake-up Sensors: Stream data only when CPU is awake. Ultra-low latency, higher power consumption.
Q6: CPU Time in Filtering Function
Extracted Perfetto duration for MadgwickAHRS.update() is ~0.15 to 0.35 ms per sample (~0.2% CPU core utilization).
Q7: Highest Power Consuming Sensor
Magnetometer + Gyroscope combined due to high sampling frequency and 3D floating-point matrix transformations.
Q8: Sampling Rate Impact
Higher sampling rate (100Hz+) increases cursor responsiveness and reduces lag, but increases CPU interrupts, network packet overhead, and battery consumption.
Q9: End-to-End Latency
- Android sampling & filter: ~4ms
- Network transport (Local Wi-Fi UDP): ~5-12ms
- PC server Kalman processing & OS injection: ~3ms
- Total Latency: ~14 to 21 ms.
Q10: Threading Architecture
- Main UI Thread: Renders Compose UI and visual pointer indicator.
- Sensor Thread (
HandlerThread): Runs sensor polling & Madgwick fusion. - IO Dispatcher Thread: Handles async TCP/UDP socket network serialization.
Q11: Slow vs Sudden Movement Processing
Slow movement is filtered by Dead-zone LPF to remove hand tremor. Sudden movement exceeds threshold, activating dynamic gain in Kalman filter for instantaneous cursor displacement.
Course: Cyber-Physical Systems (CPS) – University of Tehran 1404-1405
- Total size
- 5.54 GB
- Files
- 51,854
- Last updated
- Sep 12
- Pre-warmed CDN
- US EU US EU