Getting started with Cubelets, a first tutorial

Twenty Standard kit for Cubelets

1 - A first robot

A first robot with Cubelets

A first robot with Cubelets

You need a gray Cubelet, a black Cubelet, and a clear Cubelet. Snap them together. You’ve built a robot!

Every robot needs power. The blue-gray Cubelet is the Battery Cubelet (hint: the Battery Cubelet has an on-off switch. Make sure it’s on before you start to play; turn it off when you’re done.).

A robot is a machine that senses its surroundings and acts on its surroundings. So every robot needs a Sense Cubelet and a Action Cubelet. Sense Cubelets are black and Action Cubelets are clear.

Snap together a Battery Cubelet, a Knob Sense Cubelet, and a Flashlight Action Cubelet. The Flashlight Action Cubelet lights up. You control its brightness by turning the knob.

It dims when you turn the knob counterclockwise (to the left) so you could call it a dimbot.

2 - Try swapping Sense Cubelets

A robot made of 3 Cubelets

Now take out the Knob Sense Cubelet. Put a Brightness Sense Cubelet in its place. You still have a flashlight robot, but now its brightness depends not on the knob, but on the light around it.

Test it: Cover the Brightness Sense Cubelet with your hand (Hint: one face of every Sense Cubelet has the actual sensor. It’s the different face without the magnet connectors.)

The flashlight dims. Move your hand away and the flashlight gets brighter. You can swap any Sense Cubelet for any other Sense Cubelet.

You’ll still have a robot, just a different robot. In the dimbot we swapped a Brightness Sense Cubelet for a Knob Sense Cubelet to make a light-sensitive dimbot.

3 - Try swapping Action Cubelets

Swapping of a Cubelet Action

Usage of the Bar Graph Cubelet

We tried swapping Sense Cubelets. You can also swap Action Cubelets. Put a Drive Action Cubelet in place of the Flashlight Action Cubelet. Now your robot has a Brightness Sense and a Drive Cubelet (and of course, a Battery Cubelet).

This robot moves when it senses light. In a bright room it’s a fast robot. In a dark room it’s a slowbot.

Try more swapping. What if you use a Speaker Action Cubelet instead of the Drive Action Cubelet? (canarybot)

What about a Distance Sense Cubelet instead of a Brightness Sense Cubelet? (timidbot). Try turning the Drive Action Cubelet so the robot goes backward instead of forward (friendlybot or timidbot).

4 - How numbers flow

Understand data flow into Cubelets

Each black Sense Cubelet senses some property of its surroundings and turns it into a number. The Knob Sense Cubelet senses how much you rotate its knob. Turn the knob all the way counterclockwise (left), and the Knob Sense Cubelet produces a small number. Turn it clockwise (to the) right to produce a big number.

Each Sense Cubelet tells its number to all its neighbors.

The Brightness Sense Cubelet senses how light the room is. In a dark place the Brightness Sense Cubelet produces a small number. In a light place, the Brightness Sense Cubelet produces a big number.

Each Action Cubelet takes numbers from its neighbors and turns the numbers into an action.

The Flashlight Action Cubelet takes a number and lights its lamp. A big number makes the lamp bright. A small number makes the lamp dim.

Think of the number as hopping or flowing from one Cubelet to the next. Numbers are flowing through the Cubelets of the robot from Sense Cubelets to Action Cubelets all the time. That’s what makes the robot behave the way it does.

Numbers don’t flow through Sense Cubelets. Each Sense Cubelet produces its own number, so it doesn’t pass numbers from its neighbors.

5 - Using the Bar Graph Cubelet to see the numbers

 The Bar Graph Cubelet

You can use the Bar Graph Action Cubelet to understand what’s going on inside your robot—to show the numbers flowing from Cubelet to Cubelet.

Attach the Bar Graph Action Cubelet to any Cubelet in a robot. The Bar Graph Action Cubelet shows how big the number is. If the number is big, all the cells in the bar graph light. If the number is small, only a few light up. If the number is very small (or zero) no cells light at all.

Try it. Build a simple brightness gobot with a Brightness Sense Cubelet and a Drive Action Cubelet. Attach the Bar Graph Action Cubelet to one of the Cubelets. If there’s a lot of light, the Bar Graph Action Cubelet will show a full bar (and the Drive Action Cubelet will move fast). If there’s not much light, the Bar Graph Action Cubelet won’t light much.

You don’t need the Bar Graph Action Cubelet to understand what’s going on with this simple robot. But with bigger and more complicated robots, the Bar Graph Action Cubelet can help.

