CARP Mobility Package

A comprehensive Flutter package for conducting standardized mobility assessments using smartphone and wearable sensors. This package provides clinical-grade mobility tests commonly used in healthcare and research settings to assess physical function, balance, and fall risk.

Features

Mobility Tests

  • Timed Up and Go (TUG) Test: Comprehensive assessment of mobility, balance, and fall risk
  • Walking Test (10-Meter Walk Test): Measures walking speed and gait performance
  • Sit-to-Stand Test (STS): Evaluates lower body strength and functional mobility
  • Shoulder Range of Motion (SROM) Tests: Assesses shoulder flexibility and range of motion
    • Flexion/Extension movements
    • Abduction movements
    • Internal/External rotation

Sensor Support

  • Smartphone Sensors: Built-in accelerometer, gyroscope, and magnetometer
  • Movesense Devices: External wearable sensors for enhanced precision
  • Flexible Sensor Placement: Support for various body locations (chest, waist, thigh, etc.)

Advanced Features

  • Real-time sensor data processing and analysis
  • Automatic event detection (stand-up, sit-down, turns, steps)
  • Calibration procedures for accurate measurements
  • Multi-language support with localization
  • Comprehensive result reporting with timing metrics
  • Research Package integration for structured test workflows

Getting Started

Prerequisites

  • Flutter SDK 3.7.2 or higher
  • Android/iOS device with motion sensors
  • (Optional) Movesense device for enhanced sensor capabilities

Installation

Add this package to your pubspec.yaml:

dependencies:
  carp_mobility_package: ^0.1.0

Run:

flutter pub get

Permissions

Add the following permissions to your app:

Android (android/app/src/main/AndroidManifest.xml):

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

iOS (ios/Runner/Info.plist):

<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app uses Bluetooth to connect to Movesense devices</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app uses location services for Bluetooth device discovery</string>

Usage

Basic TUG Test Implementation

import 'package:carp_mobility_package/carp_mobility_package.dart';
import 'package:research_package/research_package.dart';

class MobilityTestScreen extends StatefulWidget {
  @override
  _MobilityTestScreenState createState() => _MobilityTestScreenState();
}

class _MobilityTestScreenState extends State<MobilityTestScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: RPUITask(
        task: TugTask(identifier: 'tug_assessment'),
        onSubmit: (RPTaskResult result) {
          // Handle test results
          print('TUG Test completed: ${result.toString()}');
        },
      ),
    );
  }
}

Walking Test with Custom Parameters

import 'package:carp_mobility_package/carp_mobility_package.dart';

// Create a custom walking test with specific step count
final wtMeasure = WTMeasure(
  type: 'wt',
  name: 'Custom Walk Test',
  numberOfSteps: 20, // Custom step count
);

final walkingTask = WTTask(
  identifier: 'walking_assessment',
  measure: wtMeasure,
);

// Use in RPUITask
RPUITask(
  task: walkingTask,
  onSubmit: (result) {
    final wtResult = result.results['wt_test'] as WTResult?;
    if (wtResult != null) {
      print('Walking time: ${wtResult.time} seconds');
    }
  },
)

Sit-to-Stand Test

import 'package:carp_mobility_package/carp_mobility_package.dart';

final stsTask = StsTask(identifier: 'sts_assessment');

RPUITask(
  task: stsTask,
  onSubmit: (result) {
    final stsResult = result.results['sts_test'] as StsResult?;
    if (stsResult != null) {
      print('STS repetitions: ${stsResult.repetitions}');
      print('Test duration: ${stsResult.duration}');
    }
  },
)

Shoulder Range of Motion Tests

import 'package:carp_mobility_package/carp_mobility_package.dart';

// Flexion test
final flexionTask = FlexionTask(identifier: 'shoulder_flexion');

// Abduction test
final abductionTask = AbductionTask(identifier: 'shoulder_abduction');

// External rotation test
final externalRotationTask = ExternalRotationTask(identifier: 'shoulder_external_rotation');

Test Descriptions

Timed Up and Go (TUG) Test

The TUG test measures the time it takes for a person to stand up from a chair, walk a short distance, turn around, walk back, and sit down. It includes:

  • Stand-up detection using accelerometer data
  • Turn detection using gyroscope integration
  • Sit-down detection with timing validation
  • Calibration phase for accurate turn angle measurement

Walking Test (10-Meter Walk Test)

Measures walking speed and step detection over a specified distance:

  • Real-time step counting using accelerometer peaks
  • Configurable step targets (default: 15 steps)
  • Walking time measurement for speed calculation
  • Optimized for various sensor placements

Sit-to-Stand Test

Evaluates lower body strength through repeated standing motions:

  • 30-second test duration
  • Automatic repetition counting
  • Stand/sit cycle detection
  • Performance metrics calculation

Shoulder Range of Motion Tests

Assess shoulder joint flexibility and mobility:

  • Flexion/Extension: Forward and backward arm movements
  • Abduction: Arm movement away from body
  • Internal/External Rotation: Rotational movements
  • Gyroscope-based angle measurement

Configuration Options

Sensor Locations

  • SensorLocation.chest - Chest mounted (recommended for TUG)
  • SensorLocation.waist - Waist/belt mounted
  • SensorLocation.pocket - Smartphone in pocket
  • SensorLocation.thigh - Thigh mounted
  • SensorLocation.upperArm - Upper arm (for SROM tests)

