I’m having some issues transferring my encoder values from my Romi to my Raspberry Pi 3 using the a_star.py library.
I get “data” but the issue manifests as unstable values and odd discontinuities as I roll the wheels. For example, the following is a trace of the encoder values read out from my_astar.read_encoders() as I push the robot forwards.
I would expect the encoder to go from 0 to -1 in this case, or to go from 0 to 65535 if I were using unsigned 16-bit arithmetic, but 32xxx suggests something weirder.
The Romi side seems fine. I dumped the getCounts and buffer values to Serial on the Romi side just to confirm:
Can anyone point me at any ideas for what to debug next? I’m almost to the point of putting a logic analyzer on the I2C bus (though I suspect the data is fine on the wire). My guess is that I’m causing/encountering a signing error somewhere that is causing the bytes to lose their high bits.
Thank you for your reply. I can confirm that I am observing the same behavior with the stock raspberry pi slave library slave.py program on the room 32u4 control board and the arduino RomiRPiSlaveDemo from same GitHub repo. My raspberry pi is a version 3 model running Ubuntu MATE 16.04.
Ah ha! I tried increasing the PololuRPiSlave delay template parameter to 20 from 5. The numbers now go negative from zero as expected (at least on the server.py example).
PololuRPiSlave<struct Data,20> slave;
I will report back as I find out more.
I’m glad the issue is resolved; thank you for letting us know.
I suspect you might have not set the clock frequency for the I2C on the Raspberry Pi to work with the original RomiRPiSlaveDemo code. If you do not already know and for others following this thread, there is a known bug with the Raspberry Pi’s I2C implementation, which is mentioned in the Summary section of the README.md file on the library’s GitHub Page as well as in the comments at the top of PololuRPiSlave.h.