The FollowMeBot follows the user based on the color of his or her shirt. The device hosts a webcam on a servo to find the object and orient the robot. The color is chosen through the user interface with push buttons. Currently, the MATLAB code supports red and green detection. The purpose of FollowMeBot is to be able to follow the user in order to be helpful for daily tasks.

Dependencies:   Rectangle Servo TextLCD mbed

Fork of FollowMeBot3 by Rahul Shetty

Committer:
dhamilton31
Date:
Mon Nov 11 19:22:13 2013 +0000
Revision:
0:3ed56271dd2d
FollowMeBot

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dhamilton31 0:3ed56271dd2d 1 #include "mbed.h"
dhamilton31 0:3ed56271dd2d 2 #include "iRobot.h"
dhamilton31 0:3ed56271dd2d 3
dhamilton31 0:3ed56271dd2d 4 // Definitions of iRobot Create OpenInterface Command Numbers
dhamilton31 0:3ed56271dd2d 5 // See the Create OpenInterface manual for a complete list
dhamilton31 0:3ed56271dd2d 6
dhamilton31 0:3ed56271dd2d 7 iRobot::iRobot(PinName tx, PinName rx) : device(tx, rx){
dhamilton31 0:3ed56271dd2d 8 speed_left = 200;
dhamilton31 0:3ed56271dd2d 9 speed_right = 200;
dhamilton31 0:3ed56271dd2d 10 }
dhamilton31 0:3ed56271dd2d 11
dhamilton31 0:3ed56271dd2d 12 // Start - send start and safe mode, start streaming sensor data
dhamilton31 0:3ed56271dd2d 13 void iRobot::start() {
dhamilton31 0:3ed56271dd2d 14 // device.printf("%c%c", Start, SafeMode);
dhamilton31 0:3ed56271dd2d 15 device.putc(Start);
dhamilton31 0:3ed56271dd2d 16 device.putc(SafeMode);
dhamilton31 0:3ed56271dd2d 17 wait(.5);
dhamilton31 0:3ed56271dd2d 18 // device.printf("%c%c%c", SensorStream, char(1), BumpsandDrops);
dhamilton31 0:3ed56271dd2d 19 device.putc(SensorStream);
dhamilton31 0:3ed56271dd2d 20 device.putc(1);
dhamilton31 0:3ed56271dd2d 21 device.putc(BumpsandDrops);
dhamilton31 0:3ed56271dd2d 22 wait(.5);
dhamilton31 0:3ed56271dd2d 23 }
dhamilton31 0:3ed56271dd2d 24 // Stop - turn off drive motors
dhamilton31 0:3ed56271dd2d 25 void iRobot::stop() {
dhamilton31 0:3ed56271dd2d 26 device.printf("%c%c%c%c%c", DriveDirect, char(0), char(0), char(0), char(0));
dhamilton31 0:3ed56271dd2d 27 }
dhamilton31 0:3ed56271dd2d 28 // Forward - turn on drive motors
dhamilton31 0:3ed56271dd2d 29 void iRobot::forward() {
dhamilton31 0:3ed56271dd2d 30 device.printf("%c%c%c%c%c", DriveDirect, char((speed_right>>8)&0xFF), char(speed_right&0xFF),
dhamilton31 0:3ed56271dd2d 31 char((speed_left>>8)&0xFF), char(speed_left&0xFF));
dhamilton31 0:3ed56271dd2d 32
dhamilton31 0:3ed56271dd2d 33 }
dhamilton31 0:3ed56271dd2d 34 // Reverse - reverse drive motors
dhamilton31 0:3ed56271dd2d 35 void iRobot::reverse() {
dhamilton31 0:3ed56271dd2d 36 device.printf("%c%c%c%c%c", DriveDirect, char(((-speed_right)>>8)&0xFF), char((-speed_right)&0xFF),
dhamilton31 0:3ed56271dd2d 37 char(((-speed_left)>>8)&0xFF), char((-speed_left)&0xFF));
dhamilton31 0:3ed56271dd2d 38
dhamilton31 0:3ed56271dd2d 39 }
dhamilton31 0:3ed56271dd2d 40 // Left - drive motors set to rotate to left
dhamilton31 0:3ed56271dd2d 41 void iRobot::left() {
dhamilton31 0:3ed56271dd2d 42 device.printf("%c%c%c%c%c", DriveDirect, char((speed_right>>8)&0xFF), char(speed_right&0xFF),
dhamilton31 0:3ed56271dd2d 43 char(((-speed_left)>>8)&0xFF), char((-speed_left)&0xFF));
dhamilton31 0:3ed56271dd2d 44 }
dhamilton31 0:3ed56271dd2d 45 // Right - drive motors set to rotate to right
dhamilton31 0:3ed56271dd2d 46 void iRobot::right() {
dhamilton31 0:3ed56271dd2d 47 device.printf("%c%c%c%c%c", DriveDirect, char(((-speed_right)>>8)&0xFF), char((-speed_right)&0xFF),
dhamilton31 0:3ed56271dd2d 48 char((speed_left>>8)&0xFF), char(speed_left&0xFF));
dhamilton31 0:3ed56271dd2d 49
dhamilton31 0:3ed56271dd2d 50 }
dhamilton31 0:3ed56271dd2d 51 // Charger - search and return to charger using IR beacons (if found)
dhamilton31 0:3ed56271dd2d 52 void iRobot::charger() {
dhamilton31 0:3ed56271dd2d 53 device.printf("%c%c", Demo, char(1));
dhamilton31 0:3ed56271dd2d 54 }
dhamilton31 0:3ed56271dd2d 55 // Play Song - define and play a song
dhamilton31 0:3ed56271dd2d 56 void iRobot::playsong() { // Send out notes & duration to define song and then play song
dhamilton31 0:3ed56271dd2d 57
dhamilton31 0:3ed56271dd2d 58 device.printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",
dhamilton31 0:3ed56271dd2d 59 Song, char(0), char(16), char(91), char(24), char(89), char(12), char(87), char(36), char(87),
dhamilton31 0:3ed56271dd2d 60 char(24), char(89), char(12), char(91), char(24), char(91), char(12), char(91), char(12), char(89),
dhamilton31 0:3ed56271dd2d 61 char(12),char(87), char(12), char(89), char(12), char(91), char(12), char(89), char(12), char(87),
dhamilton31 0:3ed56271dd2d 62 char(24), char(86), char(12), char(87), char(48));
dhamilton31 0:3ed56271dd2d 63
dhamilton31 0:3ed56271dd2d 64 wait(.2);
dhamilton31 0:3ed56271dd2d 65 device.printf("%c%c", PlaySong, char(0));
dhamilton31 0:3ed56271dd2d 66 }