Inertial navigation dev

From Bob's Basement

Jump to: navigation, search

Reason

This is here to log development inertial navigation

Wiimote Experiment

Today I bought a wiimote. As it turns out it's got a nice 3-axis accelerometer in it which is extremely handy to experiment with, as well as other fun sensors. I managed to get it working with GlovePIE (after downloading BlueSoleil bluetooth stack, as the MS one sucks basically). I wrote a really simple GlovePIE script which logs the output of the Z axis accelerometer at a sample rate of 400Hz.

wait 2.5ms
OutputToFile(RemoveUnits(Wiimote.RelAccZ))

This outputs the raw Z accelerometer data into a file called output.txt in the program's folder. Not that this is documented anywhere.

I threw the wiimote about a bit. The output looks something like this:

0.04
0.04
-0.04
-1.17
-0.01
0.01
0.01
-1.49
-1.87
-1.87
-3.38
-4.51
-3.75
-0.08
-0.05
-0.03
0.00

Then I wrote a simple perl script to work out the displacement.

#!/usr/bin/perl
# accel readings in ms^-2
# pitch and roll in degrees.
use warnings;
use strict;
my $sample_rate = 400;
my $delta_t = 1/$sample_rate;
my @z = ();
open(LOG,"z.txt");
while (<LOG>) {
	if (!/^#/) {
		chomp;
		push(@z,$_);
	}
}
my $abs_z = 0;
my $prev_zv = 0;
my $prev_za = 0;
foreach (@z) {
	my $delta_a = $_ + $prev_za;
	$prev_za = $_;
	my $rel_z = ($prev_zv*$delta_t)+0.5*$delta_a*$delta_t**2;
	$abs_z += $rel_z;
	$prev_zv = $rel_z / $delta_t;
	print $abs_z."\n";
}

Not the prettiest script ever written, but it does the job. I threw the output of this into a graphing program and had a look. Image:Accel_graph1.png Nice :)

I noticed that it wasn't all that accurate, as I didn't take into account tilt at all, so it thought it was falling through the floor. That's where the gyros will come into play - I think. Other than that, experiment went well :)

Personal tools