Gadget

2010/05 – 2010/08

1 Introduction

Gadget is a fully autonomous robot that follows a black tape on a white surface at high speed. It uses eight QRD 1114 sensors to track the position of the tape. An onboard TINAH board using an ATMega 128 processor controls the robot using a simple state machine.

Photo of Gadget
FIGURE 1 Photo of Gadget at speed.

Gadget was created as a team of four in the second year of my undergraduate curriculum for the course “Phys 253 — Introduction to Instrument Design”. My team included Russell Vanderhout, Adrien Emery, and Billy Fung.

Photo of me
FIGURE 2 Photo of me working on the CAD design of Gadget, with Adrien doing some soldering work in the background.

2 Design

Gadget features many interesting design choices not found in the robots of other teams.

Render
FIGURE 3 Render of Gadget, half clay render and half with materials.

2.1 Mechanical design

I did most of the mechanical design for the robot. It took several iterations before we got it working satisfactorily.

Render of Gadget
FIGURE 4 Render of gadget.

2.1.1 Chassis

Render of Chassis version 4 and 2
FIGURE 5 Render of Gadget, final version shown on the left, and an intermediate version (Chassis version 2) shown on the right.

The chassis is manufactured from a single sheet of 22-gauge steel cut using an OMAX waterjet cutter.

Only chassis versions 2, 3.5, and 4 were actually manufactured. The latter two were powder-coated red.

Chassis version 3.5
FIGURE 6 Chassis version 3.5, an intermediate design.
Schematic of all chassis versions
FIGURE 7 Schematic of all chassis versions to scale.

2.1.2 Drivetrain

Gadget has two transversely mounted electric motors mated to a 13-tooth sprocket. The sprocke transmits power to a 24-tooth differential gear via a timing belt. The differential gear allows full power to be transmitted even during turns.

Render of drivetrain
FIGURE 8 Render of drivetrain and rear wheels
Render of differential gear
FIGURE 9 Render of differential gear and drivetrain

The differential gear was manufactured from several pieces of laser-cut acrylic. A video of the cutting process can be found on Youtube.

2.1.3 Steering

The steering is controlled by a servo motor. Front wheels are mounted on laser-cut acrylic parts. The usage of ball bearings allows the front wheels to rotate smoothly and frictionlessly, whilst allowing precise steering.

Render of front wheel assembly
FIGURE 10 Render of front wheel assembly and steering mechanism

The steering mechanism is carefully designed according to the Ackermann geometry. A priority was to improve the mechanical advantage of the servo motor so that a small movement of the servo would result in a large change in steering angle, so that performance is less bottlenecked by the speed of the servo motor. As it turns out, however, performance is still bottlenecked by the servo motor and we had to buy a new one with a response time almost twice as fast, and with more torque. The new servo decreased our lap time from around 18 seconds to 12 seconds.

One of the things most prone to failure was the linkage connecting the two front wheels. This linkage was originally cut in 24-gauge steel, then in 22-gauge, and then ultimately in 18-gauge.

2.1.4 Shell

Each robot is required to have an infrared emitter mounted at a height of six inches. We designed a shell to mount the said emitter as well as for cosmetic purposes.

Render of completed robot
FIGURE 11 Render of completed robot with shell cover.

A rear spoiler was spot-welded on for fun. Both the shell and the spoiler are made in 24-gauge steel, and powder-coated black. A red racing stripe was added using red tape.

2.1.5 Wheels

The wheels on Gadget were made from polycarbonate, and the tyres from rubber. Both are cut using the waterjet cutter. The design of the rear wheels evokes the famous five porthole wheels on the Lamborghini Countach. The rear tyres flex in a similar way to the Michelin Tweel to improve ground contact.

Side render of Gadget
FIGURE 12 Side render of Gadget focussing on the wheels.

2.2 Electrical Design

The electrical design was mostly done by Billy and Adrien. Billy was largely responsible for designing and soldering the comparator circuit for the QRD1114 sensors for tape tracking; Adrien was largely responsible for the circuits involving the rangefinder and motor control. Adrien also designed and constructed the infrared detector and filter, although this was not used.

2.2.1 QRD1114 comparator circuit

The comparator circuit receives the analog signal of the QRD1114 and outputs either digital HIGH or LOW based on a threshold that is adjusted using a potentiometer. It uses one dual comparator for every two QRD sensors. Although it was originally planned to have eight potentiometers, one to calibrate each QRD sensor, only four were used in the end. This was because, after soldering three potentiometers, it became apparent that QRD1114 sensors were sufficiently alike that only one potentiometer would suffice to calibrate them all. Besides, tuning the potentiometer is a lot more tedious than simply giving the sensor a physical nudge with a popsicle stick, which usually accomplishes the same effect.

Render of QRD1114 comparator circuit
FIGURE 13 Render of QRD1114 comparator circuit.

