Stable Orientation – Digital IMU 6DOF + Arduino

Discussions area for bildr's blog posts.
The raw values are useless if you want orientation.
A gyroscope actually does exactly that, it tells you the rate of rotation. It doesn't know your orientation.

In combination with the accelerometer and a ton of math you can get the orientation. That is actually exactly what this whole sensor thing is meant to do.

Run the sixDOF_Example.ino code to get your orientation.

ojosdepajaro2 wrote:Hello again. Thanks for the answer!

So I got the raw acceleration and angle data (code below). Or so I thought.
Making some tests with Max MSP, I realised that I wasn't getting a rotation angle (like 0-360). According to the library, "gyro values are expressed in deg/sec, the * M_PI/180 will convert it to radians/sec", so my angle values change according to the speed that I use to turn my gyro.... :roll:

I confess that I'm clueless. All I want is to know what's the angle (0-360), but I don't know how to use this data. I've tried this http://www.teacherschoice.com.au/maths_library/angles/angles.htm radians to degrees conversion, but It's not what I need, since I need to convert radians per second to degrees.

Any math master that could help me solving this issue?
Thanks once again,

Code: Select all
#include <FreeSixIMU.h>
#include <FIMU_ADXL345.h>
#include <FIMU_ITG3200.h>
#include <Wire.h>

float angles[3]; // yaw pitch roll
float values [3];
float raw_values[5]


// Set the FreeSixIMU object
FreeSixIMU sixDOF = FreeSixIMU();

void setup() {
  Serial.begin(9600);
  Wire.begin();
  delay(5);
  sixDOF.init(); //begin the IMU

}