6 - How you arrange the Cubelets makes a difference

Structural design with Cubelets robots Structural design with Cubelets robots

This robot comes in different versions because you can put the Drive Action Cubelet into the robot in different ways. One way, the robot goes straight. The other way, the robot goes around and around. You could call it a turnabot.

It’s not just which Sensor and Action Cubelets you choose. It’s also how you place them in the robot. The same Cubelets arranged in a different physical configuration make different robots.

Place the Brightness Sense Cubelet so its sensor face points down. Now it doesn’t see the light. This gobot is a nogobot. No matter how bright the room is the robot won’t go. Its Brightness Sense Cubelet doesn’t sense the light.

Try placing the Brightness Sense Cubelet to face in different directions. How does that affect the robot’s behavior?

7 - Stability

Stability of the robots made of Cubelets Stability of the robots made of Cubelets

Stability of the robots made of Cubelets Stability of the robots made of Cubelets

Some robots are more stable than others. Try building a simple gobot with a Distance Sense Cubelet and a Drive Action Cubelet. It’s stable if you build a train with all three Cubelets (the Battery Cubelet, the Drive Action Cubelet, and the Distance Sense Cubelet) arranged in a row.

The Distance Sense Cubelet produces a big number when something gets near it. You can chase this timidbot around with your hand. When you get near the timidbot, it runs away.

If you build this robot as a tower instead of a train, it still works, but it’s no longer stable: Approach the Distance Sense Cubelet and the Drive Action Cubelet starts moving. Then the tower falls over.

You can fix this: Add a Cubelet at the bottom next to the Drive Action Cubelet. Any Cubelet will do, but try one of the green Cubelets, either a Passive Cubelet or a Cubeleter Cubelet. Notice that you can build this gobot in different ways. If the Distance Sense Cubelet faces the same direction that the Drive Action Cubelet moves, your robot comes toward your hand. If you turn the Distance Sense so it faces the opposite direction, it moves away. You can chase it around with your hand.

8 - A Sense Cubelet can control more than one Action Cubelet

Cubelets sensors and actuators

Build a simple gobot with a Brightness Sense Cubelet and a Drive Action Cubelet: It goes when it senses light. Add a Speaker Action Cubelet. Now it goes and chirps when it senses light.Add a Flashlight Action Cubelet. Now it goes and chirps and lights up when it senses light.

Add all the Action Cubelets you want. They all respond to the same Brightness Sense Cubelet. With a lot of light on the Brightness Sense Cubelet all the Action Cubelets will act a lot. Without light on the Brightness Sense Cubelet the Action Cubelets won’t do much.Build a lighthousebot that uses the Knob Sense Cubelet to control the speed and the brightness of a rotating robot tower.

9 - Think Cubelets

 

You’ve met the Battery Cubelet, and the black Sense Cubelets and the clear Action Cubelets. It’s time to meet the colored Think Cubelets. The simplest Think Cubelet is the red Inverse Think Cubelet.

Think Cubelets are the colored Cubelets.

Let’s go back to the light-sensitive dimbot. It has a Brightness Sense Cubelet and a Flashlight Action Cubelet. (It also has a Battery Cubelet of course but we’re going to stop mentioning the Battery Cubelet because every robot has one). The dim-bot made a silly flashlight. Its lamp is bright when it’s in a bright room, and dark when it’s in a dark room. We’d prefer a flashlight robot that turns on when it’s dark, and off when it’s light.

10 - The Inverse Think Cubelet

The Inverse Cubelet

Put the pink Inverse Cubelet between the Brightness Sense Cubelet and the Flashlight Action Cubelet.

Remember the number flow story: Every Sense Cubelet produces a number. The Brightness Sense Cubelet produces a big number when it senses a lot of light. It tells that big number to its neighbor (the Flashlight Action Cubelet), which turns the big number into a bright light.

The Inverse Think Cubelet turns a big number into a small number (and a small number into a big number).

When we put the Inverse Think Cubelet into the robot, numbers pass through it from Sense Cubelet to Action Cubelet. When the Brightness Sense Cubelet senses a lot of light it produces a big number, which the Inverse Think Cubelet turns into a small number, and passes to the Flashlight Action Cubelet, which dims its lamp.

It also works the other way. When you put the robot in a dark room (or shade it with your hand) the Brightness Sense Cubelet produces a small number. The Inverse Think Cubelet turns it into a big number, and the Flashlight Action Cubelet makes its light bright: A nightbot that turns on in a dark room, and turns off in a bright room.

