Thread: Odd math issues
View Single Post
  #1   Spotlight this post!  
Unread 17-02-2007, 10:34
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Odd math issues

Our current robot has the following function in it which adjusts the desired orientation of one of our joints based upon the joystick:

Code:
void Waist(void) {
    long delta;
   
    if(p1_wheel>147) {
      delta=-1L;
    }
    if(p1_wheel<107) {
      delta=1L;
    }
  
    waist_theta-= delta;


}
All the variables in this code are declared as longs, except for p1_wheel (obviously). waist_theta is only read in other functions, not written.

Despite this, somehow the value of waist_theta is sporadically jumping instantly to a large negative number. Any ideas? I'm suspecting some unusual type conversion issue.