View Single Post
  #2   Spotlight this post!  
Unread 03-03-2005, 22:35
EricS-Team180's Avatar
EricS-Team180 EricS-Team180 is offline
SPAM, the lunchmeat of superheroes!
AKA: Eric Schreffler
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Apr 2002
Rookie Year: 2001
Location: Stuart, Florida
Posts: 561
EricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond repute
Re: Casting Floats, printf's, and variable maxing

You might try splitting things up, temporarily to get to the bottom of it...

Code:
int nav_heading;
int new_pos;
int old_pos;
int dist=0;
int nav_x;
int nav_y;

void Navigation(void)
{
	
float temp ;

	nav_heading = Get_Gyro_Angle();
	
	new_pos = (int)( Get_Left_Encoder_Count() + Get_Right_Encoder_Count() )/2;  
	

	dist = (new_pos - old_pos);

        /*nav_x+= (int) cos((float) nav_heading /1000) * dist;*/
        /* ...add printfs to keep checking the value of temp*/ 
         temp = (float) nav_heading ;
         temp /= 1000. ;
         temp = cos(temp) ; 
         temp *= (float)dist ;
	 nav_x = (int)temp ;

	nav_y+= (int) sin((float)nav_heading/1000) * dist;

	
	old_pos = new_pos;
}
That always helps me figure out casting peculiarities...

Eric
__________________

Don't PANIC!
S. P. A. M.