First of all sorry for my English
I'm trying to build a simple arduino based head-tracker, basicly following this:
https://www.youtube.com/watch?v=QpO1Wty3F3I
https://github.com/mdjarv/arduinoheadtracker
And must be something I'm doing terribly bad, i think
I can see values like "1.23,14.39,-3.38" at the serial monitor (arduino IDE) changing very fast.
And if I move the sensor, these values change.
But when I run freepie code... nothing happens.
Values at "Watch" are not changing at all.
All of them (yaw, pitch, roll, trackIR.yaw, ...) are always "0".
I checked Settings > Plugins > Free IMU and select COM port and baud rate.
Freepie code I use is:
Code: Select all
### CONFIGURATION ###
# Watch input and output values
DEBUG = True
# Output mode
OUTPUT_FREETRACK = False
OUTPUT_TRACKIR = True
# Keybindings
KEY_CENTER = Key.Pause # Center orientation to current position
KEY_TOGGLE_ON_OFF = Key.End # Toggle headtracking on or off
# Calibration multipliers
TRACKIR_MULTIPLIER = 10
FREETRACK_MULTIPLIER = 0.001
### THE CODE ###
def update():
global yaw
yaw = freeImu.yaw
global pitch
pitch = freeImu.pitch
global roll
roll = freeImu.roll
def updateTrackIR():
trackIR.yaw = (yaw - centerYaw) * TRACKIR_MULTIPLIER
trackIR.pitch = (pitch - centerPitch) * TRACKIR_MULTIPLIER
trackIR.roll = (roll - centerRoll) * TRACKIR_MULTIPLIER
if DEBUG:
diagnostics.watch(trackIR.yaw)
diagnostics.watch(trackIR.pitch)
diagnostics.watch(trackIR.roll)
def updateFreeTrack():
freeTrack.yaw = (yaw - centerYaw) * -FREETRACK_MULTIPLIER # Inverted
freeTrack.pitch = (pitch - centerPitch) * FREETRACK_MULTIPLIER
freeTrack.roll = (roll - centerRoll) * FREETRACK_MULTIPLIER
if DEBUG:
diagnostics.watch(freeTrack.yaw)
diagnostics.watch(freeTrack.pitch)
diagnostics.watch(freeTrack.roll)
def center():
global centerYaw
centerYaw = yaw
global centerPitch
centerPitch = pitch
global centerRoll
centerRoll = roll
if starting:
enabled = True
centerYaw = freeImu.yaw
centerPitch = freeImu.pitch
centerRoll = freeImu.roll
global yaw
yaw = 0.0
global pitch
pitch = 0.0
global roll
roll = 0.0
freeImu.update += update
def do_update():
if OUTPUT_FREETRACK:
updateFreeTrack()
if OUTPUT_TRACKIR:
updateTrackIR()
if DEBUG:
diagnostics.watch(yaw)
diagnostics.watch(pitch)
diagnostics.watch(roll)
if enabled:
do_update()
if keyboard.getKeyDown(KEY_CENTER):
center()
if keyboard.getPressed(KEY_TOGGLE_ON_OFF):
enabled = not enabled
center()
do_update()
Code: Select all
#include <ADXL345.h>
#include <bma180.h>
#include <HMC58X3.h>
#include <ITG3200.h>
#include <MS561101BA.h>
#include <I2Cdev.h>
#include <MPU60X0.h>
#include <EEPROM.h>
//#define DEBUG
#include "DebugUtils.h"
#include "CommunicationUtils.h"
#include "FreeIMU.h"
#include <Wire.h>
#include <SPI.h>
float ypr[3]; // yaw pitch roll
// Set the FreeIMU object
FreeIMU my3IMU = FreeIMU();
void setup() {
Serial.begin(115200);
Wire.begin();
delay(5);
my3IMU.init(); // the parameter enable or disable fast mode
delay(5);
}
void loop() {
my3IMU.getYawPitchRoll(ypr);
Serial.print(ypr[0]);
Serial.print(",");
Serial.print(ypr[1]);
Serial.print(",");
Serial.println(ypr[2]);
delay(10);
}
So, please, can anyone help me?
I'm completely lost
Regards!