summaryrefslogtreecommitdiff
path: root/src/core/ao_sample.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-10-25 04:34:16 -0700
committerKeith Packard <keithp@keithp.com>2013-10-25 04:34:16 -0700
commit351d53836e201834a2d89773a08ab7c2dab2b2f4 (patch)
tree599b180bc18e690496091dd335d8fa7731400b86 /src/core/ao_sample.c
parent08143a922fe27bc50a19924f46538f9476ab5fd1 (diff)
altos: Calibrate IMU accelerometers too
Average the IMU accelerometer values pointing up and down so that we have a zero-g offset for all three axes. This can then be used to compute which direction the rocket is pointing while sitting on the pad. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/core/ao_sample.c')
-rw-r--r--src/core/ao_sample.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/core/ao_sample.c b/src/core/ao_sample.c
index 676e0ffd..a9d50cb2 100644
--- a/src/core/ao_sample.c
+++ b/src/core/ao_sample.c
@@ -139,19 +139,16 @@ ao_sample_preflight_set(void)
/* No rotation yet */
ao_quaternion_init_zero_rotation(&ao_rotation);
- /* XXX Assume we're pointing straight up for now */
+ /* Take the pad IMU acceleration values and compute our current direction
+ */
ao_quaternion_init_vector(&ao_pad_orientation,
- ao_ground_accel_across,
- ao_ground_accel_through,
- -ao_ground_accel_along);
+ ao_ground_accel_across - ao_config.accel_zero_across,
+ ao_ground_accel_through - ao_config.accel_zero_through,
+ -ao_ground_accel_along - ao_config.accel_zero_along);
+
ao_quaternion_normalize(&ao_pad_orientation,
&ao_pad_orientation);
- printf ("pad r%8.5f x%8.5f y%8.5f z%8.5f\n",
- ao_pad_orientation.r,
- ao_pad_orientation.x,
- ao_pad_orientation.y,
- ao_pad_orientation.z);
#endif
nsamples = 0;
}