M40_KiwiBot-w-dart

This article appeared in Make: Vol. 40.

This article appeared in Make: Vol. 40.

A robot that can move in any direction immediately is useful for getting around tight spaces and for behaviors like chasing (or fleeing). No matter how fast an R/C car is, there’s no way it can catch something that can instantly go any direction, even sideways. Regular car-style robots can’t drive sideways, but omniwheel robots can!

An omniwheel is a wheel whose tread is made up of a bunch of little rollers. They’re used commercially for things like transfer tables on production lines, and this means they’re cheap and reliable. In this project you’ll use them to build a Kiwi drive robot platform — a three-omniwheel vehicle that can travel in any direction. It’s mesmerizing to watch, and it can even rotate while traveling, so it’s great for turret-type applications too.

If a robot can drive in any direction immediately, it is called holonomic — it has two degrees of freedom on the floor. Cars, where all the wheels line up, can’t move at right angles to their wheels, so they’re not holonomic.

Wheels

Omniwheels can move at 90 degrees to their axis, so you can mount them facing different directions on your vehicle and use a bit of math to still go in a straight line. (That’s where a microcontroller comes in handy.) Like most things in engineering, there are some tradeoffs, which is why we don’t all drive omniwheel cars. They’re slower, sensitive to dust, can take less load — only a few pounds for the wheels we’re using — and they’re less efficient. But in tight spaces they’re the right choice, and a lot of fun!

Our omniwheel robot is a beginner-friendly build that uses an Arduino microcontroller, the new Make: Motor Shield, and standard R/C gear — all of it plug-and-play.

NEW! Make: Motor Shield

Co-developed with Wicked Device, our awesome new motor shield can run 4 DC motors (1.2A–3A max), or 2 steppers and 6 servos. It has current sensing so you can use motors as sensors, and it accepts R/C inputs from standard radio control gear! No soldering required. Maker Shed item #MSMOT01, from makershed.com.

Kiwi Drive: Crack the Code

Your robot has 3 wheels, all pointing in different directions — how on Earth is it going to drive in a straight line? It requires some sophisticated math, so you can’t drive this vehicle without a computer. The Arduino code turns the radio control signals into motor power signals for each motor. But how?

  1. A radio control signal is a little bit like a pulse-width modulation signal (PWM), but not quite. The R/C transmitter creates signal pulses, and the Arduino reads these in on pins Dig4 (R/C input 1, on the right) and Dig8 (R/C input 2, on the left, near the other jumpers).
  2. The Arduino converts the R/C signals to PWM motor drive signals, using the PulseIn command.
  3. Next, the Arduino sketch applies vector math formulas to break the motor signal’s single vector (A–B) into 3 vectors, one for each wheel (w1, w2, and w3). The Arduino works all this out for you on the fly, sends the new drive signals to each motor, and the vehicle drives!

holonomicDirve

How does the math work? Imagine you’re trying to walk from point A to point B. The problem is, the only directions you’re allowed to walk are the red, green, and blue directions. How would you walk? Because of our rules, you can’t walk straight there. One way to do it would be to walk in the green direction until you were level with point B, then walk in the red direction until you arrived at B. You wouldn’t need to walk in the blue direction. (There are many solutions).

This way of walking looks a lot like using vectors, because it is. You don’t need to walk in the blue direction in this example, so let’s make the problem harder: Imagine you’re trying to travel at a certain speed, shown by the length of the line, and you have to use all the lines. So you have 3 lines, all specific lengths and directions. Now there’s only one possible way to combine the red, green, and blue lines to get from A to B (Figure 2). The key thing to understand is that line length represents the speed of each wheel. What we have to do is calculate the length each line needs to be.

The line length represents the wheel speed (WS) of each wheel. We already know how fast we want the vehicle to go (the magnitude of the vector), the direction we want (vehicle angle, or theta, θ) and the angle of each wheel on the vehicle (WA), which was set when we built it (0°, 120°, and 240° — that’s where the √(3/2) comes from in the formulas below).

We can now work out 2 numbers, the x and y vectors:

vx = cos(θ) * magnitude
vy = sin(θ) * magnitude

We plug those into 3 formulas to get the speeds (angular velocities) for each wheel. The first wheel is easy — it only moves parallel to the x-axis, so we just take the x component and throw away the y:

w1 = –vx

The other 2 wheels, w2 and w3, have a component of both x and y vectors:

w2 = 0.5 * vx – √(3/2) * vy
w3 = 0.5 * vx + √(3/2) * vy

Of course, you don’t have to do this math, it’s all done by the Arduino. If you read the Arduino sketch, you’ll see there’s an additional implementation detail to handle whether the results are positive or negative. This is because we want a negative answer to mean “go backward” and a positive “go forward.”