Sampling Rates

  • Accelerometer: 26Hz, 52Hz, 104Hz, 208Hz
  • Gyroscope: 26Hz, 52Hz, 104Hz, 208Hz
  • Magnetometer: 26Hz, 52Hz, 104Hz, 208Hz

Example App

A complete example application is available in the /example directory, demonstrating:

  • All mobility test implementations
  • Sensor selection interfaces
  • Result processing and display
  • Best practices for integration

To run the example:

cd example
flutter run

Localization

The package supports multiple languages:

  • English (en)
  • Danish (da)
  • Hungarian (hu)

Add custom translations by extending the localization files in assets/lang/.

Research Integration

This package is designed for clinical research and integrates with:

Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests for any improvements.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use this package in research, please cite:

CARP Mobility Package. (2025). Copenhagen Research Platform (CARP).

Support

Libraries

carp_mobility_package
domain/config/mobility_config
domain/config/srom_config
domain/config/sts_config
domain/config/tug_config
domain/config/wt_config
domain/measures/mobility_measure
domain/measures/srom_measure
domain/measures/sts_measure
domain/measures/tug_measure
domain/measures/wt_measure
domain/results/mobility_result
domain/results/srom_result
domain/results/sts_result
domain/results/tug_calibration_result
domain/results/tug_result
domain/results/wt_result
domain/steps/mobility_step
domain/steps/srom/abduction/abduction_instructions_step
domain/steps/srom/abduction/abduction_preparation_step
domain/steps/srom/extension/extension_instructions_step
domain/steps/srom/extension/extension_preparation_step
domain/steps/srom/external_rotation/external_rotation_instructions_step
domain/steps/srom/external_rotation/external_rotation_preparation_step
domain/steps/srom/flexion/flexion_instructions_step
domain/steps/srom/flexion/flexion_preparation_step
domain/steps/srom/internal_rotation/internal_rotation_instructions_step
domain/steps/srom/internal_rotation/internal_rotation_preparation_step
domain/steps/srom/srom_realtime_angle_tracker
domain/steps/srom/srom_result_step
domain/steps/srom/srom_test_step
domain/steps/sts/sts_instructions_step
domain/steps/sts/sts_preparation_step
domain/steps/sts/sts_realtime_progress_tracker
domain/steps/sts/sts_result_step
domain/steps/sts/sts_test_step
domain/steps/tug/tug_calibration
domain/steps/tug/tug_instructions_step
domain/steps/tug/tug_preparation_step
domain/steps/tug/tug_result_step
domain/steps/tug/tug_test_step
domain/steps/wt/wt_instructions_step
domain/steps/wt/wt_preparation_step
domain/steps/wt/wt_result_step
domain/steps/wt/wt_test_step
domain/tasks/abduction_task
domain/tasks/extension_task
domain/tasks/external_rotation_task
domain/tasks/flexion_task
domain/tasks/internal_rotation_task
domain/tasks/sts_task
domain/tasks/tug_task
domain/tasks/wt_task
localization/mp_localizations
sensing/probes/mobility_probe
sensing/processors/mobility_processor
sensing/processors/srom/abduction_strategy
sensing/processors/srom/extension_strategy
sensing/processors/srom/external_rotation_strategy
sensing/processors/srom/flexion_strategy
sensing/processors/srom/internal_rotation_strategy
sensing/processors/srom/srom_movement_strategy
sensing/processors/srom/srom_processor
sensing/processors/sts_processor
sensing/processors/tug_processor
sensing/processors/wt_processor
sensing/sensors/movesense_sensor
sensing/sensors/sensor
sensing/sensors/sensor_event
sensing/sensors/smartphone_sensor
ui/steps/srom/abduction/abduction_instructions_step_ui
ui/steps/srom/abduction/abduction_preparation_step_ui
ui/steps/srom/extension/extension_instructions_step_ui
ui/steps/srom/extension/extension_preparation_step_ui
ui/steps/srom/external_rotation/external_rotation_instructions_step_ui
ui/steps/srom/external_rotation/external_rotation_preparation_step_ui
ui/steps/srom/flexion/flexion_instructions_step_ui
ui/steps/srom/flexion/flexion_preparation_step_ui
ui/steps/srom/internal_rotation/internal_rotation_instructions_step_ui
ui/steps/srom/internal_rotation/internal_rotation_preparation_step_ui
ui/steps/srom/srom_result_step_ui
ui/steps/srom/srom_test_step_ui
ui/steps/sts/sts_instructions_step_ui
ui/steps/sts/sts_preparation_step_ui
ui/steps/sts/sts_result_step_ui
ui/steps/sts/sts_test_step_ui
ui/steps/tug/tug_calibration_step_ui
ui/steps/tug/tug_instructions_step_ui
ui/steps/tug/tug_preparation_step_ui
ui/steps/tug/tug_result_step_ui
ui/steps/tug/tug_test_step_ui
ui/steps/wt/wt_instructions_step_ui
ui/steps/wt/wt_preparation_step_ui
ui/steps/wt/wt_result_step_ui
ui/steps/wt/wt_test_step_ui
ui/widgets/bullet_item
ui/widgets/countdown_circle
ui/widgets/instruction_video_player
ui/widgets/sensor_xyz_plot
utils/utils