Skip to content

Commit 08ddcdc

Browse files
committed
Update SensorLSM6DSV.java
1 parent 2d66609 commit 08ddcdc

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

ShimmerDriver/src/main/java/com/shimmerresearch/verisense/sensors/SensorLSM6DSV.java

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.shimmerresearch.driverUtilities.ChannelDetails.CHANNEL_TYPE;
2929
import com.shimmerresearch.sensors.AbstractSensor;
3030
import com.shimmerresearch.sensors.ActionSetting;
31+
import com.shimmerresearch.sensors.lisxmdl.SensorLIS2MDL;
3132

3233
/**
3334
* Second-generation Verisense IMU: LSM6DSV (accelerometer + gyroscope) with the
@@ -38,10 +39,16 @@
3839
* tagged FIFO ([TAG_CNT][X][Y][Z]) interleaving the three streams; the byte-level
3940
* extraction + per-stream timestamping lives in
4041
* {@code VerisenseDevice.parseDataBlockDataLsm6dsv(...)}. This class provides the
41-
* channel definitions, configuration and calibration. Calibration matches the
42-
* firmware/SDK nominal model: value = raw / sensitivity (identity alignment,
43-
* zero offset) where sensitivity = 32768/(FS*9.80665) for accel, 32768/FS for
44-
* gyro and 1/0.15 for mag.
42+
* channel definitions, configuration and calibration.
43+
* <p>
44+
* Sensitivities: 32768/(FS*9.80665) LSB per m/s^2 for accel, the ST angular-rate
45+
* spec of 4.375 mdps/LSB at +-125 dps for gyro, and 667 LSB/Gauss for the LIS2MDL
46+
* mag - the last taken from {@link SensorLIS2MDL} rather than duplicated here, so
47+
* calibrated magnetometer output is in GAUSS, consistent with every other Shimmer
48+
* magnetometer and with the per-unit calibration the device stores.
49+
* <p>
50+
* Alignment is left as identity here and corrected by the file parser per hardware
51+
* revision; offsets are zero.
4552
*
4653
* @author Mark Nolan
4754
*/
@@ -230,8 +237,10 @@ public static final class DatabaseConfigHandle {
230237
CompatibilityInfoForMaps.listOfCompatibleVersionInfoLSM6DSV);
231238

232239
// ----------------- Calibration Start -----------------------
233-
// Identity alignment + zero offset so calibrated = raw / sensitivity, matching
234-
// the firmware/SDK nominal model (and the validated standalone decoder).
240+
// Identity alignment is a placeholder, NOT the real sensor->ASM map: the file
241+
// parser overrides it per hardware revision at parse time (see
242+
// CalibrationFileManager.applyGen2DefaultAlignment in the VerisenseDriver repo).
243+
// Correcting it here as well would give two sources of truth for the same values.
235244
public static final double[][] DEFAULT_OFFSET_VECTOR_LSM6DSV = {{0},{0},{0}};
236245
public static final double[][] DEFAULT_ALIGNMENT_MATRIX_LSM6DSV = {{1,0,0},{0,1,0},{0,0,1}};
237246

@@ -251,8 +260,17 @@ public static final class DatabaseConfigHandle {
251260
public static final double[][] SENS_GYRO_1000DPS = {{28.571428571,0,0},{0,28.571428571,0},{0,0,28.571428571}};
252261
public static final double[][] SENS_GYRO_2000DPS = {{14.285714286,0,0},{0,14.285714286,0},{0,0,14.285714286}};
253262

254-
// Mag sensitivity (LSB per uT) = 1/0.15
255-
public static final double[][] SENS_MAG = {{6.666667,0,0},{0,6.666667,0},{0,0,6.666667}};
263+
// Mag sensitivity: taken from the LIS2MDL's own sensor class rather than
264+
// re-declared here, because it is a property of the chip (1.5 mGauss/LSB) and not
265+
// of the LSM6DSV sensor hub the samples arrive through. 667 LSB/Gauss, matching
266+
// the firmware calibration seed (SC_LIS2MDL_MAG_SENS), the web SDK catalog, and
267+
// every other Shimmer magnetometer (LSM303DLHC etc. are all LSB/Gauss).
268+
//
269+
// This was previously a local copy of 6.666667 = 1/0.15 LSB/uT, which made
270+
// gen-2 magnetometer output 100x larger than every other Shimmer device for the
271+
// same field, and 100x out of step with the per-unit calibration the device
272+
// stores. Reference the shared constant so the two cannot diverge again.
273+
public static final double[][] SENS_MAG = SensorLIS2MDL.DefaultSensitivityMatrixMagShimmer3r;
256274

257275
public CalibDetailsKinematic calibDetailsAccel2g = new CalibDetailsKinematic(
258276
LSM6DSV_ACCEL_RANGE.RANGE_2G.configValue, LSM6DSV_ACCEL_RANGE.RANGE_2G.label,

0 commit comments

Comments
 (0)