void loop() {
  sixDOF.getEuler(angles);
  sixDOF.getValues(values);
  sixDOF.getRawValues
  /*
  Serial.print(angles[0]);
  Serial.print(" | "); 
  Serial.print(angles[1]);
  Serial.print(" | ");
  Serial.println(angles[2]);*/

//ANGULOS
  Serial.print(angles[0]);
  Serial.print(" ");
  Serial.print(angles[1]);
  Serial.print(" ");
  Serial.print(angles[2]); 
  Serial.print(" ");

//GYROSCOPE
  Serial.print(values[0]);
  Serial.print(" ");
  Serial.print(values[1]);
  Serial.print(" ");
  Serial.println(values[2]);
  Serial.println(raw_values[0]);
  Serial.println(



  delay(100);
}
ameyer
Founder
 
Posts: 3312
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Hey, ameyer. Thanks for your answer but it is actually the sixDOF_Example.ino that I'm using. Once again, I can only get radians/sec. My question was, precisely, to try to figure out how to get that "ton of math" done, precisely because "this is exactly what this whole sensor thing is meant to do". I imagine that measuring the time that i put in a movement would be a good start, but I actually would need this information beforehand... wouldn't I?

So if anyone can point out to some clue on how to figure out the orientation, it would be really nice.

Thanks,


ameyer wrote:The raw values are useless if you want orientation.
A gyroscope actually does exactly that, it tells you the rate of rotation. It doesn't know your orientation.

In combination with the accelerometer and a ton of math you can get the orientation. That is actually exactly what this whole sensor thing is meant to do.

Run the sixDOF_Example.ino code to get your orientation.

ojosdepajaro2 wrote:Hello again. Thanks for the answer!

So I got the raw acceleration and angle data (code below). Or so I thought.
Making some tests with Max MSP, I realised that I wasn't getting a rotation angle (like 0-360). According to the library, "gyro values are expressed in deg/sec, the * M_PI/180 will convert it to radians/sec", so my angle values change according to the speed that I use to turn my gyro.... :roll:

I confess that I'm clueless. All I want is to know what's the angle (0-360), but I don't know how to use this data. I've tried this http://www.teacherschoice.com.au/maths_library/angles/angles.htm radians to degrees conversion, but It's not what I need, since I need to convert radians per second to degrees.

Any math master that could help me solving this issue?
Thanks once again,

Code: Select all
#include <FreeSixIMU.h>
#include <FIMU_ADXL345.h>
#include <FIMU_ITG3200.h>
#include <Wire.h>

float angles[3]; // yaw pitch roll
float values [3];
float raw_values[5]


// Set the FreeSixIMU object
FreeSixIMU sixDOF = FreeSixIMU();

void setup() {
  Serial.begin(9600);
  Wire.begin();
  delay(5);
  sixDOF.init(); //begin the IMU

}

void loop() {
  sixDOF.getEuler(angles);
  sixDOF.getValues(values);
  sixDOF.getRawValues
  /*
  Serial.print(angles[0]);
  Serial.print(" | "); 
  Serial.print(angles[1]);
  Serial.print(" | ");
  Serial.println(angles[2]);*/

//ANGULOS
  Serial.print(angles[0]);
  Serial.print(" ");
  Serial.print(angles[1]);
  Serial.print(" ");
  Serial.print(angles[2]); 
  Serial.print(" ");

//GYROSCOPE
  Serial.print(values[0]);
  Serial.print(" ");
  Serial.print(values[1]);
  Serial.print(" ");
  Serial.println(values[2]);
  Serial.println(raw_values[0]);
  Serial.println(



  delay(100);
}
ojosdepajaro2
 
Posts: 4
Joined: Fri Apr 15, 2016 2:45 am

Load the sixDOF_Example.ino - Completely unmodified in any way. It will not give you radians/s or anything like that.

sixDOF_Example.ino is the example that has all the math done for you. It will print out the orientation in Euler angles.

The loop should look exactly like this - If it is different then it got modified and you should download it again.

Code: Select all

void loop() {
 
 sixDOF.getEuler(angles);
 
 Serial.print(angles[0]);
 Serial.print(" | ");
 Serial.print(angles[1]);
 Serial.print(" | ");
 Serial.println(angles[2]);
 
 delay(100);
}




ojosdepajaro2 wrote:Hey, ameyer. Thanks for your answer but it is actually the sixDOF_Example.ino that I'm using. Once again, I can only get radians/sec. My question was, precisely, to try to figure out how to get that "ton of math" done, precisely because "this is exactly what this whole sensor thing is meant to do". I imagine that measuring the time that i put in a movement would be a good start, but I actually would need this information beforehand... wouldn't I?

So if anyone can point out to some clue on how to figure out the orientation, it would be really nice.

Thanks,


ameyer wrote:The raw values are useless if you want orientation.
A gyroscope actually does exactly that, it tells you the rate of rotation. It doesn't know your orientation.

In combination with the accelerometer and a ton of math you can get the orientation. That is actually exactly what this whole sensor thing is meant to do.

Run the sixDOF_Example.ino code to get your orientation.

ojosdepajaro2 wrote:Hello again. Thanks for the answer!

So I got the raw acceleration and angle data (code below). Or so I thought.
Making some tests with Max MSP, I realised that I wasn't getting a rotation angle (like 0-360). According to the library, "gyro values are expressed in deg/sec, the * M_PI/180 will convert it to radians/sec", so my angle values change according to the speed that I use to turn my gyro.... :roll:

I confess that I'm clueless. All I want is to know what's the angle (0-360), but I don't know how to use this data. I've tried this http://www.teacherschoice.com.au/maths_library/angles/angles.htm radians to degrees conversion, but It's not what I need, since I need to convert radians per second to degrees.

Any math master that could help me solving this issue?
Thanks once again,

Code: Select all
#include <FreeSixIMU.h>
#include <FIMU_ADXL345.h>
#include <FIMU_ITG3200.h>
#include <Wire.h>

float angles[3]; // yaw pitch roll
float values [3];
float raw_values[5]


// Set the FreeSixIMU object
FreeSixIMU sixDOF = FreeSixIMU();

void setup() {
  Serial.begin(9600);
  Wire.begin();
  delay(5);
  sixDOF.init(); //begin the IMU

}

void loop() {
  sixDOF.getEuler(angles);
  sixDOF.getValues(values);
  sixDOF.getRawValues
  /*
  Serial.print(angles[0]);
  Serial.print(" | "); 
  Serial.print(angles[1]);
  Serial.print(" | ");
  Serial.println(angles[2]);*/

//ANGULOS
  Serial.print(angles[0]);
  Serial.print(" ");
  Serial.print(angles[1]);
  Serial.print(" ");
  Serial.print(angles[2]); 
  Serial.print(" ");

//GYROSCOPE
  Serial.print(values[0]);
  Serial.print(" ");
  Serial.print(values[1]);
  Serial.print(" ");
  Serial.println(values[2]);
  Serial.println(raw_values[0]);
  Serial.println(



  delay(100);
}
ameyer
Founder
 
Posts: 3312
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Thanks a lot ameyer!
Since it improved when reloading the program with no acceleration reading... I think the problem was that somehow the data was reversed and I was reading it in the opposite order. Still, not quite there yet, but in a much better place.
Best!
ojosdepajaro2
 
Posts: 4
Joined: Fri Apr 15, 2016 2:45 am

All the data coming out is in euler angles, so it can be a little daunting to understand at first: https://en.wikipedia.org/wiki/Euler_angles

What does the output look like? And what do you need it to look like?




ojosdepajaro2 wrote:Thanks a lot ameyer!
Since it improved when reloading the program with no acceleration reading... I think the problem was that somehow the data was reversed and I was reading it in the opposite order. Still, not quite there yet, but in a much better place.
Best!
ameyer
Founder
 
Posts: 3312
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Hello,

I obtain values like that from my arduino
6D429F3D,ADBE23BF,6CBC41BF,0F77BFBD,
7E029F3D,6FC623BF,12B741BF,3F5EBFBD,
E9CF9E3D,16CC23BF,14B341BF,0755BFBD,
91D39E3D,40D423BF,B5AC41BF,862FBFBD,

I change the port to COM3 (where the arduino is working) but muy cube is freeze and the angles don't change. It seems like it cann't read the values.
ciclen
 
Posts: 1
Joined: Sat Apr 30, 2016 5:40 pm

Those values are perfectly correct if you are running FreeSix_cube.ino - This is meant to talk to the processing.org program also included (FreeSix_cube.pde) - It compresses the data to reduce the amount of characters it needs to send over (thus reducing the latency)

Load sixDOF_Example.ino if you want a human readable output


ciclen wrote:Hello,

I obtain values like that from my arduino
6D429F3D,ADBE23BF,6CBC41BF,0F77BFBD,
7E029F3D,6FC623BF,12B741BF,3F5EBFBD,
E9CF9E3D,16CC23BF,14B341BF,0755BFBD,
91D39E3D,40D423BF,B5AC41BF,862FBFBD,

I change the port to COM3 (where the arduino is working) but muy cube is freeze and the angles don't change. It seems like it cann't read the values.
ameyer
Founder
 
Posts: 3312
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

I am using the IMU code -- it is awesome! However, the resolution of the angle outputs seem to be limited to 1 degree increments. Is there any way to increase the angular resolution?

Thanks in advance.
myrtle13
 
Posts: 1
Joined: Thu Aug 18, 2016 8:18 pm

It's possible that it is just because the resolution is stored in an int so it calculated as a whole number. This is often done because float calculations on the arduino are much slower.

You could try changing to code to calculate a float and see if that helps. Iv'e personally never tried it so I don't know.

myrtle13 wrote:I am using the IMU code -- it is awesome! However, the resolution of the angle outputs seem to be limited to 1 degree increments. Is there any way to increase the angular resolution?

Thanks in advance.
ameyer
Founder
 
Posts: 3312
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Having trouble with the FreeSix_cube.ino

I can load the sixDOF_Example.ino and successfully get readings of angle changes. But when I load the FreeSix_Cube I get this as an output:

Ò–ˆ´‰ 
&%€‰T(��&T á“”ˆ�Vq‚œÉ ’þ-i•f4�Rà�†…‰$€Â"A–�eÉÁÀЖ™ÅŽÔŠ„˜.Í8dÿ”9–Èÿb’ÿ T’N

(literally gibberish) and it continues with this.

Using the Processing code shows no response too. I did not modify the ino files, downloaded them multiple times even. I am using an Arduino Mega. Am I missing something?
Attachments
Serial.png
Serial Print out
Serial.png (102.67 KiB) Viewed 726 times
Jameric
 
Posts: 2
Joined: Sat Nov 19, 2016 10:26 pm

FreeSix_cube.ino is the right file. Your baud rate is just wrong It should be 115200, not 9600.

It is compressed, so it wont be human readable. It will look something like this:
6D429F3D,ADBE23BF,6CBC41BF,0F77BFBD,
7E029F3D,6FC623BF,12B741BF,3F5EBFBD,
E9CF9E3D,16CC23BF,14B341BF,0755BFBD,
91D39E3D,40D423BF,B5AC41BF,862FBFBD,

BUT... that wont have any affect on the processing sketch. Im really not sure at all why it's not working with FreeSix_cube.ino. Is there any error in processing at all?

Unfortunately I'm going to be away for the next week, so I'm sorry if I am very late to reply.



Jameric wrote:Having trouble with the FreeSix_cube.ino

I can load the sixDOF_Example.ino and successfully get readings of angle changes. But when I load the FreeSix_Cube I get this as an output:

Ò–ˆ´‰ 
&%€‰T(��&T á“”ˆ�Vq‚œÉ ’þ-i•f4�Rà�†…‰$€Â"A–�eÉÁÀЖ™ÅŽÔŠ„˜.Í8dÿ”9–Èÿb’ÿ T’N

(literally gibberish) and it continues with this.

Using the Processing code shows no response too. I did not modify the ino files, downloaded them multiple times even. I am using an Arduino Mega. Am I missing something?
ameyer
Founder
 
Posts: 3312
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Yes, changing the baud rate did fix the output on the ino.

The processing sketch runs, it pulls up the sketch, but processes nothing. (see attachment)

The TX light on the board goes out when I run the sketch. Closing the sketch will turn the TX light back on (blinking and then eventually turning solid). If I open the serial monitor in arduino, the TX light comes back on blinking.

No worries on a late reply. I look forward to it when you can.


ameyer wrote:FreeSix_cube.ino is the right file. Your baud rate is just wrong It should be 115200, not 9600.

It is compressed, so it wont be human readable. It will look something like this:
6D429F3D,ADBE23BF,6CBC41BF,0F77BFBD,
7E029F3D,6FC623BF,12B741BF,3F5EBFBD,
E9CF9E3D,16CC23BF,14B341BF,0755BFBD,
91D39E3D,40D423BF,B5AC41BF,862FBFBD,

BUT... that wont have any affect on the processing sketch. Im really not sure at all why it's not working with FreeSix_cube.ino. Is there any error in processing at all?

Unfortunately I'm going to be away for the next week, so I'm sorry if I am very late to reply.



Jameric wrote:Having trouble with the FreeSix_cube.ino

I can load the sixDOF_Example.ino and successfully get readings of angle changes. But when I load the FreeSix_Cube I get this as an output:

Ò–ˆ´‰ 
&%€‰T(��&T á“”ˆ�Vq‚œÉ ’þ-i•f4�Rà�†…‰$€Â"A–�eÉÁÀЖ™ÅŽÔŠ„˜.Í8dÿ”9–Èÿb’ÿ T’N

(literally gibberish) and it continues with this.

Using the Processing code shows no response too. I did not modify the ino files, downloaded them multiple times even. I am using an Arduino Mega. Am I missing something?
Attachments
Sketch.png
Screen cap of sketch
Sketch.png (109.26 KiB) Viewed 703 times
Jameric
 
Posts: 2
Joined: Sat Nov 19, 2016 10:26 pm

For some reason the processing sketch is not getting the serial data from the arduino.

If you have any serial monitor open (even the arduino one) at the same time, it will prevent the processing sketch from getting the data as only one thing can read from the serial at a time.

Other than that, I can't really figure out what is happening.

If you know processing at all, it could be a good test to make a sketch that just prints out any data it gets from the arduino.

Try this:

Code: Select all

import processing.serial.*;
Serial myPort; // Create object from Serial class

final String serialPort = "COM4";

void setup() {
 myPort = new Serial(this, serialPort, 115200);

 delay(100);
 myPort.clear();
 myPort.write("1");
}


void draw() {
  while (myPort.available() > 0) {
    int inByte = myPort.read();
    println(inByte);
  }
}



Jameric wrote:Yes, changing the baud rate did fix the output on the ino.

The processing sketch runs, it pulls up the sketch, but processes nothing. (see attachment)

The TX light on the board goes out when I run the sketch. Closing the sketch will turn the TX light back on (blinking and then eventually turning solid). If I open the serial monitor in arduino, the TX light comes back on blinking.

No worries on a late reply. I look forward to it when you can.


ameyer wrote:FreeSix_cube.ino is the right file. Your baud rate is just wrong It should be 115200, not 9600.

It is compressed, so it wont be human readable. It will look something like this:
6D429F3D,ADBE23BF,6CBC41BF,0F77BFBD,
7E029F3D,6FC623BF,12B741BF,3F5EBFBD,
E9CF9E3D,16CC23BF,14B341BF,0755BFBD,
91D39E3D,40D423BF,B5AC41BF,862FBFBD,

BUT... that wont have any affect on the processing sketch. Im really not sure at all why it's not working with FreeSix_cube.ino. Is there any error in processing at all?

Unfortunately I'm going to be away for the next week, so I'm sorry if I am very late to reply.



Jameric wrote:Having trouble with the FreeSix_cube.ino

I can load the sixDOF_Example.ino and successfully get readings of angle changes. But when I load the FreeSix_Cube I get this as an output:

Ò–ˆ´‰ 
&%€‰T(��&T á“”ˆ�Vq‚œÉ ’þ-i•f4�Rà�†…‰$€Â"A–�eÉÁÀЖ™ÅŽÔŠ„˜.Í8dÿ”9–Èÿb’ÿ T’N

(literally gibberish) and it continues with this.

Using the Processing code shows no response too. I did not modify the ino files, downloaded them multiple times even. I am using an Arduino Mega. Am I missing something?
ameyer
Founder
 
Posts: 3312
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

I understand that the IMU provides accurate axis data for the sensor position. Do you know if we can compare the data from two sensors placed a few feet apart to confirm parallelism for example, that would be way cool!

Thanks in Advance

Jean
JM1010
 
Posts: 1
Joined: Thu Dec 08, 2016 2:14 pm

You could.... BUT I bet there is a much better way of doing it. These IMUs have a bit of drift on them so the data doesn't really stay put and would be hard to compare if you needed precision.

JM1010 wrote:I understand that the IMU provides accurate axis data for the sensor position. Do you know if we can compare the data from two sensors placed a few feet apart to confirm parallelism for example, that would be way cool!

Thanks in Advance

Jean
ameyer
Founder
 
Posts: 3312
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Good evening to everybody and Happy new Year
It seems that i have the same issues with Jameric, namely:

I managed to take compressed information from the ino file. The values seems to be ok (non zero)
However when i run the pde code the box appears and I am able to press h and n (recognizes my inputs correctly)
however the box is not moving as mirror to the sensor. It is just stable like freeze.

I would really appreciate if somebody found what is wrong for this behavior

Regards
delgado
 
Posts: 8
Joined: Thu Dec 22, 2016 2:08 pm

This code is pretty old at this point and I don't have any of the hardware to test it out.
But, what I can assume is happening is that for some reason Processing is not getting the serial data.

Have you made sure the arduino app, or any other serial monitor, are closed when running this? Only one application can connect to the serial port at a time. So if you try to view the serial data while running the processing sketch it will not work.

Also, when you lost the human readable version of the arduino code, is everything correct?

delgado wrote:Good evening to everybody and Happy new Year
It seems that i have the same issues with Jameric, namely:

I managed to take compressed information from the ino file. The values seems to be ok (non zero)
However when i run the pde code the box appears and I am able to press h and n (recognizes my inputs correctly)
however the box is not moving as mirror to the sensor. It is just stable like freeze.

I would really appreciate if somebody found what is wrong for this behavior

Regards
ameyer
Founder
 
Posts: 3312
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Ameyer thanks for the reply

It seems that the COM that i use for Processing sketch is not used by other application.
However I tried also the code that you proposed to Jameric for testing the data transfer from the COM and i get constantly the zero value. Does this mean that i don t have data transfer from that COM?

Yes also the uncompressed data retrieved from ITG through ino seems to be ok (no zero)

Currently i use windows 10, 64 bit, ino latest version and processing v2 (i tested also with the latest pde version. no hope)
I tried also everything to Windows xp ! (:)) and Windows 7 32 bit but the behavior was the same !!

I got crazy.



ameyer wrote:This code is pretty old at this point and I don't have any of the hardware to test it out.
But, what I can assume is happening is that for some reason Processing is not getting the serial data.

Have you made sure the arduino app, or any other serial monitor, are closed when running this? Only one application can connect to the serial port at a time. So if you try to view the serial data while running the processing sketch it will not work.

Also, when you lost the human readable version of the arduino code, is everything correct?

delgado wrote:Good evening to everybody and Happy new Year
It seems that i have the same issues with Jameric, namely:

I managed to take compressed information from the ino file. The values seems to be ok (non zero)
However when i run the pde code the box appears and I am able to press h and n (recognizes my inputs correctly)
however the box is not moving as mirror to the sensor. It is just stable like freeze.

I would really appreciate if somebody found what is wrong for this behavior

Regards
delgado
 
Posts: 8
Joined: Thu Dec 22, 2016 2:08 pm

If the code is printing 0s then it is getting something. It's just not correct for some reason. Iv'e never used a windows machine so I really don't know if the OS would have anything to do with it.

When you load the other .ino code, does it look correct. When you hold it still are the numbers still, and when you tilt it does it change properly?


delgado wrote:Ameyer thanks for the reply

It seems that the COM that i use for Processing sketch is not used by other application.
However I tried also the code that you proposed to Jameric for testing the data transfer from the COM and i get constantly the zero value. Does this mean that i don t have data transfer from that COM?

Yes also the uncompressed data retrieved from ITG through ino seems to be ok (no zero)

Currently i use windows 10, 64 bit, ino latest version and processing v2 (i tested also with the latest pde version. no hope)
I tried also everything to Windows xp ! (:)) and Windows 7 32 bit but the behavior was the same !!

I got crazy.



ameyer wrote:This code is pretty old at this point and I don't have any of the hardware to test it out.
But, what I can assume is happening is that for some reason Processing is not getting the serial data.

Have you made sure the arduino app, or any other serial monitor, are closed when running this? Only one application can connect to the serial port at a time. So if you try to view the serial data while running the processing sketch it will not work.

Also, when you lost the human readable version of the arduino code, is everything correct?

delgado wrote:Good evening to everybody and Happy new Year
It seems that i have the same issues with Jameric, namely:

I managed to take compressed information from the ino file. The values seems to be ok (non zero)
However when i run the pde code the box appears and I am able to press h and n (recognizes my inputs correctly)
however the box is not moving as mirror to the sensor. It is just stable like freeze.

I would really appreciate if somebody found what is wrong for this behavior

Regards
ameyer
Founder
 
Posts: 3312
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Yes it works correctly. The sensor values respond to each movement (yaw pitch roll)
When keeping the sensor stable the data are around the value of sensors last position.

It cannot be a java issue (or even a graphics issue) since many of the pde examples are operating perfectly.

In case that i want to print the received data from the FreeSix_cube.pde
what should i do?
I tried in void keyPressed() { i inserted println(q); before the if statments
and i took [0] 0.0 [1] 0.0 [2] 0.0 [3] 0.0
So in that case communication exist, but i have no data ?

I attach also an image of the sixDOF_Example.ino where all the data seems to be ok.
Also the data taken when loading the FreeSix_cube.ino seems to be ok (not attached here)





ameyer wrote:If the code is printing 0s then it is getting something. It's just not correct for some reason. Iv'e never used a windows machine so I really don't know if the OS would have anything to do with it.

When you load the other .ino code, does it look correct. When you hold it still are the numbers still, and when you tilt it does it change properly?


delgado wrote:Ameyer thanks for the reply

It seems that the COM that i use for Processing sketch is not used by other application.
However I tried also the code that you proposed to Jameric for testing the data transfer from the COM and i get constantly the zero value. Does this mean that i don t have data transfer from that COM?

Yes also the uncompressed data retrieved from ITG through ino seems to be ok (no zero)

Currently i use windows 10, 64 bit, ino latest version and processing v2 (i tested also with the latest pde version. no hope)
I tried also everything to Windows xp ! (:)) and Windows 7 32 bit but the behavior was the same !!

I got crazy.



ameyer wrote:This code is pretty old at this point and I don't have any of the hardware to test it out.
But, what I can assume is happening is that for some reason Processing is not getting the serial data.

Have you made sure the arduino app, or any other serial monitor, are closed when running this? Only one application can connect to the serial port at a time. So if you try to view the serial data while running the processing sketch it will not work.

Also, when you lost the human readable version of the arduino code, is everything correct?

delgado wrote:Good evening to everybody and Happy new Year
It seems that i have the same issues with Jameric, namely:

I managed to take compressed information from the ino file. The values seems to be ok (non zero)
However when i run the pde code the box appears and I am able to press h and n (recognizes my inputs correctly)
however the box is not moving as mirror to the sensor. It is just stable like freeze.

I would really appreciate if somebody found what is wrong for this behavior

Regards
Attachments
values.PNG
values.PNG (44.95 KiB) Viewed 124 times
delgado
 
Posts: 8
Joined: Thu Dec 22, 2016 2:08 pm

I really don't know what is going on. It seems like the data coming over is just blank for some reason.
You could use the "sixDOF_Example.ino" and a simple println sketch in processing to see if that data comes over correctly


To do what you want(print out the data), I would start with something like this in readQ:


void readQ() {
if (myPort.available() >= 18) {
String inputString = myPort.readStringUntil('n');
println(inputString);
if (inputString != null && inputString.length() > 0) {
String [] inputStringArr = split(inputString, ",");
if (inputStringArr.length >= 5) { // q1,q2,q3,q4,rn so we have 5 elements
q[0] = decodeFloat(inputStringArr[0]);
q[1] = decodeFloat(inputStringArr[1]);
q[2] = decodeFloat(inputStringArr[2]);
q[3] = decodeFloat(inputStringArr[3]);
}
}
}else{
println(myPort.available()); //how many characters are available
}
}




delgado wrote:Yes it works correctly. The sensor values respond to each movement (yaw pitch roll)
When keeping the sensor stable the data are around the value of sensors last position.

It cannot be a java issue (or even a graphics issue) since many of the pde examples are operating perfectly.

In case that i want to print the received data from the FreeSix_cube.pde
what should i do?
I tried in void keyPressed() { i inserted println(q); before the if statments
and i took [0] 0.0 [1] 0.0 [2] 0.0 [3] 0.0
So in that case communication exist, but i have no data ?

I attach also an image of the sixDOF_Example.ino where all the data seems to be ok.
Also the data taken when loading the FreeSix_cube.ino seems to be ok (not attached here)





ameyer wrote:If the code is printing 0s then it is getting something. It's just not correct for some reason. Iv'e never used a windows machine so I really don't know if the OS would have anything to do with it.

When you load the other .ino code, does it look correct. When you hold it still are the numbers still, and when you tilt it does it change properly?


delgado wrote:Ameyer thanks for the reply

It seems that the COM that i use for Processing sketch is not used by other application.
However I tried also the code that you proposed to Jameric for testing the data transfer from the COM and i get constantly the zero value. Does this mean that i don t have data transfer from that COM?

Yes also the uncompressed data retrieved from ITG through ino seems to be ok (no zero)

Currently i use windows 10, 64 bit, ino latest version and processing v2 (i tested also with the latest pde version. no hope)
I tried also everything to Windows xp ! (:)) and Windows 7 32 bit but the behavior was the same !!

I got crazy.



ameyer wrote:This code is pretty old at this point and I don't have any of the hardware to test it out.
But, what I can assume is happening is that for some reason Processing is not getting the serial data.

Have you made sure the arduino app, or any other serial monitor, are closed when running this? Only one application can connect to the serial port at a time. So if you try to view the serial data while running the processing sketch it will not work.

Also, when you lost the human readable version of the arduino code, is everything correct?

delgado wrote:Good evening to everybody and Happy new Year
It seems that i have the same issues with Jameric, namely:

I managed to take compressed information from the ino file. The values seems to be ok (non zero)
However when i run the pde code the box appears and I am able to press h and n (recognizes my inputs correctly)
however the box is not moving as mirror to the sensor. It is just stable like freeze.

I would really appreciate if somebody found what is wrong for this behavior

Regards
ameyer
Founder
 
Posts: 3312
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Hi ameyer, first of all, I would like to thank you for this wonderful blog post. It was a great help to my fyp which im currently doing. My problem is the display shown on the pde file. The cube is rotating well but the values are not shown the way it is supposed to be in the processing software. Mind showing how I can edit the programme codes?
Attachments
IMU display.png
IMU display.png (199.64 KiB) Viewed 102 times
arisha
 
Posts: 1
Joined: Wed Jan 11, 2017 4:04 am

I really dont know what is going wrong
I think i will abandon this project finally :(

When i loaded the sixDOF_Example.ino i tried this pde code (i dont know if it is correct)

import processing.serial.*;

Serial myPort; // Create object from Serial class

final String serialPort = "COM3";


float [] q = new float [4];


void setup()
{

myPort = new Serial(this, serialPort, 115200);


delay(100);
myPort.clear();
myPort.write("1");

println(q);

}


i took back an array of zeros.

and when i tried the addition you suggested in the original pde code with the corresponding ino file loaded i took back a list of zeros some numbers and then null (see picture below).

I am so frustrated that i ll find a mac machine to check everything from scratch




ameyer wrote:I really don't know what is going on. It seems like the data coming over is just blank for some reason.
You could use the "sixDOF_Example.ino" and a simple println sketch in processing to see if that data comes over correctly


To do what you want(print out the data), I would start with something like this in readQ:


void readQ() {
if (myPort.available() >= 18) {
String inputString = myPort.readStringUntil('n');
println(inputString);
if (inputString != null && inputString.length() > 0) {
String [] inputStringArr = split(inputString, ",");
if (inputStringArr.length >= 5) { // q1,q2,q3,q4,rn so we have 5 elements
q[0] = decodeFloat(inputStringArr[0]);
q[1] = decodeFloat(inputStringArr[1]);
q[2] = decodeFloat(inputStringArr[2]);
q[3] = decodeFloat(inputStringArr[3]);
}
}
}else{
println(myPort.available()); //how many characters are available
}
}




delgado wrote:Yes it works correctly. The sensor values respond to each movement (yaw pitch roll)
When keeping the sensor stable the data are around the value of sensors last position.

It cannot be a java issue (or even a graphics issue) since many of the pde examples are operating perfectly.

In case that i want to print the received data from the FreeSix_cube.pde
what should i do?
I tried in void keyPressed() { i inserted println(q); before the if statments
and i took [0] 0.0 [1] 0.0 [2] 0.0 [3] 0.0
So in that case communication exist, but i have no data ?

I attach also an image of the sixDOF_Example.ino where all the data seems to be ok.
Also the data taken when loading the FreeSix_cube.ino seems to be ok (not attached here)





ameyer wrote:If the code is printing 0s then it is getting something. It's just not correct for some reason. Iv'e never used a windows machine so I really don't know if the OS would have anything to do with it.

When you load the other .ino code, does it look correct. When you hold it still are the numbers still, and when you tilt it does it change properly?


delgado wrote:Ameyer thanks for the reply

It seems that the COM that i use for Processing sketch is not used by other application.
However I tried also the code that you proposed to Jameric for testing the data transfer from the COM and i get constantly the zero value. Does this mean that i don t have data transfer from that COM?

Yes also the uncompressed data retrieved from ITG through ino seems to be ok (no zero)

Currently i use windows 10, 64 bit, ino latest version and processing v2 (i tested also with the latest pde version. no hope)
I tried also everything to Windows xp ! (:)) and Windows 7 32 bit but the behavior was the same !!

I got crazy.



ameyer wrote:This code is pretty old at this point and I don't have any of the hardware to test it out.
But, what I can assume is happening is that for some reason Processing is not getting the serial data.

Have you made sure the arduino app, or any other serial monitor, are closed when running this? Only one application can connect to the serial port at a time. So if you try to view the serial data while running the processing sketch it will not work.

Also, when you lost the human readable version of the arduino code, is everything correct?

delgado wrote:Good evening to everybody and Happy new Year
It seems that i have the same issues with Jameric, namely:

I managed to take compressed information from the ino file. The values seems to be ok (non zero)
However when i run the pde code the box appears and I am able to press h and n (recognizes my inputs correctly)
however the box is not moving as mirror to the sensor. It is just stable like freeze.

I would really appreciate if somebody found what is wrong for this behavior

Regards
Attachments
serial.PNG
serial.PNG (25.37 KiB) Viewed 95 times
delgado
 
Posts: 8
Joined: Thu Dec 22, 2016 2:08 pm

That is very weird.

It has something to do with the decodeFloat in readQ

On one hand it looks like the decodeFloat function is working as it is rotating, but then that same decodeFloat is not printing correctly. I'm actually not sure why that is at all or what to do about it.

arisha wrote:Hi ameyer, first of all, I would like to thank you for this wonderful blog post. It was a great help to my fyp which im currently doing. My problem is the display shown on the pde file. The cube is rotating well but the values are not shown the way it is supposed to be in the processing software. Mind showing how I can edit the programme codes?
ameyer
Founder
 
Posts: 3312
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

Something seems wrong with arduino talking to processing. So we can start super basic and see if this works

Arduino code
Code: Select all
long printVal = 0;

void setup() {
  Serial.begin(115200);
}

void loop() {
  printVal ++;
  Serial.print(printVal);
}


processing code
Code: Select all
import processing.serial.*;
Serial myPort;

void setup() {
 myPort = new Serial(this, "COM3", 115200);

 delay(100);
 myPort.clear();
 myPort.write("1");
}


void draw() {
  while (myPort.available() > 0) {
    int inByte = myPort.read();
    println(inByte);
  }
}



delgado wrote:I really dont know what is going wrong
I think i will abandon this project finally :(

When i loaded the sixDOF_Example.ino i tried this pde code (i dont know if it is correct)

import processing.serial.*;

Serial myPort; // Create object from Serial class

final String serialPort = "COM3";


float [] q = new float [4];


void setup()
{

myPort = new Serial(this, serialPort, 115200);


delay(100);
myPort.clear();
myPort.write("1");

println(q);

}


i took back an array of zeros.

and when i tried the addition you suggested in the original pde code with the corresponding ino file loaded i took back a list of zeros some numbers and then null (see picture below).

I am so frustrated that i ll find a mac machine to check everything from scratch




ameyer wrote:I really don't know what is going on. It seems like the data coming over is just blank for some reason.
You could use the "sixDOF_Example.ino" and a simple println sketch in processing to see if that data comes over correctly


To do what you want(print out the data), I would start with something like this in readQ:


void readQ() {
if (myPort.available() >= 18) {
String inputString = myPort.readStringUntil('n');
println(inputString);
if (inputString != null && inputString.length() > 0) {
String [] inputStringArr = split(inputString, ",");
if (inputStringArr.length >= 5) { // q1,q2,q3,q4,rn so we have 5 elements
q[0] = decodeFloat(inputStringArr[0]);
q[1] = decodeFloat(inputStringArr[1]);
q[2] = decodeFloat(inputStringArr[2]);
q[3] = decodeFloat(inputStringArr[3]);
}
}
}else{
println(myPort.available()); //how many characters are available
}
}




delgado wrote:Yes it works correctly. The sensor values respond to each movement (yaw pitch roll)
When keeping the sensor stable the data are around the value of sensors last position.

It cannot be a java issue (or even a graphics issue) since many of the pde examples are operating perfectly.

In case that i want to print the received data from the FreeSix_cube.pde
what should i do?
I tried in void keyPressed() { i inserted println(q); before the if statments
and i took [0] 0.0 [1] 0.0 [2] 0.0 [3] 0.0
So in that case communication exist, but i have no data ?

I attach also an image of the sixDOF_Example.ino where all the data seems to be ok.
Also the data taken when loading the FreeSix_cube.ino seems to be ok (not attached here)





ameyer wrote:If the code is printing 0s then it is getting something. It's just not correct for some reason. Iv'e never used a windows machine so I really don't know if the OS would have anything to do with it.

When you load the other .ino code, does it look correct. When you hold it still are the numbers still, and when you tilt it does it change properly?


delgado wrote:Ameyer thanks for the reply

It seems that the COM that i use for Processing sketch is not used by other application.
However I tried also the code that you proposed to Jameric for testing the data transfer from the COM and i get constantly the zero value. Does this mean that i don t have data transfer from that COM?

Yes also the uncompressed data retrieved from ITG through ino seems to be ok (no zero)

Currently i use windows 10, 64 bit, ino latest version and processing v2 (i tested also with the latest pde version. no hope)
I tried also everything to Windows xp ! (:)) and Windows 7 32 bit but the behavior was the same !!

I got crazy.



ameyer wrote:This code is pretty old at this point and I don't have any of the hardware to test it out.
But, what I can assume is happening is that for some reason Processing is not getting the serial data.

Have you made sure the arduino app, or any other serial monitor, are closed when running this? Only one application can connect to the serial port at a time. So if you try to view the serial data while running the processing sketch it will not work.

Also, when you lost the human readable version of the arduino code, is everything correct?

delgado wrote:Good evening to everybody and Happy new Year
It seems that i have the same issues with Jameric, namely:

I managed to take compressed information from the ino file. The values seems to be ok (non zero)
However when i run the pde code the box appears and I am able to press h and n (recognizes my inputs correctly)
however the box is not moving as mirror to the sensor. It is just stable like freeze.

I would really appreciate if somebody found what is wrong for this behavior

Regards
ameyer
Founder
 
Posts: 3312
Joined: Thu Jan 21, 2010 11:59 pm
Location: The Bay Area

PreviousNext

Return to Blog Posts

Who is online

Users browsing this forum: No registered users and 1 guest