Make a Lidar-Guided Robot With the GiggleBot

2.8K34

Intro: Make a Lidar-Guided Robot With the GiggleBot

In this tutorial, we are making the GiggleBot tackle the difficulties of a maze.

We are mounting a servo on the GiggleBot onto which we attach a distance sensor. While running, the servo is going to rotate back and forth so that the distance sensor can measure the distance up to each obstacle. This works much like a LIDAR sensor which is usually much more expensive.

At the same time, the GiggleBot is sending this data to a remote BBC micro:bit that displays onto its 5-by-5 matrix of LEDs its relative position to the obstacles.

Your job is to be able to navigate the GiggleBot only by looking at what it's shown on the other BBC micro:bit. To control the GiggleBot, the buttons on the remote BBC micro:bit are used.

That sounds like fun! Let's get down to it, shall we?

STEP 1: Required Components

We're going to need:

  1. A GiggleBot .
  2. A battery pack for the BBC micro:bit. It comes along with a BBC micro:bit in its package.
  3. x3 AA batteries for the GiggleBot.
  4. A Grove cable to connect the distance sensor to the GiggleBot.
  5. A Servo kit from DexterIndustries.
  6. x3 BBC micro:bits. One for the GiggleBot and one used to control the robot from far away.
  7. A Distance Sensor from DexterIndustries.

Get the GiggleBot robot for the BBC micro:bit here!

STEP 2: Assembling the Robot

To make the GiggleBot ready to be programmed, we need to assemble it, although there's not much needed to be done.

Insert the 3 AA batteries in its compartment underside the GiggleBot.

Assemble the servo package. To its rotating arm of the servo, use the last hole of it to fix the servo onto the GiggleBot's front connectors. You can use a screw and/or some wire to make it more stable in its place. Or you can hot glue it to the board. In my case, I used a screw and short wire to tie the servo arm to the GiggleBot board.

When mounting the servo arm onto the servo, make sure the servo is already set to position 80. You can do that by calling gigglebot.set_servo(gigglebot.RIGHT, 80). You can read more about that here .

Next, place the distance sensor on the front side of the servo package and fix it like in the above example.

Finally, connect the distance sensor with a Grove cable to any of the 2 I2C ports and the servo motor to the right port sitting on the GiggleBot - the right port is mentioned on it.

STEP 3: Create Your Own Maze - Optional

In this case, I have used a bunch of boxes to create a closed loop track, similar to a NASCAR one.

At this step, you can get really creative and make it how twisted you want or make it super long because it's really up to you.

Or if you don't want a track at all, you can put the GiggleBot in a kitchen or a living room for example - that should be good enough because there are plenty of walls and obstacles you still need to avoid.

STEP 4: Setting Up the Environment

In order for you to be able to program the BBC micro:bit in MicroPython, you have to set up an editor for it (the Mu Editor) and set the GiggleBot MicroPython Runtime as its runtime. For that, you have to follow the instructions on this page. As of this moment, version v0.4.0 of the runtime is used.

STEP 5: Programming the GiggleBot - Part I

First, let's set up the GiggleBot's script. This script will make the GiggleBot rotate its servo motor 160 degrees (80 degrees in each direction) while at the same time take 10 readings from the distance sensor per turn.

When turned on, the GiggleBot will be standing by until it receives a command from the remote control. There can be only 3 commands: move forward, to the left or to the right.

Note: The following script might have missing whitespaces and this seems to be due to some issue in displaying GitHub Gists. Click on the gist to take you to its GitHub page where you can copy-paste the code.

STEP 6: Programming the Remote - Part II

What's left to be done is programming the 2nd BBC micro:bit that acts as a remote.

The remote is used to display on its 5-by-5 pixel-made screen the relative distance to obstacles. At most, there are going to be 10 pixels turned on.

At the same time, the remote is giving you the capabilities to remote control the GiggleBot by pressing its 2 buttons: move forward, to the left and to the right.

Note: The following script might have missing whitespaces and this seems to be due to some issue in displaying GitHub Gists. Click on the gist to take you to its GitHub page where you can copy-paste the code.

STEP 7: Interpreting the Remote Screen

In the above GIF, it is shown various interpretations of the distance towards an object the circularly surrounds the GiggleBot at different distances.

In the first frame of the GIF, the distance to the object is roughly 10 centimeters and as the GIF frame count increases, the distance increases too up until the screen no longer shows any object at which point it can be said the object if there's one, is farther than 50 centimeters away.

STEP 8: Running It


To control the GiggleBot, you have the following options:

  1. Press button A and button B to move the GiggleBot forward.
  2. Press button A to spin the GiggleBot to the left.
  3. Press button B to spin the GiggleBot to the right.

To see to which direction the closest obstacles are detected, just look on the remote's (the remote BBC micro:bit that you're holding) screen. You should be able to control the GiggleBot from far away without looking at it.

2 Comments

Hi! May I ask where I can buy the Servo kit? It's the only component that I can't seem to find as a separate item that I can purchase. Thanks!