I was looking for an Arduino library to convert the signal from the Sharp GP2Y0A60SZLF Analog Distance Sensor (5V) I use in my Mini-Sumo project to a distance value. The features I was looking for in a library for were:
- Possibility of using a fifth order polynomial fit curve
- Possibility to perform real-time (moving window) median filtering on the signal with an adjustable filter window size.
I searched for existing libraries that would offer these features but didn’t find any. The libraries I found were either using look-up tables or power functions instead of polynomial. Some offered median filtering but not in real-time (filtering on a batch of readings at a time only).
So I decided to write my own library. This is the first library I write for Arduino. Most of my coding experience so far was in Python or Matlab so the process of learning how to write classes in C++ and package the code to meet the Arduino library specification was a great learning experience. The Arduino Library Tutorial as well as simply looking at the different Pololu libraries were of great help in the process.
I made the library to be simple to use with default calibration coefficients for the Sharp GP2Y0A60SZLF Analog Distance Sensor (5V) built-in whilst still offering the possibility to define custom calibration coefficients, allowing its use with different sensors and/or with different units. Hopefully the library is documented well enough so that it can be useful to others.
Also, after reading @ryantm’s blog post on continuous testing with PlatformIO and Travis CI, I decided to give it a try and put my library to the test, which succeeded!
As this is my first Arduino library and I am far from being a professional programmer, feel free to have a look and provide me feedback on how I could improve it.
P.S. To the forum moderators; I posted this in the “Software” section, feel free to move it to “Sensors” if you feel it is more appropriate.