Swap out the Flashlight Action Cubelet and put a Drive Action Cubelet in its place. Now you’ve built a robot that goes when it’s dark, and stops when it’s light.

The Inverse Think Cubelet in this night-gobot inverts the number from the Brightness Sense Cubelet before passing it to the Drive Action Cubelet. In low light, the Brightness Sense Cubelet produces a small number; the Inverse Think Cubelet inverts it to a big number, which makes the Drive Action Cubelet go fast. In bright light, the Brightness Sense Cubelet produces a big number, which the Inverse Think Cubelet inverts to a small number, so the Drive Action Cubelet moves slowly, or not at all.

11 - Differential drive

Differential drive of a Cubelet robot

Remember the go-bot that uses a Distance Sense Cubelet to control a Drive Action Cubelet? Put two gobots together on a robot (facing the same way) and you’ve built a steeringbot.

The steering-bot has two gobot towers with a Battery Cubelet in between. They each act independently. (Each Sense Cubelets does not pass the value from the other Sense Cubelet.) Each gobot tower responds to an object (like your hand). Put your hand near the right side gobot tower and its Drive Action Cubelet will go, while the left side’s Drive Action Cubelet stays still (or goes slower).

When one Drive Action Cubelet moves and the other doesn’t, or turns the other way, the steeringbot turns. That’s called “differential drive steering”.

12 - Action Cubelets average their inputs

Cubelets

Cubelets

We saw how one Sense Cubelet can control several Action Cubelets. If your robot has two Sense Cubelets and one Action Cubelet, which one controls the robot?

Build a testbot with two Distance Sense Cubelets and a Bar Graph Action Cubelet between them.

The Bar Graph Action Cubelet shows a low value if neither Distance Sense Cubelet senses an object.

Put one hand in front of each Distance Sense Cubelet. They will both produce a high number. The Bar Graph Action Cubelet shows a high number.

Now put your hand in front of just one of the Distance Sense Cubelets. This Cubelet now produces a high number while the other Distance Sense Cubelet produces a low number. The Bar Graph Action Cubelet takes both numbers and averages them. It shows a number that is halfway between the numbers it gets from its two Distance Sense neighbors.

13 - Gradients: diffusion

Gradient of data with Cubelets

Gradient of data with Cubelets

If your robot has an Action Cubelet right between two Sense Cubelets, the Action Cubelet averages the numbers the two Sense Cubelets tell it.

If one Sense Cubelet is farther from the Action Cubelet than the other, then the closer Cubelet has a stronger effect. You can test this using the Bar Graph Cubelet.

Build a robot with the two Distance Sense Cubelets on either end and two Passive Cubelets between them. Add a Bar Graph Action Cubelet to one of the Passive Cubelets.

Now play with your robot: put one hand in front of each Distance Sense Cubelet, so that the Bar Graph Action Cubelet reads high (all its cells light). Take your hand away from the Distance Sense Cubelet that is farther from the Bar Graph Action Cubelet. Now put your hand back and try the other Distance Sense Cubelet. The Bar Graph Action Cubelet responds more strongly to the closer Distance Sense Cubelet.

An Action Cubelet acts according to the average of the Sense Cubelet numbers it gets, weighted by the distances (number of Cubelets from Sense Cubelet to Action Cubelet, or “hop count”) they’ve travelled.

14 - Use the Minimum Cubelet as a switch

Use the Minimum Cubelet as a switch

Suppose you want to make a light-sensitive go-bot—it goes when it sees light. But you also want to be able to turn it off. Of course, you can just switch off the battery, or take out the Battery Cubelet. But you can also use Cubelets to make an on-off switch. Here’s how.

An ordinary light-sensitive go-bot just has two Cubelets: a Brightness Sense Cubelet and a Drive Action Cubelet (plus a Battery Cubelet). The number from the Brightness Sense Cubelet tells the Drive Action Cubelet how fast to go. A brighter light, a bigger number, a faster go-bot.

Take out the Brightness Sense Cubelet and put a Minimum Think Cubelet in its place. This Minimum Think Cubelet tells the Drive Action Cubelet how fast to go. It takes all the numbers its Sense Cubelet neighbors give it, and chooses the smallest (minimum) of those numbers. This smallest number is what it tells its Action Cubelet neighbors.

