Where Technology meets magic

53 Posts
6 Posts
84 Posts
142 Posts
High Voltage
57 Posts
Image processing
5 Posts
4 Posts
3 Posts
27 Posts
11 Posts
7 Posts
3 Posts
21 Posts
19 Posts
9 Posts
9 Posts
91 Posts
2 Posts
23 Posts
Windows Mobile
11 Posts

Sponsored Links


Top Articles!

AVR SDCard FAT support with FatFS | 19632 Views | Rate 38.88
AVR SDCard FAT support with FatFS
Single Chip Computer | 1870 Views | Rate 29.22
Single Chip Computer
3V to 400V regulated inverter for Geiger counters | 2911 Views | Rate 18.78
3V to 400V regulated inverter for Geiger counters
Virtualmin Git return code 22 fatal: git-http-push failed | 112 Views | Rate 14
Virtualmin Git return code 22 fatal: git-http-push failed


News & Updates

2014-12-12, Virtualmin Git return code 22 fatal: git-http-push failed

2014-11-25, Electric Fence - 20KV pulses for perimeter defense

2014-10-29, Statie de monitorizare a radiatiei de fond in Timisoara

2014-10-29, uRADMonitor - Online Radiation monitoring station



Building a robot – Make the robot follow you

By Radu Motisan Posted on February 7th, 2013 , 4709 Views (Rate 6.91)

Featured on Hack A Day, check it out here!

My friend Kevin, contacted me for building an advanced autonomous companion robot. The final goal is to have to robot following its user. This is the construction log page, with more content added as the project moves on. As this project continues what I have shown in a previous article, you can see this post a a follow-up, named as Part2.

1. January 21, 2013

Kevin carefully prepared everything for the long trip, and the package with the hardware components got here today. For the new robot I will drop my previous Ara robotic rover platform, in favor of the neat A4WD1 from Lynxmotion. Essentially this is a similar differential control rover platform, using 4 geared motors of 200RPM 37mm diameter, one for each wheel (HN-GH12-2217).
android autonomous companion robot 1 android autonomous companion robot 2 android autonomous companion robot 3 android autonomous companion robot 4
android autonomous companion robot 5 android autonomous companion robot 6 android autonomous companion robot 8 android autonomous companion robot 7
Putting the rover together was easy except for the tires which required a little Vaseline. The robot's central processing unit will be an Atmega128 microcontroller and not the Lynxmotion's BASIC Atom Pro 28 Pin (which also requires the custom "bot board II"). Atmega128 wins here with its 128KB flash memory, 16MHz max operating frequency and a multitude of IO ports, while the Basic atom pro can only provide 32K of Program Space and a limited operating frequency (Not to mention the costs, Lynxmotion products are also very expensive).
The motors are to be driven via a Sabertooth 2X12 R/C Regenerative Dual Channel Motor Controller . I am yet to see how well this performs when compared to my simple H-Bridge that I used before. The battery is a generous 12V 2800mAh from Lynxmotion.

2. February 06, 2013

The rover's bottom is a thin black plexiglass sheet, that looks great but can't sustain much weight. In this case, the battery seemed a bit too heavy for the bottom sheet, especially considering high speed movements over rough terrain. So I had to build a battery holder using some steel. Hope I won't get to replace all the original rover by the end of this project :) . But this is what perfectionists usually do.
android autonomous companion robot 09 android autonomous companion robot 10 android autonomous companion robot 11 android autonomous companion robot 12 android autonomous companion robot 13
android autonomous companion robot 14 android autonomous companion robot 15 android autonomous companion robot 16 android autonomous companion robot 17 android autonomous companion robot 18
The steel support is placed longitudinally at the bottom, fixed in screws. This can be used to support other components as well, as I drilled multiple holes for that. Two U-shape holders have been fitted using rivets, this way I got no difference in level, and no sharp points to puncture the battery to be placed in this support:

The prominent ends have been leveled with a metal file. The U-shaped holders got some little plastic spacers, made from PVC plastic heated and bended in a convenient angle. With the battery in place, here is the first motor test:

3. February 12, 2013

The Atmega128 board got a power supply, for both 5V and 3V. The latter is for the Bluetooth module and one of the GPS modules.
building a robot 1 building a robot 2 building a robot 3
The power supply consists of a high efficiency DC-DC converter built using the LM2596 IC. There are plenty of such converters available on Ebay for just a few bucks. I replaced the pot with a fixed 1KO resistor, so the converter would put out a fixed 5V voltage. The 3V is obtained using two L78L33 's. The power boards where fixed to the Atmega128 board.

