I've just started to play with my brand new Mindsensors Line leader, and found some strange points in the NXTLineLeader class.
First strange point is that single bytes registers are read as 2 bytes ones. For instance, steering, average, result, Kp,... are read using statements like the following one :
- Code: Select all
getData(LL_READ_STEERING, buf, 2)
Shouldn't this be :
- Code: Select all
getData(LL_READ_STEERING, buf, 1)
instead ?
In addition, steering is supposed to be signed since it's a bias to be added/subtracted to motors power setting. But in the getSteering method, the returned value is computed using the following expression :
- Code: Select all
buf[0] & 0xff
which clears the sign bit and thus makes negative values be returned as positive ones in the upper range of the 0..255 domain.
Using the orginal code makes my basic test program (copied from RobotC equivalent) fail. Patching the source to fix the above mentionned points makes things behave as they should.
Since it's quite surprising nobody ever mentioned these points, I suspect I'm missing something (although I'm rather confident about my fixes). Maybe the code in the lib relates to some previous version of the sensor, since I could notice that some of the sensor features are not made accessible by the class.
Could anybody shed some light please ?
Best regards
PS: in the event my guesses would be right, I would be glad to provide my modified version of the class, with additions supporting missing features of the sensor. Just tell me how I can contribute.