2.2.2 Rangefinder circuit

Gadget is equipped with an infrared rangefinder at the front to detect obstacles. Adrien soldered the rangefinder comparator circuit to convert the analog signal of the rangefinder to either HIGH or LOW to indicate the presence of an obstacle.

A low-pass resistor-capacitor filter was constructed to mitigate the issues of noise from extraneous infrared sources. In addition, the rangefinder is encased in a solid metal block that is grounded to reduce noise.

Render of rangefinder and its circuit
FIGURE 14 Render of rangefinder and its circuit.

2.2.3 Infrared sensor

Adrien soldered a sallen-key band pass filter, amplifier, dc-block, and peak detector for the infrared sensor circuit. Since an infrared emitter is mounted on each robot, such an infrared sensor would allow Gadget to avoid other robots. However, this idea was scrapped in favour of the rangefinder, which could avoid all obstacles.

3 Software

The code for Gadget is written in the Wiring language for the UBC Engineering Physics custom-designed TINAH board with the Atmel ATMega128 16MHz microprocessor, similar to that of the more famous Arduino systems.

Gadget sitting on my workbench
FIGURE 15 Gadget sitting on my workbench in front of the laptop and monitor used for developing software.

The code was jointly written by Russell Vanderhout and me and can be accessed here in the same condition as was used on competition day.

Source code

3.1 Tape-following algorithm

Flowchart of algorithm
FIGURE 16 Flowchart of algorithm for following the tape.

Gadget has more tape-sensing QRD1114 sensors than any other robot of its year, and thus there ought to be an algorithm to give it some advantage over its competitors. To efficiently read and process all eight sensors, Russell devised the “Two-Eight” method which has two states:

In each iteration of Two Sensor Scan, if at least one sensor is on, it sends an instruction to the steering servo motor. The tape is either exactly under one sensor, with eight different possibilities, or in between two adjacent sensors (both of which read positive), with seven different possibilities. So, there are fifteen possible angles. Hence, the instruction sent to the angle is the appropriate one from a lookup table containing 15 angles.

This is essentially proportional control with a nonlinear actuation curve, possible only through the large number of sensors we have.

anglesensor 0sensor 1sensor 2sensor 3sensor 4sensor 5sensor 6sensor 7
-37^\circ10000000
-21^\circ11000000
-16^\circ01000000
-12^\circ01100000
-9^\circ00100000
-5^\circ00110000
-3^\circ00010000
0^\circ00011000
+3^\circ00001000
+5^\circ00001100
+9^\circ00000100
+12^\circ00000110
+16^\circ00000010
+21^\circ00000011
+37^\circ00000001
Table 1 Actuation angles as a function of sensor input signals.

3.2 Lane-changing

The track of the Roborace has two lanes. Avoiding obstacles entails detecting the obstacle and then switching to the other lane. A boolean variable keeps track of the lane on which Gadget is travelling, and once the rangefinder detects an obstacle for longer than some threshold, the following algorithm executes:

  1. Set the servo motor to an angle such as to steer towards the other lane.
  2. Proceed at this steering angle until all eight sensors do not detect the tape anymore.
  3. Set the servo motor to go straight.
  4. Proceed until the tape track is detected on the side of the robot away from the new lane. The reason for this slight “overshoot” is because if the tape was on the same side as the new track, the standard tape following algorithm would make it forcefully steer into the new track (even though it is already angled to enter this track) and result in unacceptable oscillations and even failure of the tape-following algorithm. However, overshooting slightly would result in an elegant and smooth lane re-entry.

3.3 Motor control

Gadget is capable of very high speeds because it uses more powerful motors (and it has two of those) than most other robots. However, the servo motor requires time to respond; as such, moving at too great a speed may cause oscillations since the robot is simply unable to steer fast enough. Hence, the robot is usually run at roughly 70% pulse width modulation duty cycle.

To avoid skidding, the robot brakes at the start of turning, by setting the duty cycle to some value determined by a lookup table. After a predetermined braking time, the robot accelerates at full duty cycle for a short time before returning to its usual speed.

3.4 Optimizations

The source code uses many lookup tables and inlines several functions. It can scan the tape over 15,000 times per second.

4 Performance

Our friend Anson Liang took a video of our robot giving some idea of its speed, although in the video it suffered from some oscillation.

It could lap the inner track in 11 seconds and the outer track in 12 seconds. The only robots that are consistently faster are Adiabatmobile (8 seconds) and Elvis (10 seconds).

Gadget is capable of detecting and avoiding obstacles around 30 cm ahead of it. However, despite our efforts to shield the rangefinder, it often activated due to ambient infrared noise. For this reason, it failed to work properly during the actual race. However, right after the race, we unplugged the rangefinder and the robot ran about 100 laps flawlessly at high speed, impressing the audience.

Gadget in race condition
FIGURE 17 Gadget in race condition right after the main event.