4. February 18, 2013

New Atmega128 board, with pin connectors including power and gnd to make connections easier. The microcontroller board has been mounted to the robot's platform. The Sabertooth 2X12 has also been mounted. Thick wires link the h-bridge and the motors.
android robodog 1 android robodog 3 android robodog 4

5. February 25, 2013

I finished the top board, exposing the bluetooth UART module and the NMEA GPS module. This will be mounted outside the robot's body, to make sure the modules get maximum radio signal. An LCD is to provide vital information such as battery levels and other diagnosis messages.
android robodog top board 1 android robodog top board 2 android robodog top board 3 android robodog top board 4
And with these last modules, I had to write a considerable amount of software. And this is only the beginning of the long road ahead:
- HD44780 LCD code . The LCD uses only 3 wires to connect to the Atmega128, using a shift register, 74HC164, to save a few IO pins.
- UART code, to handle data from the UART Bluetooth module and the UART GPS Module.
- GPS NMEA Parser, highly optimized to save memory and processing power. Also available on Google code, here.
And the first problems didn't wait too long to show up. It appears the bluetooth module's RF creates some kind of interference that reduces the GPS signal. As a result, having the Bluetooth module on, I can barely get a GPS fix. When the signal is good (8 satellites in use), turning the bluetooth module on will reduce the signal (3-4 satellites). Here is a demo to show this defect. The red jumper wire is used to power on/off the Bluetooth module. The "sats" value displayed on the LCD is the number of fixed satellites.

So to bypass the issue, I'll need to rework the top-board and move the Bluetooth module at some distance from the GPS module. I was not aware of such a design requirement.

6. March 27, 2013

The Sabertooth 2X12 R/C Regenerative Dual Channel Motor Controller needs to be hooked up to an UART port. On the microcontroller board I have no free UART port available, so to simplify I plan to use a dual H-Bridge built from scratch. You can see the Dual H-Bridge here.
dual_hbridge_motor_controller_08 dual_hbridge_motor_controller_08 dual_hbridge_motor_controller_08 dual_hbridge_motor_controller_08
Schematics and PCB available in the Dual H-Bridge article.

The LCD has been mounted inside the chassis, must admit it looks perfect this way: low profile, high tires, black paint, and that blue electric LCD light. All combined with a highly energetic movement.

7. March 28, 2013

Following the successful dual HBridge integration, I added the Bluetooth UART module, and wrote a software for Android OS, to allow me to control the robot by using the phone. Here's a demo video:

And a few pictures to show the final robot shape:
android robot 1 android robot 2 android robot 3 android robot 4
Next thing to do is to make the robot follow the user, AUTOMATICALLY! I'm currently considering two options, one involves using the GPS Module, send the coordinates via bluetooth to user's mobile phone that also has GPS and can then inform the robot where it needs to go, the second option would be to use some kind of beacons, the user would carry in his/her hand (or pocket), and the robot would detect those and follow the signal.

8. April 08, 2013

As I've shown above, the purpose of this robot is to follow its user, and I imagined two instruments for implementing that:

1) a global localization method, using GPS. The PROs are that we can place a GPS module on the robot, and the user can have a mobile phone with its own GPS module. The phone can establish a connection to the robot using Bluetooth, and send the user coordinates periodically. Then the robot can calculate the path it needs to run, to get in close proximity of the user, and follow him/her. Sounds good, but the CONs are bad: first, the GPS errors are too big to allow us to make the robot follow the user; it would rather jump like a crazy monkey all around the user, and this is the best scenario. Another issue is also the GPS signal which is poor or unavailable indoors.
If we place a stationary GPS receiver, here's how the GPS coordinates look like:
As you can see, despite the fact our GPS receiver is stationary, the localization data we receive has a tolerance of a few meters or even tens of meters, placing us on a disc surrounding the real position. This is inappropriate for the purpose of this work, so I have decided to find different means of robot positioning and orientation; this number -2- below:

2) The local method will use a closed system for localization, formed of only the robot itself, the user, and a signaling beacon. Normally the user will carry a signaling beacon (ultrasonic, infrared, radio, etc), which the robot will "see" and follow. Easy to say, doing it is of course much harder, as we need a smooth robot movement, so a lot of error compensation and fuzzy logic must be involved.
Recently I made some excellent progress using ultrasounds as a transmission method, to create a simple beacon detector. You can read more on it here.
The user needs to carry this tiny, low power ultrasonic beacon which the robot should be able to "hear" and use the signal to navigate to the target, and follow it.
ultrasonic_beacon_receiver_2 ultrasonic_beacon_receiver_3 ultrasonic_beacon_receiver_4 ultrasonic_beacon_receiver_5
These wonderful modules will not only return a signal when ultrasounds are detected, but the output amplitude is directly proportional with the actual distance to the beacon. So we'll know both where the beacon is, and how far.
Given these tools, there are several ways of implementing the working mechanism:
a) using a single ultrasonic receiver, placed in front of the robot: the rover will need to rotate until it detects a maximum level of signal. Then it should move forward until the detected signal reaches a given threshold (so it will not hit the user, but stop right before him/her). It doesn't really work well, as the software gets overcomplicated and the results are not as good as expected.
b) similar to a), but use a servo motor to rotate the ultrasonic sensor instead of rotating the entire robot. When the maximum signal is detected, the robot should turn towards the source, and begin moving forward . It still doesn't solve many of the issues found with a)
c) using two ultrasonic receivers, placed some space apart, in the frontal part of the rover. Now we can make differential measurements, so it's easy to know from which part is the signal coming from, as the corresponding sensor will have higher readings. The robot can now directly turn towards the beacon, and follow the forward direction while the two sensors give approximately similar readings. If the right sensor output increases, then it means the robot needs to turn right, to face the beacon and continue moving forward. Same case for left. A similar approach has been used in a project by Andrew Wiens :

d) using more than two sensors, ideally 8, placed at 45 degrees in a radial disposition. This would pinpoint the source more accurately, and reduce the time needed to find the beacon. Still, to simplify, I plan to go for the differential measurements presented at c) .

The ultrasonic sensors already return an output signal which is a function of the distance to the beacon / user. This can be used to measure the distance. If greater accuracy is required, we can involve infrared light in the process:
- the beacon sends a set of 38KHz modulated Infrared pulses marking moment of time t0
- the beacon immediately sends out the ultrasonic pulses
- the receiver which is a few meters from the beacon, receives the infrared pulses practically instantaneously and knows the time is t0 (using a TSOPXX38)
- the receiver registers the incoming ultrasonic pulses at the time t1, where t1>t0. By using the speed of sound in air, we can get the exact distance to the beacon.
All in one we use light to signal the start for counting, and we stop when the ultrasonic waves reach the destination.
More on this here, here or here.

9. April 09, 2013

Using the ultrasonic sensors differential readings (with sensors placed in front, at angles of aprox. 15 degrees of the longitudinal axis), I got some excellent results: the robot is able to follow me, and keep track of my speed, and orientation:

The algorithm compares the readings from the two sensors and decides whether to turn left (if left sensor return higher readings), right or to move forward (if the output of the two sensors is similar).
There are some remaining issues:
- if the robot approaches a wall, and the beacon signal is coming from the back, it will reflect in the wall and confuse the robot
- no detection capabilities for signal coming from any other direction, other than the front
To solve these issues, three more ultrasonic receiver boards are needed, namely one for back, and one for each of the sides. Also the movement is a bit shaky, and this can also be improved by changes in the robot's software code. More to follow soon.
ultrasound_guided_robot_1 ultrasound_guided_robot_2 ultrasound_guided_robot_3
I built some nice PCBs for the ultrasonic sensors, and provided more details on Detecting an ultrasonic beacon, here.
ultrasonic_beacon_receiver_1 ultrasonic_beacon_receiver_2 ultrasonic_beacon_receiver_3 ultrasonic_beacon_receiver_5

10. April 10, 2013

I built a total of 5 ultrasonic receivers, that are to be placed two in the front, one at the back and two on each side.

The idea is to have the robot turn around facing the ultrasonic signal, and then to make it follow the source using the two frontal sensors. The differential readings will help us decide whether to adjust the direction for left or right.
Using some PVC pipes, I built some nice and robust plastic enclosures, by heating and pressing the plastic to get the desired shapes:
ultrasonic_enclosure_1 ultrasonic_enclosure_2 ultrasonic_enclosure_3 ultrasonic_enclosure_4
The result looks great:

