All Hardware Done, Let's Integrate the Sensors
The last 7 days have been so busy it almost feels like a month has passed since my last post. The MDF plates were laser cut the day after my last post and since then I've been hard at work, modelling mounts for everything. I know I said in my last post I planned to just zip-tie everything down, but sensors need a fixed reference point without the risk of them moving around within the carriage, and the grid system I designed with zip-ties in mind makes aligning 3D printed mounts for everything relatively simple.
With every change I make, I keep the CAD model up to date and as close as I reasonably can to the physical robot. This help me keep everything well-planned and organised and helps me spot any issues before I try printing/assembling anything.
I'm using M3 heat-set inserts to allow my printed parts to be cleanly and securely bolted to the MDF plate through the grid holes.
Another big milestone reached in the last few days is that the track has now been brought up to the lab, a big thanks to Nick, Alex and the other faculty staff who helped move that enormous thing across campus! The next step is integrating the robot with the track!
It's Sensor Time
Now all the hardware is (mostly) attached together, it's time to turn back to the software side of this project. As I began trying to integrate the sensors, I noticed my development environment I had set up a few weeks ago wasn't particularly dev-friendly; intellisense and syntax completion were nowhere to be found. I got to work researching and made some significant improvements to the development experience by introducing Meta's PyreFly language server into the mix and finding sets of Micropython and Pimoroni firmware stubs to get syntax completion and proper import checking for the built-in libraries I'm using (i.e. machine and Inventor. All this is managed as part of the Nix flake, making the whole setup declarative and completely reproducible with a single command on any machine with Nix installed.
With my environment now set up to my liking, I began programming some modules to read the sensors individually (I'll work on combining the data later). The first was the IMU which required a library to be installed. The official bno08x library from AdaFruit is compatible only with Circuitpython, so to use it in Micropython, I found this community-developed library instead. I added it to the nix flake and made it so Nix regenerates the lib folder every time nix develop is run to keep things reproducible. The tutorial documentation is easy to follow and before long I was getting linear acceleration readings from the IMU.
The DFRobot distance sensor is quite a bit more difficult to work with though, it's accessible only over UART by sending raw byte values directly with no library to abstract away the process. On top of that, the documentation leaves a lot to be desired and it heavily implies DFRobot have reverse-engineered this sensor and don't fully know how it works. After a few hours of staring at the documentation and whipping up a quick script to generate the checksums required at the end every command, I eventually got to the point where I could get readings from it and adjust other settings like activating/deactivating the visible targeting laser.
