# Determine current roomba state / operating mode

Using the SCI messages, I would like to determine the current operating mode or state of a iRobot Roomba 780. Finally, I would like to detect and separate four states:

• Cleaning
• In docking station
• Returning to docking station
• Error (e.g. trapped on obstacle)

What is a fast and reliable way to detect those states using SCI data?

The Roomba SCI Sensor packets "Remote Control Command" and "Buttons" seem to return the currently called commands and not the currently executed ones.

The manual you linked to is not for the Roomba 780. You'll want to reference the one on this page: http://www.irobot.com/create

You can tell if the robot is on the dock by checking the "Home Base" bit in the charging sources available packet (#34).

There is currently no way to know via the OI if Roomba is trying to find the dock.

• Quite a good hint, thanks. I try to find correlations between different sensor States in order to determine the overall Roomba state, incl. "error". – Tob Mar 31 '15 at 9:54

I found a partial answers to my question: The "current" sensor message indicates if the roomba is operating (< 0) or in the docking station (> 0). Open remains error handling and "searching for docking station". I'll adapt my answers if I get further.

EDIT 2015-05-05: The solution which seems to work looks in pseudo code as follows:

if ( charging_state == 5 ) {
return ERROR;
}
else if ( charging_state == 2 ) {
return CHARGING;
}
else {
if ( charger_available == 2 ) {
return INDOCK;
}
else {
if ( main_brush_current != 0 && current < 0 ) {
return WORKING;
}
else {
return ERROR;
}
}
}


The "variables" within the if statements are corresponding sensor messages given in the document, linked by @Andrea.

The "return values" indicate the corresponding Roomba states.

• Roomba doesn't always draw current while sitting on the dock. It stops charging to allow the battery to cool off. – Andrea Okerholm Apr 2 '15 at 1:01