For some uber-coolness factor, I decided to add frontal white lights and back position red lights, controllable from the software (on/off). The frontal side now also houses a nice Sharp 2y0a infrared sensor, that will help avoid hitting any obstacles. So now the robot is capable to hear and see its surroundings. Love how it looks:
robot_cool_1 robot_cool_2 robot_cool_4 robot_cool_5 robot_cool_6

11. May 01, 2013

Time has come to build the TX ultrasonic beacon. This time I wanted to try something new, so here is my first PCB for SMD components:
ultrasonic_beacon_40KHz_NE556_1 ultrasonic_beacon_40KHz_NE556_2 ultrasonic_beacon_40KHz_NE556_3 ultrasonic_beacon_40KHz_NE556_4
It uses a NE556, dual timer, and is configured to emit short bursts of 40KHz pulses. You can see the circuit here:
556_diagram 556_smd_pcb
Eagle file also available, beacon TX.
A case was also needed, to enclose the 9V battery as well, and make it comfortable for holding it in the hand. The final results looks like this:
tx_beacon_1 tx_beacon_2 tx_beacon_3

12. May 03, 2013

This project finally comes to an end, so I recorded two demo videos to show the robot following me, outdoors. A few modifications in software are likely to be done, but all in one, the work is pretty much complete:
Demo 1:

Demo 2:

13. May 22, 2013

As I am a perfectionist with all that I build, I couldn't stay away and had to make this robot even better. So I did two things:
1) For the autonomous, human following software: I improved the ultrasonic detection algorithm, and the movement logic: Now the robot will follow its user more precisely, and the speed will vary with the detected signal: if the robots sees the user at a greater distance, will engage with a greater speed. If closer to the user, will proceed with smaller steps. The calculations are not linear, so I used some time to get the best formula. In the end I'm quite pleased, we can see some nice improvements when compared to previous two videos - so here are two new demos:
Demo 3:

Demo 4:

2) For the remote control software, where the user controls the robot using a phone, the rover now reports its frontal sensor readings (that show the proximity in centimeters to any detected obstacle), to the smartphone. So the movement commands go from phone to robot, and the sensor readings go the opposite way, from robot to phone. The Android software now allows the user to turn the lights on and off, and using the frontal distance sensor, a red line is drawn, showing the proximity to an obstacle. The robot can be controlled this way - without actually seeing what it is heading for, as this simple radar will be enough to get a clear path. Here is another demo:

3) When bluetooth is connected, the robot will ignore any ultrasonic signals from its beacon. So better separates the two modes of operation discussed above.


Mechanisms for Combining Infrared and Ultrasound Signals for Indoor Wireless localization
Infrared / Ultrasonic beacon
Ultrasonic Source Localization
Mobile Robot Navigation
Learn about GPS
Robo-Dog on Hack A Day

More on PocketMagic:

Atmega8 and enc28J60 for ethernet support | 8731 Views | Rate 10
Atmega8 and enc28J60 for ethernet support
How to set the AVR Fusebits | 6416 Views | Rate 9.89
How to set the AVR Fusebits
Custom Rotary Knob Control for Android | 3965 Views | Rate 9.67
Custom Rotary Knob Control for Android
Programmatically Injecting Events on Android - Part 1 | 8936 Views | Rate 9.26
Programmatically Injecting Events on Android - Part 1
Variable 0..30V Regulated Power supply for 20A max | 15263 Views | Rate 8.65
Variable 0..30V Regulated Power supply for 20A max
Discussing security in online on TV News show | 2665 Views | Rate 8.46
Discussing security in online on TV News show

