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.