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.

[wpvideo 31UzGyU6]

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.”

Project Steps

Solder wires to the motors

Then test each motor by connecting it to the battery pack — just twist the wires together — to make sure the wheels turn smoothly. The motor terminal tabs are fragile, so be careful with the wires until they’re glued down.

NOTE: With DC motors, it doesn’t matter which side is positive (+) and which is negative (–). But make sure all 3 motors are wired the same way or your robot will end up driving in circles, because one motor will be going backward.

Attach the wheels

Cut disks from 1/8″ (0.118″) acrylic following the provided template wheel1.svg, and super-glue them together as shown. (I set a small weight on top while the glue dried.)

Then glue the larger disks to the omniwheels, and the smaller disks directly to the motors as shown.

Mount the motors

Use double-stick tape to mount the motors to the platform, following the template base1.svg to make sure the motor shafts are lined up correctly, 120° apart.

Put a dab of hot glue on each pair of wires to hold them down.

Route the motor wires

Drill 3 holes to pass the motor wires through the platform. The platform will want to run up the drill bit, so hold it down firmly.

Route the wires through the holes. Test each motor with the battery pack again.

Add the electronics

Turn the platform over so the motors are on the bottom. On top, stack the battery pack, an insulating sheet of paper or plastic, the Arduino, and the Make: Motor Shield (in that order). I used little rubber feet on the Arduino, but double-stick tape will work as well.

Make sure the motor shield switch is in the Off position, then connect the battery pack to the shield’s + and – pins, and the motors to pins M1, M2, and M3 on the shield.

Connect the receiver

Follow the manufacturer’s instructions to pair your R/C receiver with your transmitter.

Run an R/C servo cable from your receiver to the 2 RC_IN ports on the motor shield. Black (ground) is toward the middle of the shield. I used the rudder (RUDD) and aileron (AILE) connections of my R/C receiver, which map to the left-hand transmitter joystick.

Program the Arduino

Connect your Arduino to your computer with a USB cable. Download the sketch OmniWheelControl.ino from github.com/WickedDevice/OmniWheelControl, open it in the Arduino IDE, and click the arrow button to upload it to your board.

You’ll also need the Motor Shield library; download it at github.com/WickedDevice/WickedMotorShield then go to the Arduino IDE and install it by selecting Sketch → Import Library.

Add a cover (optional)

You can make one out of pretty much anything you like the looks of.

If you have access to a laser cutter, download our files for laser-cutting a basic box from 1/8″ (0.118″) acrylic, sized to contain a 6×AA battery pack, the Arduino, the motor shield, and the R/C receiver.

Take it for a test drive

The motor shield has 2 important jumpers to keep in mind. BEC provides power to the radio receiver, so you don’t need an additional power source. EXT provides power to the Arduino using the motor power source, in this case the battery pack. Make sure both these jumpers are connected and that there are fresh batteries in the holder.

TIP: When removing a jumper, don’t try to store it away from the board — it’s tiny and easy to lose. Instead, disconnect it from one pin only, and let it hang. This breaks the connection, but keeps the jumper handy if you want to reset it.

The switch on the motor shield powers up the motors — this is so you can experiment with a robot on your desk without having it drive off suddenly. Turn it on now. Turn on your transmitter and try moving the sticks. If everything’s working, you should now have a working R/C holonomic robot!

NOTE: When not operating the Robot, disconnect the power jumpers and turn off the motor power switch to save batteries. (I got 6 hours of near-continuous use out of 4 Duracells at Maker Faire, so it’s pretty efficient.)

Going further

Once you’ve driven your robot around a bit, you’ll probably notice that it can be hard to tell front from back. An easy fix is to attach an arrow, a face, or some other prominent decoration on one side.

For more of a challenge, add a Nerf gun to the vehicle. Since it can “strafe” sideways without turning, it can slide out from cover, shoot, and then slide quickly back. Use a servo-operated mechanism to pull the trigger.

Try adding a camera setup for spying, FPV driving, or even a telepresence robot. Or make a pair of kiwi bots to play laser tag or robot soccer.

Finally, let’s talk about a scaled-up Kiwi drive. The math and the code should work with vehicles of any size, and bigger omniwheels (like the Kornylak RW27) can easily support a person on a set of three. R/C mobile barstool, anyone?

Killer Kiwis

What else can you do with a Make: Motor Shield and a Kiwi drive robot? Try these ideas — and share yours in the comments below, or with #makeprojects.

Laser battle bots — Use one R/C stick to drive and the other to rotate, just like your favorite first-person-shooter video games. On each bot, add a laser pointer and a light sensor, protected inside a short piece of pipe so that only direct hits are detected!

“Dr. Evil” frickin’ rotating chair — Scale up to big omniwheels, 12V motors, and an oversized R/C joystick to build a go-anywhere villain’s throne that also spins on command (or, like the original, randomly). The math and the code should work with vehicles of any size, and bigger omniwheels (like the Kornylak RW27) can handle 200lb loads apiece.

Ball balancing robot — Use brushless DC motors and add an IMU to build an astonishing bot that drives any direction while balancing on top of a ball. You’ll have one remaining DC motor connection and 6 servo connections to build functionality on top. Serve beverages like Artoo on Jabba’s sail barge?

Cat Tormentor — Chase kitty with your basic Kiwi bot, and mount a laser pointer on a two-servo pantilt rig to give kitty something to chase too.