22 Responses to “Building a robot – Make the robot follow you”

  1. 1
    Android controlled robot (via Bluetooth) – Part 1 « PocketMagic:

    […] Note: Part 2 is available here: Android controlled robot – Part 2 […]

  2. 2
    ATMega128 and HD44780 LCD using 3 Wires with the 74HC164 « PocketMagic:

    […] the Android Controlled robot project, I've decided I'll be needing an LCD, to show various parameters and make debugging easier. In the […]

  3. 3
    Dual H-Bridge for controlling two motors « PocketMagic:

    […] the A4WD1 Robot platform project presented here, I decided to skip the Sabertooth 2X12 R/C Regenerative Dual Channel Motor Controller, and build a […]

  4. 4

    this is very good project.
    im also working for a project like this, can you give me the android Bluetooth app source code.

  5. 5
    Detecting an ultrasonic beacon « PocketMagic:

    […] speaking about robots, here are some neat ultrasonic detector modules, built for the differential rover robot I'm currently working on. These modules can be hooked up to a microcontroller's ADC port, and will […]

  6. 6
    Francis Baygan:

    lets say we turn the robot on 50 meters away from the beacon will it still manage to reach the beacon?

  7. 7

    This was designed to work on close proximity; your scenario is out of the current scope of this project: the ultrasound beacon has a certain limited range, 5-6 meters the most . For what you want, a different mechanism should be used, perhaps using radio waves.

  8. 8
    Wireless rover with Android control - RaspberryPiBoards:

    […] spend the first portion of this year building and improving upon this wireless rover project. It’s actually the second generation of an autonomous follower project he started a few years […]

  9. 9
    Wireless rover with Android control | Daily IT News on IT BlogIT Blog:

    […] spend the first portion of this year building and improving upon this wireless rover project. It’s actually the second generation of an autonomous follower project he started a few years […]

  10. 10

    Hi Radu, great project. I’m looking at making something very similar with a power wheelchair. in you ultrasonic TX circuit you say you’ve used an NE556 timer wheras in your schematic it is LM556N. what is the difference between these components? Can i use the NE556 timer? I am looking at using your design for my ultrasonic TX but have never made a PCB before.

  11. 11
    Radu Motisan:

    Hi Amy . Yes you can use the NE556 !

  12. 12
    Wireless rover with Android control | Make, Electronics projects, electronic Circuits, DIY projects, Microcontroller Projects - makeelectronic.com:

    […] account the primitive parcel of this year storehouse too improving above this wireless wanderer proposition. It’s really the deputy age of an autonomous groupie undertaking he started a some years […]

  13. 13
    Remote Control Robots Using Android Mobile Devices - How To Tutorials And Resources - Into Robotics:

    […] controlled robot (via Bluetooth) Part 1, Part 2 This is a comprehensive tutorial in two parts that explain and revealed the steps to control a […]

  14. 14

    high sir,, gud day… can u help me on making my final project entitled “human following smart shopping cart”. if its ok to you,, can we buy your project above? i mean can you provide us the tutorial of your project and we will pay you for your help..
    you may contact me here…….. (belenedwin@yahoo.com) tnx… and Godbless

  15. 15
    jay ar:

    hellow sir,, can u help me on haw to hook up the 5 ultrasonic receiver in arduino board… can i see ur program on the follow me robot using ultrasonic beacon… tnx in advance

  16. 16

    Hi Radu, first of all, congratulations for this project, I´ve been working on something similar, but I just found a problem, I made 2 robots, each one with it’s own control, and everything is perfect until they are close to each other, the signals begin to mix and suddenly I find two robots following one remote, Do you (or does anyone) have an idea of how could this be solved?

  17. 17
    Justin Yoo:

    I am very impressed with what you have accomplished.
    I am just a college student at an engineering school, and I am really interested in making what you have made here.
    Could you tell me a few tips and what parts to use? Did you make the ultrasonic sensor’s circuit board yourself?
    Could you please help me get started on this project?
    Thank you so much.
    I will be eagerly waiting for your reply.

  18. 18
    Dennis Phillips:

    I have tried compiling your original code you provided in Part 1. When running the resulting application I receive an exception when it tries to create the tabs. Do you have a more recent update to the source code you are willing to share?

  19. 19
    Radu Motisan:

    @Dennis, see Bill’s comment under this article: http://www.pocketmagic.net/2010/01/android-dynamic-tab-control/

  20. 20
    Dennis Phillips:

    Thanks that solved the problem.

  21. 21

    hello can i have the code for the ultrasonic robot. the code for the robot to move and can i use other arduino for the microcontroller?

  22. 22
    nikil rayani:

    Hello Radu,

    I’m trying to replicate exactly what you did here, but i’m having difficulty with the coding of the ultrasonic receiver and transmitter. How would I code the microcontroller for the ultrasonic sensors? May I please get the code for that? Thanks.

Thank you for commenting. Your comment won't show until approved, which can take some time.