After a working hard all day I got back to debugging my robot and rummaging through the Icommand classes in search of a bug.
My quest was not in vain. I think.
from Pilot.java:
- Code: Select all
public int getLeftCount(){ return _parity*_left.getTachoCount();}
public int getRightCount(){ return _parity*_right.getTachoCount();}
Now, the tachocount, according to Outputstate.java, is the number of counts since last reset of the motor counter. This sounds all well and good, but for some reason I noticed after a couple of debug lines, it was never reset! It worked like blockTachoCount, counting degrees of rotation since the NXT was turned on. ("Current position relative to last programmed movement" - OutputState.java).
Motor A Rotation Count : 240 Motor B Rotation Count : 243
Motor A Tacho Count :8987 Motor B Tacho Count :8993
Motor A Block Tacho :8987 Motor B Block Tacho :8993
Why was it not reset?
- Code: Select all
public void resetTachoCount()
{
_left.resetRotationCounter(); // !! Which one is TachoCount???
_right.resetRotationCounter();
}
This is why.
Interestingly, changing only resetTachoCount() to reset the correct count didn't seem to fix anything, so I changed getLeftCount() and its sibling, along with getTravelDistance() to read the correct counter, the RotationCounter.
In other news, after I'd recovered from this debugging ordeal, I noticed that using a lower ratio (0.8 as opposed to 0.95) in updatePosition() gave me highly accurate X and Y values.
I just hope it won't bork up my rotations.
-M