Roomba 530 OI serial data
Posted: July 26th, 2016, 9:23 am
I'm working on a project, hooking my Arduino up to my roomba. I have a problem that I don't know how to resolve,
http://prntscr.com/bxpr7x
I simply don't know how to get those values (Image above). I'm very new to c++ so my knowledge isn't strong.
The code I have in the Arduino
Any help would I would appreciate.
The Roomba: https://scontent-lhr3-1.xx.fbcdn.net/t3 ... 4426_o.jpg
530 with 880 CHM and Dirtbin (It's a beast)
http://prntscr.com/bxpr7x
I simply don't know how to get those values (Image above). I'm very new to c++ so my knowledge isn't strong.
The code I have in the Arduino
I got the example code from http://roombahacking.com/software/ardui ... mpTurn.pde and modefied it.
const int txPin = 0;
const int rxPin = 0;
const int ddPin = 8;
byte start[] = {128};
//And take control of the robot
byte hyjack[] = {131};
byte getSensor[] = {142, 7};
char sensorbytes[10];
//byte getSensor[] = {142, 7};
#define bumperRight (sensorbytes[0] & 0x01) //1
#define bumperLeft (sensorbytes[0] & 0x02) //2
#define wheelDropRight (sensorbytes[0] & 0x04) //4
#define wheelDropLeft (sensorbytes[0] & 0x08)//8
//byte getSensor[] = {142, 9};
#define cliffLeft (sensorbytes[0] & 0x01)//1
//byte getSensor[] = {142, 10};
#define cliffFrontLeft (sensorbytes[0] & 0x01)//1
//byte getSensor[] = {142, 11};
#define cliffFrontRight (sensorbytes[0] & 0x01)//1
//byte getSensor[] = {142, 12};
#define cliffRight (sensorbytes[0] & 0x01)//1
//byte getSensor[] = {142, 18};
#define cleanButton (sensorbytes[0] & 0x01)//1
//byte getSensor[] = {142, 18};
#define spotButton (sensorbytes[0] & 0x02)//2
//byte getSensor[] = {142, 18};
#define dockButton (sensorbytes[0] & 0x04)//4
//byte getSensor[] = {142, 21}; - UNKNOWN
#define chargingState (sensorbytes[0] & 0x01)
//byte getSensor[] = {142, 24}; - UNKNOWN
#define batteryTemperature (sensorbytes[0] & 127)
//byte getSensor[] = {142, 45};
#define lightBumperLeftSig (sensorbytes[0] & 0x01)//1
//byte getSensor[] = {142, 45};
#define lightBumperFrontLeftSig (sensorbytes[0] & 0x02)//2
//byte getSensor[] = {142, 45};
#define lightBumperCenterLeftSig (sensorbytes[0] & 0x03)//1
//byte getSensor[] = {142, 45};
#define lightBumperCenterRightSig (sensorbytes[0] & 0x04)//4
//byte getSensor[] = {142, 45};
#define lightBumperFrontRightSig (sensorbytes[0] & 0x08)//8
//byte getSensor[] = {142, 45};
#define lightBumperRightSig (sensorbytes[0] & 0x11)//16
//Not working
//byte getSensor[] = {142, 15};
//#define dirtDetect (sensorbytes[0] & 0x01)//1
//byte getSensor[] = {142, 17};
//#define infraredCharOmni (sensorbytes[0] & 0x01)//1
//byte getSensor[] = {142, 52};
//#define infraredCharLeft (sensorbytes[0] & 0x01)//1
//byte getSensor[] = {142, 53};
//#define infraredCharLeft (sensorbytes[0] & 0x01)//1
//byte getSensor[] = {142, 23}; - UNKNOWN
//#define batteryCurrent (sensorbytes[0])//4
//byte getSensor[] = {142, 22}; - UNKNOWN
//#define batteryVoltage (sensorbytes[0] & 65535)//4
void setup(){
Serial.begin(115200);
Serial3.begin(115200);
//Bring the roobt out of passive mode
digitalWrite(ddPin, HIGH);
delay(200);
digitalWrite(ddPin, LOW);
//Take control of the robot
Serial3.write(start, sizeof(start));
delay(200);
Serial3.write(hyjack, sizeof(hyjack));
delay(200);
}
void loop(){
delay(1000);
updateSensors();
Serial.println(sensorbytes[0] >>;
Serial.println(sensorbytes[0] & 32767);
}
void updateSensors(){
Serial3.write(getSensor, sizeof(getSensor));
int i = 0;
while(Serial3.available()){
long c = Serial3.read();
sensorbytes[i++] = c;
}
}
Any help would I would appreciate.
The Roomba: https://scontent-lhr3-1.xx.fbcdn.net/t3 ... 4426_o.jpg
530 with 880 CHM and Dirtbin (It's a beast)