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/iRobot.cpp
- Revision:
- 3:de12b39ad805
- Parent:
- 1:6c399fc35deb
- Child:
- 5:5fe2f8603be8
diff -r 0b362c662997 -r de12b39ad805 iRobot/iRobot.cpp --- a/iRobot/iRobot.cpp Thu Nov 21 00:02:05 2013 +0000 +++ b/iRobot/iRobot.cpp Mon Nov 25 19:55:12 2013 +0000 @@ -28,15 +28,15 @@ // 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); + device.printf("%c%c", Start, SafeMode); + //device.putc(Start); + //device.putc(SafeMode); wait(.5); - // device.printf("%c%c%c", SensorStream, char(1), BumpsandDrops); + /* device.printf("%c%c%c", SensorStream, char(1), BumpsandDrops); device.putc(SensorStream); device.putc(1); device.putc(BumpsandDrops); - wait(.2); + wait(.2);*/ // Setup a serial interrupt function to receive data device.attach(this, &iRobot::receive_sensor); } @@ -72,6 +72,33 @@ char((speed_left>>8)&0xFF), char(speed_left&0xFF)); } +// Angle - The angle in degrees that iRobot Create has turned since the +//angle was last requested +int iRobot::getAngle() +{ + char angleBuff[2]; + device.printf("%c%c", Sensors, Angle); + device.gets(angleBuff, 2); + return atoi(angleBuff); +} + +// Turn Angle - The angle in degrees that iRobot Create has turned since the +//angle was last requested ccw is pos angle, cw is neg angle +void iRobot::turnAngle(int angle) +{ + char angleTurn[3]; + angleTurn[0] = waitAngle; + angleTurn[1] = angle >> 8; + angleTurn[2] = angle & 0xFF; + if(angle > 0){ + device.printf("%c%c%c%c",char(137), char(0), char(200), char(0), char(1)); + } + else if(angle < 0){ + device.printf("%c%c%c%c",char(137), char(0), char(200), char(255), char(255)); + } + device.printf("%c%c%c", angleTurn[0], angleTurn[1], angleTurn[2]); + wait(.05); +} // Charger - search and return to charger using IR beacons (if found) void iRobot::charger() { @@ -96,6 +123,7 @@ void iRobot::receive_sensor() { char start_character; + printf("reading\n"); // Loop just in case more than one character is in UART's receive FIFO buffer while (device.readable()) { switch (Sensor_byte_count) {