Hacking Roomba 560 as moving camera rig

By Dan Chen, January 20, 2015

For this week, I want to turn my Roomba into my camera man. Similar to remote cameras that they use in TV studios, the roomba would move according to my preplanned path.

 

vr600_tracks

 

Wiring

By taking out the lit off the roomba, you will find a PS/2 like cable. We will be using this to communicate  with the roomba.

IMG_3933 IMG_3934

IMG_3935 IMG_3936

 

Screen Shot 2015-01-17 at 5.20.41 PM

Important: The Yun does not have built in voltage regulator, so be sure to have an external one. The roomba’s power cable provides  16V. If you are using Arduino UNO, you don’t need to worry about this.

Roomba – Arduino
GNG – GND
Vpwr 16V – Vin (regulate to 5v if using Arduino Yun )
RXD – TX / Digital Pin 10  (We are using software serial )
TXD – RX  / Digital Pin 11  (We are using software serial )

IMG_3943

Code

Note: The Roomba Default Baud Rate is 115200. You can change it to 19200 by powering on Roomba, hold down the Clean/Power button. After about 10 seconds, Roomba plays a tune of descending pitches. Roomba will communicate at 19200 baud until the power is turned off, the battery is removed and reinserted, the battery voltage falls below the minimum required for processor operation, or the baud rate is explicitly changed by way of the OI.

Try 19200 if 115200 doesn’t work, you might be accidentally set the Baud Rate to 19200.

//hex table http://hextodecimal.com/index.php?hex=C8


#include 

int rxPin = 10;
int txPin = 11;
int ledPin = 13;


SoftwareSerial Roomba(rxPin,txPin);

#define bumpright (sensorbytes[0] & 0x01)
#define bumpleft  (sensorbytes[0] & 0x02)

void setup() {
 pinMode(ledPin, OUTPUT);   // sets the pins as output
 Serial.begin(19200);
 Roomba.begin(19200);  
 // 115200  is the default, but I want to use 19200 in this case
 
 /*When powering on Roomba, 
 hold down the Clean/Power button. 
 After about 10 seconds, Roomba plays a tune of descending pitches. 
 Roomba will communicate at 19200 baud until the power is turned off, 
 the battery is removed and reinserted, 
 the battery voltage falls below the minimum required for processor operation, 
 or the baud rate is explicitly changed by way of the OI.
 */



 digitalWrite(ledPin, HIGH); // say we're alive
 Serial.println ("Sending start command...");
 delay (1000);
  // set up ROI to receive commands  
 Roomba.write(128);  // START
 delay(150);
 Serial.println ("Sending Safe Mode command...");
 delay (1000);
 Roomba.write(131);  // CONTROL
 delay(150);
 digitalWrite(ledPin, LOW);  // say we've finished setup
 Serial.println ("Ready to go!");
 delay (500);
}

void loop() {

 

  // goBackward();
    //delay(100);
    
    
   halt();
    delay(800);

goForwardSlow(50);
   delay (5000);

   halt();
    delay(500);


 while(1) { } // Stop program
 
 
 
}

void goForward() {
  Roomba.write(137); // Roomba's DRIVE command
  Roomba.write((byte)0x00); // Velocity high byte, HEX 00
  Roomba.write(100); // Velocity low byte,  HEX C8 (00C8=200mm/sec)
  Roomba.write(0x80); // Radius high byte,   HEX 80
  Roomba.write((byte)0x00); // Radius low byte,    HEX 00 (8000=straight)
}
void goForwardSlow(int travelSpeed) {
  
   Roomba.write(137); // Roomba's DRIVE command
  Roomba.write((byte)0x00); // Velocity high byte, HEX 00
  Roomba.write((travelSpeed, HEX)); // Velocity low byte,  HEX C8 (00C8=200mm/sec)
  Roomba.write(0x80); // Radius high byte,   HEX 80
  Roomba.write((byte)0x00); // Radius low byte,    HEX 00 (8000=straight)
}
void goBackward() {
 Roomba.write(137);   // DRIVE
 Roomba.write(0xff);   // 0xff38 == -200
 Roomba.write(0x38);
 Roomba.write(0x80);
 Roomba.write((byte)0x00);
}

void halt(){
  byte j = 0x00;
  Roomba.write(137);   
  Roomba.write(j);   
  Roomba.write(j);
  Roomba.write(j);
  Roomba.write(j);
}


void spinLeft() {
  Roomba.write(137); // Roomba's DRIVE command
  Roomba.write((byte)0x00);   
  Roomba.write(0xc8); // Velocity of spin 00C8 = 200 mm/sec
  Roomba.write((byte)0x00);
  Roomba.write(0x01); // Radius 0001 = spin left
}
void spinRight() {
  Roomba.write(137); // Roomba's DRIVE command
  Roomba.write((byte)0x00);
  Roomba.write(0xc8); // Velocity of spin 00C8 = 200 mm/sec
  Roomba.write(0xff);
  Roomba.write(0xff); // Radius FFFF = spin right
}

You can look up the hex table here
//hex table http://hextodecimal.com/index.php

or cover the hex using this
Roomba.write((TheNumber, HEX));

 

Result