How to Make an Object Following Robot - the Stalkerbot
Intro: How to Make an Object Following Robot - the Stalkerbot
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
Toolsscrew 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.
aif(!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.
bdouble 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.
13 Comments
josekurian 6 years ago
Could you make this instruct-able complete (Explain why there is a servo and update the connections steps\diagram) & accurate (Romeo version is v1. If any one buy v2, then keep in mind that the pins have changed) ?
JeffreyA59 6 years ago
BTW, the video doesn't work now.
rdiamond123 7 years ago
great robot, just one question. Could you use a battery holder with aa instead of the lipo but if not, where do you connect the battery?
sathish7 7 years ago
how can i get more range of following, like around 5 meters? will infrared work for this range of operation?
Charles-LiB 7 years ago
why do you need the extra mini servos is there are already 2 servo included in the 2WD miniQ Robot Chassis?
MasterP2 8 years ago
could you please upload or give me the arduino wiring.
Allam01 8 years ago
Hi it is a great project I was just wondering what can I use instead of the Romeo All in one Controller
Thanks
sebaolifre 8 years ago
Hey I need some help with project. i'll pay good ... ? i want to make a rc plane that has a object recognition and following that object (car, other rc plane, ...)
whatever you need i'll provide
vinu randula 8 years ago
i have make this but i want to know how to connect micro servo to bord. my mail is v.panangala@gmail.com
rameesvlpy 9 years ago
Hey. can u send your full pdf to my mail please....rameesputhoorgmail.com
Danger is my middle name 9 years ago
I love that chassis! I've used it for several builds before I had access to laser cutters :)
LaurenPan 9 years ago
Wow,really. Would you mind to share with me that what kind of builds you did for this kit? I have several of them also.But not quite sure which kind of project to do with... =. =
Danger is my middle name 9 years ago
When I was in college some friends and I made a "bug killer" game where we used the chassis for the "bug" that had IR sensors on it and the person playing had a "gun" with an IR LED in it that turned on with a trigger mechanism so when you "shot" the bug it would run away. It was pretty fun and we actually got a preliminary patent on it. This chassis worked really well because the positioning of the wheels made it very manuverable :)