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:

https://github.com/uk-r2-builders-club/droid_driving_course

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: https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/7

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.

Software mixing

Currently, my PS3 controller code uses the channel mixing built into the Sabertooth speed controller. This means that I send it speed and turn commands, and the speed controller mixes these to drive R2 in a tank style, where you vary the speed in the feet to go forward/back or turn.

The problem with this is that not many speed controllers do this, so I am very much tied into using the Sabertooth with my code and the Sabertooth doesn’t support brushless motors. Droid 2 is going to use an ODrive, which has no mixing built in.

Well, until now!

I’ve abstracted out the speed controller portion of the code and added a function that takes the two axis from the drive stick and then outputs the required motor speeds. In this video you can see when I push the stick forward, the top number changes to show the position of the axis, and motor 1 is set a signal of 1, or full speed forward and motor 2 gets -1, or full reverse. (Remember, the motors are flipped)

I got the bulk of the code from here:

https://electronics.stackexchange.com/questions/19669/algorithm-for-mixing-2-axis-analog-input-to-control-a-differential-motor-drive

which uses cartesian to polar (and back) transformations.

I still need to hook up the motors, I’m waiting for some connectors to turn up, to check that it actually works and to do the code changes to send the correct signals, but this is a good step forward.

The other benefit to this change is that now I’m not limited to dual motor controllers, and can look at buying cheaper single controllers with a lot less smart technology built in.

Preston Comic Con tomorrow, so R2 and I are out all day, but if the connectors turn up that I’ve ordered, sunday will be a day of connecting and testing the motors.

She Speaks!

Minimal wiring is done now, enough to get everything powered up and r2_control installed.

A quick flash of an SD card, some tweaks to the install instructions, a few small tweaks to the code to make first boot a little smoother, and shes alive!

Only got audio working for now, but it meant I could test the base code and web interface. I need to get a remote working next I think, and then I can start working on interfacing with the Odrive and Q85 motors. Theres already a python module for that, so that saves a lot of work. Unlike the Sabertooth, which required me to write a python module to interface using serial.

Also, the documentation is now up to date for the latest version of Raspbian, and the code now auto creates basic configs correctly so it will work on first start without having to pre write any configuration files. It should also be easy enough to write a setup script to install required packages and python modules.

And of course, seeing as the Pi is powered up I can now remotely access it to do coding from the comfort of my office.

Inside Out

Most people start by building their droid, then doing the electronics. I’m pretty much doing it all in reverse.

Here you can see all the electronics for R2. The left hand board has all the main power, and the right hand board is the actual electronics. Both boards have edging around them, and will happily sit back to back, making the whole system easily removable. It also means that once removed, it can be opened up as shown to be worked on.

Wiring is nearly complete for the core parts (Pi, Odrive, and Amp), I just need to get an XT60 soldered on to accept a battery. Now, I know I’ve a load of XT60 connectors somewhere in my office, but so far they have eluded me. They must be somewhere *really* safe!

Also, at the top of the pictures you can see the stripped down Q85 motors, getting modified to freeze the clutch system.

Next step it to get power to the Pi at least so that I can start installing the brain. It will also be an opportunity to get the documentation improved, and initial config sorted, incase anyone else wants to use my code.

Oh, and I think I’ve decided on a name for my droid.

R0-S3, or Rose to her friends!

Droid number 2 on its way

I’m going to have to give it a work in progress name, but its a bit difficult without even knowing what dome I’m doing!

But anyway, I picked up the CNC’d styrene kit at R2UK this weekend, and decided to get a picture of everything I’ve gathered so far:

So here you can see:

  • Styrene kit, which includes:
    • Frame
    • Skins
    • Shoulders
    • Legs
    • Ankles
    • Skirt
  • Motors (Q85), tyres, and Speed Controller (ODrive)
  • Power distribution (fuses, wires, switches, relays)
  • Amp and speakers
  • Raspberry Pi
  • DC-DC power convertors.

I’ve also bought cells for another battery, which will be identical (a little more capacity) to R2’s current one. That way they can be switched.

Hopefully I’ll be able to make a start on something this weekend. My first main jobs will be:

  • Motor conversion – The Q85s have to have their clutch frozen and rims turned down
  • Electronics mount – I want all the electronics to be removable for ease of maintenance
  • Frame – Actually put the frame together

So, watch this space for which I decide to do.

R2UK 2019

Back home now after R2UK 2019, and it was such an amazing weekend.

Three days of astromech fun, from talks about their use in the films, to weathering techniques. Driving accuracy course, to mini egg droid wacky races.

Was a bit anxious on the build up to the event, as I’d taken on the task of upgrading all the electronics in the driving course to make scoring automatic, along with registration via RFID. Thankfully however, once I’d done a little tweaking it all seemed to work fairly smoothly.

R2 not to scale! 😉 This is the DeAgostini scale model, done out in R2-KT colours by Paul Whitrow of TRamp

Lots of improvements to be made to it, and repairs after some droids didn’t seem to be avoiding the sensors that they *shouldn’t* be hitting! The actual metalwork took quite a bashing too as some droids thought it was more like a pinball machine.

This weekend is the must do event of the year for me. Its such great fun to hang around with a fantastic group of people. Everyone has something to contribute, and everyone will listen. Lots of advice was both given and received over the weekend, and I dare say motivation for building droids is at an all time high in the UK.

If you want to learn more about the driving course and the automated system I’ve done for it, its all in the git hub repository.

Power Tracking

One of the things I’m quite interested in keeping an eye on (and wish I’d started making notes a lot earlier) is how much battery power I consume at an event.

R2 is quite a heavy droid, with lots of gadgets, and is generally very active at events. I like to drive round and entertain rather than staying in one place. I also may have gone overkill on the battery, tho that being said by never fully depleting the cells I’ll probably get a lot more life out of the packs.

So, I have started a spreadsheet to keep track of how much actual power I use in a given event, to hopefully get some meaningful stats for my droid(s).

Besides standard stuff like the event name and date, I’ll be logging the amount of power put back into the droid after the event, as measured by the charger I’m using. I’ll also log approximate hours the droid was powered up, along with how much of that time he was actually active and moving around.

The spreadsheet will be public, as it may help other builders:

https://docs.google.com/spreadsheets/d/1nrjr1D3ImDR60H5FOuAsUtE8fBIQ3wupA-TJVFXjUx0/edit?usp=sharing

I just have to remember to keep it updated now! 😀

One droid is never enough

The time has come….

R2 needs a friend.

I’ve actually started collecting bits to make my next droid. I’ll be picking up the bulk of the droid in a couple of weeks at R2UK. I’ve already got the motors, speed controller, Pi, and a few other little bits. Most of the other electronics are on order too.

Not 100% certain on what type of dome the droid will have, nor the colour scheme that I’ll use. That can all come later.

What I do know:

  • Brushless Q85 motors (e-bike hub motors).
  • ODrive controller for the motors (a lot cheaper than the Roboteq most people use).
  • Will use r2_control (of course), but be able to swap out to standard RC quickly.
  • Same battery as R2, so I’ll have two identical ones.
  • All electronics will be on a removable board so that I can pull them out to work on outside of the droid.
  • Dome will be wireless with its own (small) battery.
  • Cheaper than R2 (much cheaper!)

I’ll probably also use steel feet to keep the center of gravity nice and low for stability.

So, it will mean a fair bit to do. I’ve never really worked with styrene before and with using both wireless comms for the dome and an ODrive there will be a fair amount of coding work to do on r2_control.

I’m going to try and keep a better build log for this one, with more work in progress pictures.