want yaw=0 at start , what ever the position of the board

Asked by sajid zaman

hello,
           is there any way to get yaw=0 at initial what ever the position of the board whether the board point toward north or south
 and consider initial position as a north mean give yaw=0.thanks

Question information

Language:
English Edit question
Status:
Solved
For:
FreeIMU Edit question
Assignee:
No assignee Edit question
Solved by:
Fabio Varesano
Solved:
Last query:
Last reply:
Revision history for this message
Best Fabio Varesano (fabio-varesano) said :
#1

Yes. An example of that is given in the FreeIMU_cube processing program when you press the h button.

Revision history for this message
sajid zaman (engr-sajidzaman) said :
#2

Thanks Fabio Varesano, that solved my question.

Revision history for this message
sajid zaman (engr-sajidzaman) said :
#3

i also work on that last night and solve the problem by adding some code in void loop() , but that works on yaw only which we got from getyawpitchroll() function , if u want i can share the code

Revision history for this message
Fabio Varesano (fabio-varesano) said :
#4

yes please.

Revision history for this message
sajid zaman (engr-sajidzaman) said :
#5

int temp=0; //Global variables
int yawcount=0;

void loop()
{

//...............................
//.......................
//...........................

Yaw=map(Yaw,-180,180,0,360); // if ur yaw is from 0 to 360 then it doesn't need

  yawcount++;
  if(yawcount==50)
    temp=Yaw; // variable to take yaw at initial but after when yaw comes stable
  if(yawcount>55)
    yawcount=55;

  int yaw2;
   yaw2=Yaw;

  if(temp>Yaw && Yaw>=0)
    yaw2=Yaw+360;
  if(Yaw==360)
    yaw2=360;

  yaw2-=temp;
  Serial.print(" Yaw -temp : ");
  if(yaw2>=0 && yaw2<180)
  yaw2+=180;
else if(yaw2>=180 && yaw2<=360)
  yaw2-=180;

  yaw2=map(yaw2,0,360,-180,180); // if you want yaw from 0 to 360 then its not needed
  Serial.println(int(yaw2));

//.........................
//...............

}