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
Diff: iRobot.cpp
- Revision:
- 0:3ed56271dd2d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/iRobot.cpp Mon Nov 11 19:22:13 2013 +0000 @@ -0,0 +1,66 @@ +#include "mbed.h" +#include "iRobot.h" + +// Definitions of iRobot Create OpenInterface Command Numbers +// See the Create OpenInterface manual for a complete list + + iRobot::iRobot(PinName tx, PinName rx) : device(tx, rx){ + speed_left = 200; + speed_right = 200; + } + +// Start - send start and safe mode, start streaming sensor data +void iRobot::start() { + // device.printf("%c%c", Start, SafeMode); + device.putc(Start); + device.putc(SafeMode); + wait(.5); + // device.printf("%c%c%c", SensorStream, char(1), BumpsandDrops); + device.putc(SensorStream); + device.putc(1); + device.putc(BumpsandDrops); + wait(.5); +} +// Stop - turn off drive motors +void iRobot::stop() { + device.printf("%c%c%c%c%c", DriveDirect, char(0), char(0), char(0), char(0)); +} +// Forward - turn on drive motors +void iRobot::forward() { + device.printf("%c%c%c%c%c", DriveDirect, char((speed_right>>8)&0xFF), char(speed_right&0xFF), + char((speed_left>>8)&0xFF), char(speed_left&0xFF)); + +} +// Reverse - reverse drive motors +void iRobot::reverse() { + device.printf("%c%c%c%c%c", DriveDirect, char(((-speed_right)>>8)&0xFF), char((-speed_right)&0xFF), + char(((-speed_left)>>8)&0xFF), char((-speed_left)&0xFF)); + +} +// Left - drive motors set to rotate to left +void iRobot::left() { + device.printf("%c%c%c%c%c", DriveDirect, char((speed_right>>8)&0xFF), char(speed_right&0xFF), + char(((-speed_left)>>8)&0xFF), char((-speed_left)&0xFF)); +} +// Right - drive motors set to rotate to right +void iRobot::right() { + device.printf("%c%c%c%c%c", DriveDirect, char(((-speed_right)>>8)&0xFF), char((-speed_right)&0xFF), + char((speed_left>>8)&0xFF), char(speed_left&0xFF)); + +} +// Charger - search and return to charger using IR beacons (if found) +void iRobot::charger() { + device.printf("%c%c", Demo, char(1)); +} +// Play Song - define and play a song +void iRobot::playsong() { // Send out notes & duration to define song and then play song + + 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", + Song, char(0), char(16), char(91), char(24), char(89), char(12), char(87), char(36), char(87), + char(24), char(89), char(12), char(91), char(24), char(91), char(12), char(91), char(12), char(89), + char(12),char(87), char(12), char(89), char(12), char(91), char(12), char(89), char(12), char(87), + char(24), char(86), char(12), char(87), char(48)); + + wait(.2); + device.printf("%c%c", PlaySong, char(0)); +} \ No newline at end of file