Skip to content

SensorSamplingPackage

The built-in sampling package for collecting data from the phone's sensors.

Registered automatically in the SamplingPackageRegistry. Add a Measure with one of the measure types below to a task in your protocol to use it. All measures use the Smartphone primary device. It collects:

  • accelerometer (rate of change in velocity, including and excluding gravity)
  • gyroscope (rotation)
  • magnetometer (compass)
  • acceleration features (e.g. mean, variance, etc. calculated over a sampling period)
  • ambient light (from the phone's light sensor)
  • pedometer (step events)

Ambient light is only available on Android. Step events need the activity recognition permission.

Raw sensor measures emit many events per second. Use ACCELERATION_FEATURES or a short trigger window to limit data volume.

Inheritance

Constructors

SensorSamplingPackage

SensorSamplingPackage()

Constants

ACCELERATION

String const ACCELERATION

Rate of change in velocity, including gravity, along perpendicular x, y, and z axes in the device's coordinate system.

ACCELERATION_FEATURES

String const ACCELERATION_FEATURES

A set of acceleration (non-gravitational) features calculated over a specific sampling period.

AMBIENT_LIGHT

String const AMBIENT_LIGHT

Ambient light from the phone's light sensor.

MAGNETIC_FIELD

String const MAGNETIC_FIELD

Magnetic field around the phone in x,y,z (typically measured by a magnetometer).

NON_GRAVITATIONAL_ACCELERATION

String const NON_GRAVITATIONAL_ACCELERATION

Rate of change in velocity, excluding gravity, along perpendicular x, y, and z axes in the phone's coordinate system.

ROTATION

String const ROTATION

Rotation of the phone in x,y,z (typically measured by a gyroscope).

STEP_COUNT

String const STEP_COUNT

Total step count since last system boot from the phone's pedometer. Kept for backwards compatibility with CAMS 1.x protocols (protocol API level < 2.0) - use STEP_EVENT instead.

  • Event-based measure.
  • Uses the Smartphone device for data collection.
  • No sampling configuration needed.

STEP_EVENT

String const STEP_EVENT

Step event from the phone's pedometer. Note that this measure type is different from the "stepcount" measure type, which provides aggregated step counts over a time period.

  • Event-based measure (one event per step).
  • Uses the Smartphone device for data collection.
  • No sampling configuration needed.

Properties

samplingSchemes

DataTypeSamplingSchemeMap get samplingSchemes
override

The default sampling schemes for all dataTypes in this package.

All sampling packages should define a DataTypeSamplingScheme for each data type.

Methods

create

Probe? create(
  1. String type
)
override

Creates a new Probe of the specified type. Note that type should be one of the dataTypes that this package supports. Returns null if a probe cannot be created for the type.