Detect 360° YAW/ROLL/PITCH

Hi everyone, 

I have a little project with ArduIMUV3.

The point is to detect a complete revolution 360° on roll, pitch and yaw axis, and lit up one of the leds.

I can't find where is the part in ArduIMU 1.9 code that gives the initial values of roll pitch and yaw, I would like to use these as my initial conditions to start counting a rotation on each axis.

I have tried and adapted this code found on the web for yaw, add it to the DCM file and call the function in arduimu file but no chance, also because I don't know how to get the initial values:

void ThreeSixty(float ActualYAW)
{
float prev_yaw;
float yawDeg = ToDeg(ActualYAW);
boolean cp_pi;
float yaw = yawDeg;
Serial.println(yawDeg);
if ((yaw == 180) || (yaw == 0)) return;

if (yaw * prev_yaw < 0)
{

float d_yaw = (yaw - prev_yaw);
if (d_yaw < 0)
{
cp_pi = ! cp_pi;
}
else if (cp_pi)
{
// fire detection event
Serial.print("______ThreeSixtyYAW");
Serial.print(ActualYAW);
Serial.print("______");
digitalWrite(RED_LED_PIN,HIGH);
digitalWrite(BLUE_LED_PIN,LOW);
}
}
prev_yaw = yaw;
}

Also I have tried to compile the FreeIMU code but I get the following errors:

FreeIMU_yaw_pitch_roll:115: error: stray '#' in program

FreeIMU_yaw_pitch_roll.cpp:126:9: error: invalid suffix "ff00" on integer constant
FreeIMU_yaw_pitch_roll:122: error: stray '#' in program
FreeIMU_yaw_pitch_roll.cpp:133:9: error: invalid suffix "ff" on integer constant
FreeIMU_yaw_pitch_roll:129: error: stray '#' in program
FreeIMU_yaw_pitch_roll:136: error: stray '#' in program
FreeIMU_yaw_pitch_roll:143: error: stray '#' in program
FreeIMU_yaw_pitch_roll:150: error: stray '#' in program
FreeIMU_yaw_pitch_roll.cpp:161:9: error: invalid suffix "ffff" on integer constant
FreeIMU_yaw_pitch_roll:163: error: stray '#' in program
FreeIMU_yaw_pitch_roll:165: error: stray '#' in program
FreeIMU_yaw_pitch_roll:169: error: stray '#' in program
FreeIMU_yaw_pitch_roll:186: error: stray '#' in program
FreeIMU_yaw_pitch_roll:188: error: stray '#' in program
FreeIMU_yaw_pitch_roll:191: error: stray '#' in program
FreeIMU_yaw_pitch_roll:200: error: stray '#' in program
FreeIMU_yaw_pitch_roll:201: error: stray '#' in program
FreeIMU_yaw_pitch_roll:21: error: variable or field 'serialEvent' declared void
FreeIMU_yaw_pitch_roll:21: error: expected `)' before 'p'
FreeIMU_yaw_pitch_roll:26: error: expected ',' or '...' before 'q'
FreeIMU_yaw_pitch_roll:27: error: 'import' does not name a type
FreeIMU_yaw_pitch_roll:29: error: 'Serial' does not name a type
FreeIMU_yaw_pitch_roll:32: error: expected unqualified-id before '[' token
FreeIMU_yaw_pitch_roll:33: error: expected unqualified-id before '[' token
FreeIMU_yaw_pitch_roll:36: error: expected unqualified-id before '[' token
FreeIMU_yaw_pitch_roll:38: error: 'PFont' does not name a type
FreeIMU_yaw_pitch_roll:39: error: expected constructor, destructor, or type conversion before 'int'
FreeIMU_yaw_pitch_roll.cpp: In function 'void myDelay(int)':
FreeIMU_yaw_pitch_roll:45: error: 'Thread' was not declared in this scope
FreeIMU_yaw_pitch_roll:46: error: expected type-specifier before 'InterruptedException'
FreeIMU_yaw_pitch_roll:46: error: exception handling disabled, use -fexceptions to enable
FreeIMU_yaw_pitch_roll:46: error: expected `)' before 'e'
FreeIMU_yaw_pitch_roll:46: error: expected `{' before 'e'
FreeIMU_yaw_pitch_roll:46: error: 'e' was not declared in this scope
FreeIMU_yaw_pitch_roll:46: error: expected `;' before ')' token
FreeIMU_yaw_pitch_roll.cpp: In function 'void setup()':
FreeIMU_yaw_pitch_roll:51: error: 'VIEW_SIZE_X' was not declared in this scope
FreeIMU_yaw_pitch_roll:51: error: 'VIEW_SIZE_Y' was not declared in this scope
FreeIMU_yaw_pitch_roll:51: error: 'P3D' was not declared in this scope
FreeIMU_yaw_pitch_roll:51: error: 'size' was not declared in this scope
FreeIMU_yaw_pitch_roll:52: error: 'myPort' was not declared in this scope
FreeIMU_yaw_pitch_roll:52: error: expected type-specifier before 'Serial'
FreeIMU_yaw_pitch_roll:52: error: expected `;' before 'Serial'
FreeIMU_yaw_pitch_roll:55: error: 'font' was not declared in this scope
FreeIMU_yaw_pitch_roll:55: error: 'loadFont' was not declared in this scope
FreeIMU_yaw_pitch_roll:57: error: 'println' was not declared in this scope
FreeIMU_yaw_pitch_roll.cpp: In function 'float decodeFloat(String)':
FreeIMU_yaw_pitch_roll:72: error: expected unqualified-id before '[' token
FreeIMU_yaw_pitch_roll:75: error: 'inData' was not declared in this scope
FreeIMU_yaw_pitch_roll:75: error: 'unhex' was not declared in this scope
FreeIMU_yaw_pitch_roll:81: error: 'inData' was not declared in this scope
FreeIMU_yaw_pitch_roll:82: error: 'Float' was not declared in this scope
FreeIMU_yaw_pitch_roll.cpp: At global scope:
FreeIMU_yaw_pitch_roll:86: error: variable or field 'serialEvent' declared void
FreeIMU_yaw_pitch_roll:86: error: expected `)' before 'p'

Thanks a lot, 

Best Regards,

arduimu.pde

DCM.pde

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • I'm not certain but I think the DCM algorithm only gives you -90 to +90 degrees in pitch; -180 to 180 degrees in roll and yaw.  The algorithm suffers from Gimbal Lock because in the pitch calculation there is a sin or cos function of the pitch angle which is in the denominator in some expression.

This reply was deleted.

Activity

Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21
More…