The Path of Greatest Resistence
So when we set out on this mission, Alex had the robotics experience from last year’s competition, but i was very much starting from zero, never having so much as lit a bulb using a Raspberry Pi, let alone spun a motor or interacted with sensors. So we had a choice: hit the ground running by recycling Alex’s Python code from last year (soooo tempting) or start from the ground floor and write from scratch.
“The best laid plans…”
Why do we do it to ourselves? There are so many tried & tested libraries and code examples out there that would make the coding of poli:droid so much easier to complete but rather than going with the flow we decided to use an OS by little-known software developers Microsoft…
Being .Net developers, we actually felt that the learning curve shouldn’t actually have been that great. But even so, we set ourselves a deadline of middle November to get all of the different elements at least tested and working to a basic level; failing to do meaning we would revert back to Alex’s Python codebase so ensure we wouldn’t fail to have a working robot.
Installing Windows IoT Core is actually really simple as is documented here https://docs.microsoft.com/en-us/windows/iot-core/tutorials/rpi. Much like Raspbian using NOOBS, its really just a case of flashing an image to your MicroSD and plugging it in. Then using Visual Studio to develop and debug code directly to the device.
My Hat’s Spinning…
Well as you can read about in a previous post (https://polidroid.co.uk/2020/02/01/set-backs-steps-back/), what happened happened and derailed all of our timescales leaving us with minimal time to do what we needed to do, but being a bit on the stubborn side, I decided to just double down and make it Windows IOT work for us.
So I got to work on a project with some controls to test the various components we needed to get working, starting with motors, after some investigating, we decided to use the Adafruit pHats for Motor and Servo control. What was great about these is that they have a library in the Visual Studio NuGet Package Manager which was well documented (https://learn.adafruit.com/adafruit-class-library-for-windows-iot-core/overview) which meant that all the heavy lifting of the functionality had already been done.
After a bit of playing and getting to understand the I2C bus a little bit, it wasn’t that long until we had functioning bi-directional variable speed motor control and done using a UWP app responding to slider controlled values. This felt suspiciously like progress.
PS4 vs Xbox
Being gamers, using a controller to drive our robot was the only choice we considered. I myself am a Playstation man, whilst Alex although mainly being a PC gamer, has an Xbox. So naturally we re-ignited the age old debate – Playstation or Xbox. I really wanted to get a Sixaxis controller working; I had a few of them kicking around for starters, but mainly I just love them as a controller. So after a bit of Googling, I found the pretty feature rich and well compiled SCPToolkit which appeared to just get the job done, and it worked to a degree, the only problem being that it took full ownership of the Bluetooth adapter in order to work, which wasn’t ideal, especially for testing and debugging.
So after a bit more time searching I discovered that for the small price of my brand loyalty, I could get a controller connected and working on any Windows device basically natively. So 3.4 seconds later, having paid the required “price”, I was writing a message requesting that Alex surrender one of his Xbox controllers to the cause.
I then took the basics from the Windows Dev Center (https://docs.microsoft.com/en-us/uwp/api/windows.gaming.input.gamepad) and set about making a class of my own that will raise events to control various parts of poli:droid.
Sensing the Deadline
With motor control and gamepad control sorted, that just left the small matter of distance sensors and line follow / object detection cameras to deal with.
96 total views, 1 views today