…I mean – Sense of Sight
So things were going “ok” with the basics of motor drive and gamepad control. But I was desperate to get on with the stuff which was going to start to give us the automation we needed. Enter the Time-of-Flight sensors and Cameras…. For poli:droid we aimed to have it self driving many of the courses so we decided to install two forward facing and two side facing ToF sensors so that we can detect approaching obstacles and determine their angle relative to the front of of robot and then ensure we have space to each side as well as detect a gap in any way to which we are driving parallel.
One’s & Zero’s
Alex already had a couple of the VL53L1X from Pimoroni in his (some might say worryingly) extensive supply cabinet and being such a seemingly simple little device, off I set with coding up a class to interact with it. On the face of it, this was a pretty simple task and, unlike with the Adafruit pHats, there was no ready-built class library for this sensor, so it gave me an opportunity to work directly with the Windows.Devices.I2C class library and build all of the interactions myself.
Whilst i was looking into how to do this, I found a Git Repo which, using it’s predecessor the VL53L0X, had a nice and simple class written out to be able to acquire the ranging data we were after.
Well as it turns out, there is apparently quite a difference between the ‘0’ and the ‘1’. Trying to find the I2C register map for the newer device eventually lead me to a rather worrying quote on the manufacturers website stating that – because of how complex the VL53L1X is, the register map is not available, use the API instead…
C Minus Minus
Never having used C++ before, the API looked rather daunting but after looking around at some of the other libraries which had created a wrapper around it, having a plucky can do attitude and never being one to give up on a challenge, I thought I’d give making my own .net UWP wrapper a go…
…. 1 week later, the VL53L0X had arrived and was working beautifully.
Now on to the line following Camera, PixyCam2 being the unit of choice and USB being the interface of choice. But it didn’t take long before running into the same challenge as above; having to develop my own wrapper around the hornets nest of C++ and it’s never ending #Includes…
I-SPI with my little Pi
So being ever aware of the impending deadline and how much there was still left to complete, I decided to give a different interface a try. Considering I2C was already in use for most other components and with the documentation starting that SPI produces better results, I thought i’d give it a go.
… I’m so glad i did, after an hour or so I had some basic functions working in my new library controlling the Lamps and LEDs on the PixyCam2.
Next was onto actually receiving and handling some meaningful data from the device, which thanks to the excellent documentation and sample libraries provided by the manufacturers of this great little cam, didn’t take too long at all (once Alex pointed out that my sample line was black on white, whilst the cam was configured for white on black).
7 total views, 1 views today