hi folks, i’m running an arduino ethernet with an polulu MinIMU-9 v2 (Gyro, Accelerometer, and Compass http://www.pololu.com/catalog/product/1268 and set it up with this example code https://github.com/pololu/MinIMU-9-Arduino-AHRS. Additional I’m using Z_OSC https://github.com/djiamnot/Z-OSCan arduino library to send and receive osc commands. I modified the OpenFrameworks receiveOSC example to get the data in but i have a small problem with the output:
I just try to translate this code which was written for serial output at the arduino:
Serial.print("!");
Serial.print("ANG:");
Serial.print(ToDeg(roll));
Serial.print(",");
Serial.print(ToDeg(pitch));
Serial.print(",");
Serial.print(ToDeg(yaw));
ToDeg was defined earlier:
#define ToDeg(x) ((x)*57.2957795131) // *180/pi
And at the serial monitor in Arduino i receive the following:
!ANG:0.15,0.13,66.71
!ANG:0.28,0.07,66.70
!ANG:0.31,0.11,66.71
!ANG:0.41,0.15,66.72
And exactly these numbers i want to have in open frameworks, so i have the following function in Arduino
void sendProcess(){
Z_OSCMessage message;
message.setAddress(destIp,destPort);
message.setZ_OSCMessage(oscAdr1,"fff",ToDeg(roll),ToDeg(pitch),ToDeg(yaw));
client.send(&message);
}
fff stands for three float numbers, and i double checked that roll, pitch and yaw were also declared as floats.
I start it right after the original printdata() function:
...
...
...
// Calculations...
Matrix_update();
Normalize();
Drift_correction();
Euler_angles();
// ***
printdata();
sendProcess();
}
in open frameworks i read them out as floats:
void testApp::update(){
// hide old messages
for(int i = 0; i < NUM_MSG_STRINGS; i++){
if(timers[i] < ofGetElapsedTimef()){
msg_strings[i] = "";
}
}
// check for waiting messages
while(receiver.hasWaitingMessages()){
// get the next message
ofxOscMessage m;
receiver.getNextMessage(&m);
if(m.getAddress() == "/head/direction"){
roll= m.getArgAsFloat(0);
pitch= m.getArgAsFloat(1);
yaw= m.getArgAsFloat(2);
}
}
}
now when i print them i get something like that:
-1.3445464e+44
or 0
or
-3.456553e-23
i don’t move the arduino board.
How do i get the right numbers?
Does it have something to do with the clock of the devices?
the serial monitor at the arduino software runs with 115200 baud how could i translate that into the osc open frameworks application?
Hope you can help me,
Happy Christmas, Nixon