Experimental (and ultimately ineffective) fiddling with axes
This commit is contained in:
parent
dabaaece7d
commit
8ee5e0bf55
2 changed files with 85 additions and 4 deletions
59
imuread.c
59
imuread.c
|
|
@ -21,8 +21,67 @@ static void glut_display_callback(void)
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern int invert_q0;
|
||||||
|
extern int invert_q1;
|
||||||
|
extern int invert_q2;
|
||||||
|
extern int invert_q3;
|
||||||
|
extern int invert_x;
|
||||||
|
extern int invert_y;
|
||||||
|
extern int invert_z;
|
||||||
|
|
||||||
|
static void print_invert_state(void)
|
||||||
|
{
|
||||||
|
printf("Invert: %s %s %s %s %s %s %s\n",
|
||||||
|
(invert_q0 ? "Q0" : " "),
|
||||||
|
(invert_q1 ? "Q1" : " "),
|
||||||
|
(invert_q2 ? "Q2" : " "),
|
||||||
|
(invert_q3 ? "Q3" : " "),
|
||||||
|
(invert_x ? "x'" : " "),
|
||||||
|
(invert_y ? "y'" : " "),
|
||||||
|
(invert_z ? "z'" : " ")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void glut_keystroke_callback(unsigned char ch, int x, int y)
|
static void glut_keystroke_callback(unsigned char ch, int x, int y)
|
||||||
{
|
{
|
||||||
|
if (ch == '0') {
|
||||||
|
invert_q0 ^= 1;
|
||||||
|
print_invert_state();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ch == '1') {
|
||||||
|
invert_q1 ^= 1;
|
||||||
|
print_invert_state();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ch == '2') {
|
||||||
|
invert_q2 ^= 1;
|
||||||
|
print_invert_state();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ch == '3') {
|
||||||
|
invert_q3 ^= 1;
|
||||||
|
print_invert_state();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ch == 'x') {
|
||||||
|
invert_x ^= 1;
|
||||||
|
print_invert_state();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ch == 'y') {
|
||||||
|
invert_y ^= 1;
|
||||||
|
print_invert_state();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ch == 'z') {
|
||||||
|
invert_z ^= 1;
|
||||||
|
print_invert_state();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (magcal.FitError > 9.0) {
|
if (magcal.FitError > 9.0) {
|
||||||
printf("Poor Calibration: ");
|
printf("Poor Calibration: ");
|
||||||
printf("soft iron fit error = %.1f%%\n", magcal.FitError);
|
printf("soft iron fit error = %.1f%%\n", magcal.FitError);
|
||||||
|
|
|
||||||
30
visualize.c
30
visualize.c
|
|
@ -46,6 +46,14 @@ static void rotate(const Point_t *in, Point_t *out, const float *rmatrix)
|
||||||
static GLuint spherelist;
|
static GLuint spherelist;
|
||||||
static GLuint spherelowreslist;
|
static GLuint spherelowreslist;
|
||||||
|
|
||||||
|
int invert_q0=0;
|
||||||
|
int invert_q1=0;
|
||||||
|
int invert_q2=0;
|
||||||
|
int invert_q3=1;
|
||||||
|
int invert_x=0;
|
||||||
|
int invert_y=0;
|
||||||
|
int invert_z=0;
|
||||||
|
|
||||||
void display_callback(void)
|
void display_callback(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -76,11 +84,22 @@ void display_callback(void)
|
||||||
memcpy(&orientation, ¤t_orientation, sizeof(orientation));
|
memcpy(&orientation, ¤t_orientation, sizeof(orientation));
|
||||||
// TODO: this almost but doesn't perfectly seems to get the
|
// TODO: this almost but doesn't perfectly seems to get the
|
||||||
// real & screen axes in sync....
|
// real & screen axes in sync....
|
||||||
//orientation.q0 *= -1.0f;
|
if (invert_q0) orientation.q0 *= -1.0f;
|
||||||
//orientation.q1 *= -1.0f;
|
if (invert_q1) orientation.q1 *= -1.0f;
|
||||||
//orientation.q2 *= -1.0f;
|
if (invert_q2) orientation.q2 *= -1.0f;
|
||||||
orientation.q3 *= -1.0f;
|
if (invert_q3) orientation.q3 *= -1.0f;
|
||||||
quad_to_rotation(&orientation, rotation);
|
quad_to_rotation(&orientation, rotation);
|
||||||
|
|
||||||
|
//rotation[0] *= -1.0f;
|
||||||
|
//rotation[1] *= -1.0f;
|
||||||
|
//rotation[2] *= -1.0f;
|
||||||
|
//rotation[3] *= -1.0f;
|
||||||
|
//rotation[4] *= -1.0f;
|
||||||
|
//rotation[5] *= -1.0f;
|
||||||
|
//rotation[6] *= -1.0f;
|
||||||
|
//rotation[7] *= -1.0f;
|
||||||
|
//rotation[8] *= -1.0f;
|
||||||
|
|
||||||
for (i=0; i < MAGBUFFSIZE; i++) {
|
for (i=0; i < MAGBUFFSIZE; i++) {
|
||||||
if (magcal.valid[i]) {
|
if (magcal.valid[i]) {
|
||||||
apply_calibration(magcal.BpFast[0][i], magcal.BpFast[1][i],
|
apply_calibration(magcal.BpFast[0][i], magcal.BpFast[1][i],
|
||||||
|
|
@ -91,6 +110,9 @@ void display_callback(void)
|
||||||
quality_update(&point);
|
quality_update(&point);
|
||||||
rotate(&point, &draw, rotation);
|
rotate(&point, &draw, rotation);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
if (invert_x) draw.x *= -1.0f;
|
||||||
|
if (invert_y) draw.y *= -1.0f;
|
||||||
|
if (invert_z) draw.z *= -1.0f;
|
||||||
glTranslatef(
|
glTranslatef(
|
||||||
draw.x * xscale + xoff,
|
draw.x * xscale + xoff,
|
||||||
draw.z * yscale + yoff,
|
draw.z * yscale + yoff,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue