+ public static double gyro_degrees_per_second(double counts, int imu_type) {
+ return counts / counts_per_degree(imu_type);
+ }
+
+ public static final int imu_axis_x = 0;
+ public static final int imu_axis_y = 1;
+ public static final int imu_axis_z = 2;
+
+ public static final double MAG_FULLSCALE_GAUSS_MPU = 48.00; /* 4800µT */
+ public static final double MAG_COUNTS_MPU = 32767.0;
+ public static final double counts_per_gauss_mpu = MAG_COUNTS_MPU / MAG_FULLSCALE_GAUSS_MPU;
+
+ public static final double MAG_FULLSCALE_GAUSS_BMX_XY = 11.50; /* 1150µT */
+ public static final double MAG_FULLSCALE_GAUSS_BMX_Z = 25.00; /* 2500µT */
+ public static final double MAG_COUNTS_BMX = 32767.0;
+ public static final double counts_per_gauss_bmx_xy = MAG_COUNTS_BMX / MAG_FULLSCALE_GAUSS_BMX_XY;
+ public static final double counts_per_gauss_bmx_z = MAG_COUNTS_BMX / MAG_FULLSCALE_GAUSS_BMX_Z;
+
+ public static double counts_per_gauss(int imu_type, int axis) {
+ switch(imu_type) {
+ case imu_type_telemega_v1_v2:
+ case imu_type_easymega_v1:
+ return AltosMag.counts_per_gauss;
+ case imu_type_telemega_v3:
+ case imu_type_easymega_v2:
+ return counts_per_gauss_mpu;
+ case imu_type_telemega_v4:
+ switch (axis) {
+ case imu_axis_x:
+ case imu_axis_y:
+ return counts_per_gauss_bmx_xy;
+ case imu_axis_z:
+ return counts_per_gauss_bmx_z;
+ }
+ /* fall through */
+ default:
+ return AltosLib.MISSING;
+ }
+ }
+
+ public static double convert_gauss(double counts, int imu_type, int imu_axis) {
+ return counts / counts_per_gauss(imu_type, imu_axis);