summaryrefslogtreecommitdiff
path: root/test/math_util.c
Commit message (Collapse)AuthorAgeFilesLines
* coil: remove motion_sense*Mary Ruthven2021-01-061-9/+0
| | | | | | | | | | | | | This code uses coil terms we're removing, but we don't use it in platform/cr50. Remove the code instead of replacing the terms. BUG=b:175244613 TEST=make buildall -j Change-Id: Ic2bd31ba28527d6b68016ceae89a93c80827cd27 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2613445 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* type: Rename matrix_3x3_t to mat33_fp_tYilun Lin2018-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Naming of many vector types and matrix types are not clear enough. For example, we have: vector_3_t, which is a vector of three int. vec3_t, which is a vector of three float. size4_t, which is a vector of four size_t. mat33_t, which is a 3x3 matrix of float. matrix_3x3_t, which is a 3x3 matrix of fixed point. Besides, we have types like int8_t, uint16_t types. To clearly distinguished types, the CL propose to, For vector types, naming should be `$type + 'v' + $num + '_t'`: vector_3_t becomes intv3_t vec3_t becomes floatv3_t vector 4 of uint16_t becomes uint16v4_t (which doesn't exist yet) For matrix types, naming should be `mat$N$N_` + $type + '_t', where $N is the matrix size: matrix_3x3_t becomes mat33_fp_t # fp: fixed point mat33_t becomes mat33_float_t TEST=make buildall -j BUG=b:114662791 Change-Id: I51d88d44252184e4b7b3564236833b0b892edc39 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1215449 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* type: Rename vector_3_t to intv3_t.Yilun Lin2018-09-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Naming of many vector types and matrix types are not clear enough. For example, we have: vector_3_t, which is a vector of three int. vec3_t, which is a vector of three float. size4_t, which is a vector of four size_t. mat33_t, which is a 3x3 matrix of float. matrix_3x3_t, which is a 3x3 matrix of fixed point. Besides, we have types like int8_t, uint16_t types. To clearly distinguished types, the CL propose to, For vector types, naming should be `$type + 'v' + $num + '_t'`: vector_3_t becomes intv3_t vec3_t becomes floatv3_t vector 4 of uint16_t becomes uint16v4_t (which doesn't exist yet) For matrix types, naming should be `mat$N$N_` + $type + '_t', where $N is the matrix size: matrix_3x3_t becomes mat33_fp_t # fp: fixed point mat33_t becomes mat33_float_t TEST=make buildall -j BUG=b:114662791 Change-Id: I865aa3ecbab6cb97f8585a081a679adf00febe1d Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1215442 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* math: Add inverse matrix calculationGwendal Grignou2015-08-241-0/+34
| | | | | | | | | | | | | | | | Add a slow inverse matrix calculation function. It is needed to apply factory offset properly. Also consider the NULL matrix the identity matrix. BRANCH=smaug,cyan TEST=Unit test BUG=chromium:517675 Change-Id: Ifa11954992e6f2fab02b4e92684e7b01bbaafe94 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/294594 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
* Convert motion sense calculations to fixed point.Randall Spangler2015-02-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Motion sense calculations do not require huge amounts of precision, so fixed point is plenty accurate. And fixed point works on Cortex-M0, which lacks a FPU. BUG=chrome-os-partner:36126 BRANCH=minnie (samus already works with the FPU, but could grab this if we want additional testing) TEST=manual 1. Boot system 2. At EC console: accelinfo on 250 3. Move lid through several different angles (30 degrees to max open) and see that it updates correctly and relatively smoothly. A few degrees of angle jitter is normal. 4. At several angles, rotate the chromebook around and see that the lid angle remains relatively stable. 5. If the hinge is made normal to the ground (or within 15 degrees of vertical), the angle should read 500, since the acceleration vectors don't yield good results in that orientation (for either fixed or float math). And run 'make buildall -j', which tests arc_cos() and lid angle calculations Change-Id: I70a0d08b8914629a3e21ae5578cbe8e50f29ad68 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/244116 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* math: use CONFIG_FPU when using float.Gwendal Grignou2014-11-091-1/+5
| | | | | | | | | | | | | ifdef code than needs CONFIG_FPU (acos and friends) BRANCH=ToT BUG=chrome-os-partner:32050 TEST=define CONFIG_FPU on host board and use it. Change-Id: I1c4ed16c23450bb4059d26044f4c1fe45b33674e Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226414 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Sheng-liang Song <ssl@chromium.org>
* samus: added gyro support for lsm6ds0Sheng-Liang Song2014-08-261-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Changed motion_sense task to assume sensors are unpowered in G3 and re-initialize sensors every time coming out of G3. Added EC command line test utils as well. Fixed some bug during unit tests. BUG=chrome-os-partner:27313,27320 BRANCH=ToT TEST=Verified on Samus. Tested with accel EC CLIs accelread, accelrange, accelrate, accelres Tested accelcalib, a ACCEL calibration util, and it succeeded. Tested sysfs interface: cd /sys/bus/iio/devices/iio:device1 cat in_accel_*_gyro_raw Signed-off-by: Sheng-Liang Song <ssl@chromium.org> Change-Id: I5752b00c03e1942c790ea4f28610fda83fa2dcbc Reviewed-on: https://chromium-review.googlesource.com/211484 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* Refactor accel / gyro driver to accomodate various configurationsShawn Nematbakhsh2014-08-191-35/+4
| | | | | | | | | | | | | | | | | | | Previously our accel / gyro drivers assumed that we had exactly two of each identical part in the system. Some systems may have different configurations, so allow this to be specified at the board-level. Note that our motion_sense algorithm currently assumes that we have one accelerometer in the lid and one in the base -- we'll need to fix that in another CL. BUG=chrome-os-partner:27320 TEST=Compile-only. Tested in future Samus commit. BRANCH=None. Change-Id: I1fae1f6c578fedebe78b473a5d66a5794ccaae00 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/212321 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* accel: add host command to modify accel params and add ectool commandAlec Berg2014-04-051-2/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Created a host command to set/get various motion sensor parameters and added an ectool command to use that host command. The host command is created such that the first argument is a sub-command. Sub-commands created include: dump: dumps all current motion sensor data info: returns general information about each motion sensor ec_rate: set/get the EC sampling rate of sensors sensor_range: set/get the sensor range (ie +/- 2G,4G,8G) sensor_odr: set/get the sensor output data rate (ie 50Hz, 100Hz, ...) For sensor_range and sensor_odr parameters, since the host doesn't know what are valid values for the parameter, the host can specify to round up or down to the nearest valid value. For example, the host can specify to set the output data rate to at least 100Hz, and the EC will return the closest valid output data rate that is at least 100Hz. BUG=chrome-os-partner:27321 BRANCH=rambi TEST=Test on a glimmer using ectool from vt-2 prompt: > ectool motionsense help Usage: motionsense - dump all motion data motionsense info NUM - print sensor info motionsense ec_rate [RATE_MS] - set/get sample rate motionsense odr NUM [ODR [ROUNDUP]] - set/get sensor ODR motionsense range NUM [RANGE [ROUNDUP]]- set/get sensor range > > ectool motionsense Sensor 0: 0, 0, 1024 Sensor 1: 1024, 0, 0 Sensor 2: None > ectool motionsense info 0 Type: accel Location: base Chip: kxcj9 > ectool motionsense ec_rate 10 > ectool motionsense ec_rate 1000 1000 > ectool motionsense odr 0 100000 > ectool motionsense odr 0 40000 1 50000 > ectool motionsense range 0 8 8 After running this I verified on the EC console that all the parameters were set appropriately. I tested the EC sampling rate was 1000ms by running lidangle on and making sure samples were displayed roughly every second. I verified the sensor odr and range by defining CONFIG_CMD_ACCELS and typing: > accelrange 0 8 > accelrate 0 50000 Change-Id: I444e2f0eafabd607f1c7aa78b5c4e91f6cb06387 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/192064 Reviewed-on: https://chromium-review.googlesource.com/193307 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Added unit tests for lid angle calculation and acosAlec Berg2014-02-221-0/+60
Added unit test for motion_sense lid angle calculations. Added unit test for math_util arc_cos() function. BUG=none Original-BUG=chrome-os-partner:25640 BRANCH=rambi TEST=make buildall Original-Change-Id: I35debf6fc0e2d9996debc2ede175acaa060df627 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/186720 Reviewed-by: Vic Yang <victoryang@chromium.org> (cherry picked from commit 55c3e8ee14693d6d667b5d21f0dcbb14d185ccbe) Change-Id: I017315128f318424cd3000affae785c69afd29d6 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/187434 Reviewed-by: Randall Spangler <rspangler@chromium.org>