import java.io.*;
public class AltosIMU implements Cloneable {
- public int accel_x = AltosLib.MISSING;
- public int accel_y = AltosLib.MISSING;
- public int accel_z = AltosLib.MISSING;
+ private int accel_x = AltosLib.MISSING;
+ private int accel_y = AltosLib.MISSING;
+ private int accel_z = AltosLib.MISSING;
- public int accel_along = AltosLib.MISSING;
- public int accel_across = AltosLib.MISSING;
- public int accel_through = AltosLib.MISSING;
+ private int accel_along = AltosLib.MISSING;
+ private int accel_across = AltosLib.MISSING;
+ private int accel_through = AltosLib.MISSING;
- public int gyro_x = AltosLib.MISSING;
- public int gyro_y = AltosLib.MISSING;
- public int gyro_z = AltosLib.MISSING;
+ private int gyro_x = AltosLib.MISSING;
+ private int gyro_y = AltosLib.MISSING;
+ private int gyro_z = AltosLib.MISSING;
- public int gyro_roll = AltosLib.MISSING;
- public int gyro_pitch = AltosLib.MISSING;
- public int gyro_yaw = AltosLib.MISSING;
+ private int gyro_roll = AltosLib.MISSING;
+ private int gyro_pitch = AltosLib.MISSING;
+ private int gyro_yaw = AltosLib.MISSING;
- public int mag_x = AltosLib.MISSING;
- public int mag_y = AltosLib.MISSING;
- public int mag_z = AltosLib.MISSING;
+ private int mag_x = AltosLib.MISSING;
+ private int mag_y = AltosLib.MISSING;
+ private int mag_z = AltosLib.MISSING;
- public int mag_along = AltosLib.MISSING;
- public int mag_across = AltosLib.MISSING;
- public int mag_through = AltosLib.MISSING;
+ private int mag_along = AltosLib.MISSING;
+ private int mag_across = AltosLib.MISSING;
+ private int mag_through = AltosLib.MISSING;
- public int imu_model = AltosLib.MISSING;
- public int mag_model = AltosLib.MISSING;
+ private int imu_model = AltosLib.MISSING;
+ private int mag_model = AltosLib.MISSING;
- public static final double counts_per_g_mpu = 2048.0;
- public static final double counts_per_g_bmx = 2048.0;
- public static final double counts_per_g_adxl = 20.5;
- public static final double counts_per_g_bmi088 = 1365.0;
+ private static final double counts_per_g_mpu = 2048.0;
+ private static final double counts_per_g_bmx = 2048.0;
+ private static final double counts_per_g_adxl = 20.5;
+ private static final double counts_per_g_bmi088 = 1365.0;
private static double counts_per_g(int imu_type, int imu_model) {
switch (imu_model) {
return counts / cpg * AltosConvert.gravity;
}
- public static final double GYRO_FULLSCALE_DEGREES_MPU = 2000.0;
- public static final double GYRO_COUNTS_MPU = 32767.0;
- public static final double counts_per_degree_mpu = GYRO_COUNTS_MPU / GYRO_FULLSCALE_DEGREES_MPU;
- public static final double GYRO_FULLSCALE_DEGREES_BMX = 2000.0;
- public static final double GYRO_COUNTS_BMX = 32767.0;
- public static final double counts_per_degree_bmx = GYRO_COUNTS_BMX / GYRO_FULLSCALE_DEGREES_BMX;
- public static final double counts_per_degree_bmi088 = 16.384;
+ private static final double GYRO_FULLSCALE_DEGREES_MPU = 2000.0;
+ private static final double GYRO_COUNTS_MPU = 32767.0;
+ private static final double counts_per_degree_mpu = GYRO_COUNTS_MPU / GYRO_FULLSCALE_DEGREES_MPU;
+ private static final double GYRO_FULLSCALE_DEGREES_BMX = 2000.0;
+ private static final double GYRO_COUNTS_BMX = 32767.0;
+ private static final double counts_per_degree_bmx = GYRO_COUNTS_BMX / GYRO_FULLSCALE_DEGREES_BMX;
+ private static final double counts_per_degree_bmi088 = 16.384;
private static double counts_per_degree(int imu_type, int imu_model) {
switch (imu_model) {
return counts / cpd;
}
- 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;
+ private static final double MAG_FULLSCALE_GAUSS_MPU = 48.00; /* 4800µT */
+ private static final double MAG_COUNTS_MPU = 32767.0;
+ private static final double counts_per_gauss_mpu = MAG_COUNTS_MPU / MAG_FULLSCALE_GAUSS_MPU;
- public static final double counts_per_gauss_bmx = 100.0; /* BMX driver converts to µT */
+ private static final double counts_per_gauss_bmx = 100.0; /* BMX driver converts to µT */
public static double counts_per_gauss(int imu_type, int imu_model) {
switch (imu_model) {
return AltosLib.MISSING;
}
- public boolean parse_string(String line) {
+ private boolean parse_string(String line) {
if (line.startsWith("Accel:")) {
String[] items = line.split("\\s+");
/*
+ * Here are the required sensor signs:
*
- * If the board is laying component side up with
- * the antenna (nose) pointing north
+ * +along nose up
+ * +across USB down
+ * +through TH down
*
- * +along north +roll left up
- * +across west +pitch nose down
- * +through up +yaw left turn
+ * With the board aligned to have positive accel for the relevant
+ * axis, looking down from above we have:
+ *
+ * +roll counter clockwise (nose up)
+ * +pitch counter clockwise (USB down)
+ * +yaw counter clockwise (TH down)
*/
/*
- * mpu6000
- *
- * pin 1 NW corner of chip
+ * On TMega v5, MPU6000 pin 1 (NW corner of chip) is placed towards
+ * the USB and antenna edges of the board. Relative to MPU6000 specs,
+ * we don't need to change any signs and so the correct values are:
*
* +along +Y +roll +Y
- * +across -X +pitch -X
+ * +across +X +pitch +X
* +through +Z +yaw +Z
*
*/
#define HAS_IMU 1
#define ao_mpu6000_along(m) ((m)->accel_y)
-#define ao_mpu6000_across(m) (-(m)->accel_x)
+#define ao_mpu6000_across(m) ((m)->accel_x)
#define ao_mpu6000_through(m) ((m)->accel_z)
#define ao_mpu6000_roll(m) ((m)->gyro_y)
-#define ao_mpu6000_pitch(m) (-(m)->gyro_x)
+#define ao_mpu6000_pitch(m) ((m)->gyro_x)
#define ao_mpu6000_yaw(m) ((m)->gyro_z)
#define ao_data_along(packet) ao_mpu6000_along(&(packet)->mpu6000)
/*
*
- * If the board is laying component side up with
- * the antenna (nose) pointing north
+ * Here are the required sensor signs:
*
- * +along north +roll left up
- * +across west +pitch nose down
- * +through up +yaw left turn
+ * +along nose up
+ * +across USB down
+ * +through TH down
+ *
+ * With the board aligned to have positive accel for the relevant
+ * axis, looking down from above we have:
+ *
+ * +roll counter clockwise (nose up)
+ * +pitch counter clockwise (USB down)
+ * +yaw counter clockwise (TH down)
*/
/*
- * bmi088
- *
- * pin 1 NE corner of chip
+ * On TMega v6, bmi088 pin 1 (NE corner of chip) is placed towards the
+ * USB and antenna edges of the board. Relative to bmi088 specs, to
+ * get the above values, we need to flip the Y axis, assigning values
+ * as follows:
*
* +along +X +roll +X
* +across -Y +pitch -Y
#define HAS_IMU 1
#define ao_bmi088_along(m) ((m)->acc.x)
-#define ao_bmi088_across(m) ((m)->acc.y)
+#define ao_bmi088_across(m) (-(m)->acc.y)
#define ao_bmi088_through(m) ((m)->acc.z)
#define ao_bmi088_roll(m) ((m)->gyr.x)
-#define ao_bmi088_pitch(m) ((m)->gyr.y)
+#define ao_bmi088_pitch(m) (-(m)->gyr.y)
#define ao_bmi088_yaw(m) ((m)->gyr.z)
#define ao_data_along(packet) ao_bmi088_along(&(packet)->bmi088)