Introduction: How to Make an Object Following Robot - the Stalkerbot

About: You either hate me or love me.

Intro

Speaking of mobile platforms, you might come up with ideas such as line tracking, obstacle avoidance, anti-dropping, environment monitoring, etc. But what I am making today, is a robot that follows an object, relentlessly. I call it the stalkerbot, and it is a lot of fun making this robot.

The basic function of this robot is simple: it follows you. It goes forward as you go forward; goes backward as you go backward; turns left/right as you turn left/right. When you stop moving, it stops as well.

I used two range sensors to identify the moving direction of object. You can also add more as well, but the minimum number that will do the job is two. The scenarios are quite straightforward, and will be explained later.


Material List

2wd miniQ Robot chassis from DFRobot

Upper Deck for miniQ from DFRobot

Infrared Sensor Switch from Ebay

Sharp GP2Y0A21 Distance Sensor (10-80cm) with mounting bracket from Ebay

Romeo All in one Controller from DFRobot

9g micro servo

7.4V lipo battery bar

screws, standoffs and cables

Tools

screw driver

soldering iron

computer

Step 1: Assembling the Robot

I used a 2wd mobile platform “miniQ” and an extra deck from DFRobot. Assembling the lower chassis is quite intuitive, you can also check the video guide here.

Then solder the cables onto motor, and expand the lower chassis with standoffs and the upper deck.

Screw the Romeo controller onto the upper deck (you can also fix it in the middle of two layers), and connect the motor cables with M1 & M2 on the Romeo controller.

Make sure to leave some place for the lipo battery, you can either insert it between two layers, or tape it elsewhere from dropping off.

Step 2: Wiring the Sensors

Connect the two infrared sensor switch on digital port 8 and 9 on controller, and connect the Sharp distance sensor infrared distance sensor on analog port A1.

Please note that the infrared sensor switch is a digital sensor and should be connected to digital ports: green to GND, red to 5V, yellow to digital. While the Sharp distance sensor is an analog sensor and should be connected to analog ports: black to GND, red to 5V, orange to analog.

Step 3: Programming

There are five scenarios, basically.

#1
If both sensors detect an object at the same time, and the distance is between 5 and 15 cm: object in range, just stop and check again.

#2

If both sensors detect an object at the same time, and the distance is less than 5 cm: object too close, retreat to avoid impact.

#3

If the left sensor detects an object while the right sensor does not: object at left, turn left and move forward.

#4

If the right sensor detects an object while the left sensor does not: object at right, turn right and move forward.

#5

If neither of the two sensors detects any object: not in sight, stay still and spin.

I've also enclosed the code for download. Below are explanations of some codes.

a

if(!left && !right && x>15)
{ advance(100,100); }

When digital infrared switch detects an obstacle, it generates low output; If not, generates high output.

The range of digital infrared sensor switch I used is 3~80cm, and the range can also be adjusted. Which is cool.

b

double get_gp2d120x (uint16_t value) {
if (value < 16) value = 16; return 2076.0 / (value - 11.0); }

This is to calculate the distance between IR sensor and the object.

Step 4: Epilogue

As for now, the tutorial for this object following robot has come to an end. Hope you all made it!

Next steps? Probably I will grab a mp3 module and a speaker, to make this quirky following robot more annoying - repeating "Penny, Penny" maybe? (I'm a TBBT fan).

Enjoy.