Attach the Brightness Sense Cubelet to the Minimum Think Cubelet, and also attach a Knob Sense Cubelet. Now, if you turn the Knob Sense Cubelet all the way counterclockwise (left), then the Minimum Think Cubelet tells the Drive Action Cubelet, “zero”, because this is the smaller of the numbers it’s getting. If you turn the Knob Sense Cubelet all the way clockwise (right) then the Minimum Think Cubelet will tell the Drive Action Cubelet whatever number it’s getting from the Brightness Sense Cubelet. With the Minimum Think Cubelet, the Knob Sense Cubelet acts like an on-off switch.

15 - Use the Cubeleter Cubelet to separate two parts of a robot

Cubelet de blocage

The dark green Cubeleter Cubelet passes power but does not allow numbers to flow through it. Use it to build a robot with two parts that don’t talk to each other. Here’s an example.

One half of the robot is a lighthousebot with a spinning light; the other half is a robot that chirps when it sees the light from the lighthousebot.

The lighthousebot is Knob Sense Cubelet that controls the speed of a Rotate Action Cubelet, and on top of that, a Flashlight Action Cubelet that points outward (sideways). When you turn the Knob Sense clockwise (to the right), the light goes on and spins.

Now add a Blocker Cubelet to the base (say, on the Knob Sense Cubelet). Then, on the other side of the Blocker Cubelet add a Speaker Action Cubelet, and on top put a Brightness Sense Cubelet with its sensor face pointing toward the rotating light. The Speaker Action Cubelet chirps (the rooom is bright), and every time the rotating light beam passes over the Brightness Sense Cubelet, the Speaker Action Cubelet responds by chirping faster.

To the right of the green Blocker Cubelet is a Lighthouse Cubelet: a Knob Sense Cubelet, a Rotate Action Cubelet and a Flashlight Action Cubelet. The Flashlight Action Cubelet spins when you turn up the Knob Sense Cubelet. On top of the green Blocker Cubelet is a Speaker Action Cubelet and a Brightness Sense Cubelet. When light from the spinning Flashlight Action Cubelet strikes the Brightness Sense Cubelet, the Speaker Action Cubelet chirps faster.

16 - Troubleshooting

Does it have a Battery Cubelet?
Every robot needs a Battery Cubelet.

Is the Battery Cubelet turned on?
If the Battery Cubelet is turned on then the Battery Cubelet’s LED is lit. If it’s not lit, try turning it on with the switch. If that doesn’t work, try charging the Battery Cubelet’s batteries.

Is the LED light on in each Cubelet?
Occasionally Cubelets don’t make a good connection at their faces. Try wiggling the Cubelets gently to seat them. Look at the LEDs to see which Cubelets are connected.

Does your robot have a Sense Cubelet and an Action Cubelet?
Every robot needs at least one Sense Cubelet and one Action Cubelet. Without the Action Cubelet, it won’t do anything. Without the Sense Cubelet, it won’t know what to do. With a larger robot that’s not working, try taking away Cubelets to remove complexity. Simpler smaller robots are easier to understand, so they’re easier to debug. If you think one of your Cubelets is broken, try using it to build a very simple robot. For example, if you think a Drive Action Cubelet is broken, try using it to build a simple go-bot with a Knob Sense Cubelet.

Cubelets connection
Each connecting face of a Cubelet has three conductors. The outer ring and magnets conducts ground; the inner metal ring, power; and the center pin conducts data from one Cubelet to the next. These three conductors must connect with their neighboring counterparts in order for two Cubelets to communicate.

17 - A note to experienced programmers

Experienced programmers often ask, “So which Cubelet is the IF-THEN Cubelet”. Or, “Which Cubelet is the CPU?” We understand the questions, but that’s not how Cubelets work.

Building robots with Cubelets is different from the procedural programming (in C, Java, or BASIC) that you may know. In procedural programming, a robot’s behavior results from executing a sequence of instructions in the robot’s “brain” (usually a single microcontroller).

Cubelets operate with a completely different model: distributed programming.

Every Cubelet has a microcontroller. The robot’s behavior results from local interactions between Sense, Think, and Action Cubelets and the numbers flowing from Cubelet to Cubelet.

There’s no single “brain” Cubelet, and there’s no sequence of instructions. There are no variables, functions, or procedural logic. Instead, in Cubelets, the robot is the program. The way you put the Cubelets together determines the way numbers flow from Sense to Action Cubelets, and this determines your robot’s behavior.

 

The original version of this page is on the website of the manufacturer of the Cubelets : http://www.modrobotics.com/cubelets_getting_started_guide