accelerometers¶
Source code: accelerometers.py
A factory test for reading accelerometers
Description¶
This is a test to check if values read back from accelerometers are within a certain range. If we put it on a flat table we can get (x, y, z) = (0, 0, 9.8) at an ideal case. For upside down we’ll have (x, y, z) = (0, 0, -9.8).
Since accelerometer is very sensitive, the digital output will be different for each query. For example, (0.325, -0.278, 9.55). In addition, temperature or the assembly quality may impact the accuracy of the accelerometer during manufacturing (ex, position is tilt). To mitigate this kind of errors, we’ll sample several records of raw data and compute its average value under an ideal environment.
Test Procedure¶
The test will auto start unless argument autostart is false, otherwise, it will wait for operators to press SPACE.
Check if values are within the threshold, pass / fail automatically.
Dependency¶
Device API (
cros.factory.device.accelerometer
)
Examples¶
If the device is expected to be place horizontally on desk, this test can be added as simple as:
{
"pytest_name": "accelerometers",
"label": "Base Accelerometers Test",
"run_if": "not constants.has_device_data or device.component.has_base_accelerometer",
"related_components": [
"test_tags.TestCategory.ACCELEROMETER"
],
"args": {
"location": "base"
}
}
{
"pytest_name": "accelerometers",
"label": "Lid Accelerometers Test",
"run_if": "not constants.has_device_data or device.component.has_lid_accelerometer",
"related_components": [
"test_tags.TestCategory.ACCELEROMETER"
],
"args": {
"location": "lid"
}
}
You can also change the limits of each axis to loose the criteria:
{
"pytest_name": "accelerometers",
"label": "Base Accelerometers Test With Looser Limits",
"run_if": "not constants.has_device_data or device.component.has_base_accelerometer",
"related_components": [
"test_tags.TestCategory.ACCELEROMETER"
],
"args": {
"location": "base",
"limits": {
"x": [
-1.0,
1.0
],
"y": [
-1.0,
1.0
],
"z": [
8.0,
11.0
]
}
}
}
Test Arguments¶
Name |
Type |
Description |
---|---|---|
autostart |
bool |
(optional; default: |
limits |
dict, None |
(optional; default: |
sample_rate_hz |
int |
(optional; default: |
capture_count |
int |
(optional; default: |
setup_time_secs |
int |
(optional; default: |
location |
[‘base’, ‘lid’] |
(optional; default: |