Show your driving skills

At last years R2UK event, the driving course was introduced. Originally by Colin Barker and Lee Towersey, built out of wood with 3d printed bumpers it went down a storm. It got rolled out a few times over the course of the year and I added the times to the MOT site.

I’m not one to let things lie tho. Times were manually entered into a spreadsheet, with any penalties added in by hand.

Not only that, the course took quite a while to strip down and put up due to all the power cables needed for the bumpers and gates.

This was where I come in. I was sure that I could help streamline the process and it was a nice project to work on. Along with my work, Mark Leigh and his brother started working on rebuilding the course out of aluminium box section to make things a bit sturdier.

I at least wanted to remove the need for all the cables going to the sensors, as this was a big pain in the setup, and was a bit of a mess. Whilst I was at it I came up with the idea that we could easily make them wireless so that when they’re triggered it automatically reports back to a central hub.

From there the ideas expanded! I didn’t want to have to redesign and reprint all the parts so everything had to reuse the physical bits. A Raspberry Pi would be used as a central hub to keep track of the times.

In the end I used a Wemos D1 Mini for all the sensors, as they were cheap and had more than enough I/O pins for what was needed. Both the bumpers and the slalom gates have the same electronics in them. The timing gates that start/stop the clock were microswitches but had to be reset each run so I switched these for ultrasonic range finders.

Finally, the clock got a major upgrade. Initially it just sent a signal to the Pi to say that the clock had started, but I quickly ran into latency issues. Due to this, the main timer for everything is not the Pi but the big clock itself. The timing gates are hardwired in and when they are triggered the clock sends the time back to the Pi in its API call.

So the Pi is using the same Flask python module that r2_control is using, I was already fairly familiar with it and it made creating an API very easy. The Pi is responsible for displaying and storing all the details about the runs, with Pi Zeros being used to display the various pages on monitors around the course.

As a final touch, I went really fancy! To register what droid and driver are about to do the course, they can now swipe an RFID tag. I built a simple reader with screen so that once the droid is ready to start they just swipe their tag over the reader. At R2UK there were some issues with writing tags which have since been solved. Even better, the new Builders ID cards have RFID chips built in.

Video courtesy of Rob Howdle

It took a couple of hours to work out some bugs on the course, some my own fault and others hardware limitations (seems the Pi’s onboard wifi wouldn’t allow more than 10 clients) but I worked around them and after that the course seemed quite popular again. Just need to write some better documentation and program up everyone’s ID cards.

Next step is to add another type of sensor… a shock sensors. Some people started getting quite competitive and the course was starting to take a few knocks. So a couple of accelerometers will hopefully make it back into a driving accuracy course!

All code is in the Builder’s github repository:

Motor Movement!

Well, the connectors didn’t turn up on Saturday, but they did turn up today! So after a bit of crimping, and a bit of soldering (and a few mistakes, but we won’t go into that) I had a couple of cables made up to allow me to connect the Q85 motors to the ODrive.

Here is one of the sets of cables. They consist of the red wires in the back that go to an MT60 connector that carries the main signal to the motors, and then another bunch of wires that come from the hall effect sensor that is embedded in the motor. This tells the controller where the motor is in its cycle, so that it knows which coils to energise.

Also needed were some capacitors across the sensor terminals to cut down on some noise. Instructions for doing this are here:

With all that in place, I gingerly powered it all up and set about calibrating everything. I followed a guide on the main astromech forum, along with the odrive guide for hoverboards (same principal as driving an astromech it seems). It took a bit of trial and error, that I’m hoping to iron out into a proper tutorial at some point, but the motors were eventually running!

The mixing that I’d done in software all looks like its working as intended. I can also bump the speed up incrementally, as I can with R2, but with a lot more control and accuracy.

I do need to change the ramping settings on this, which I may even make changeable on the fly from the controller. Also the multiplier may need some tuning to set top speed, but that will require some testing in situ. I need to push my changes back into github, and make sure that R2 still works with the new code.

I think this brings the electronics to a good resting place for now. Just going to tidy up some of the cabling and add a volt/current meter. Its time to concentrate on making the actual droid. So this weekend it will be time to don the breathing mask and start glueing everything together.