Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions sunray/robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ unsigned long nextTempTime = 0;
unsigned long imuDataTimeout = 0;
unsigned long nextSaveTime = 0;

unsigned long liftTimeout = 0;
unsigned long bumperTimeout = 0;

bool wifiFound = false;
char ssid[] = WIFI_SSID; // your network SSID (name)
char pass[] = WIFI_PASS; // your network password
Expand Down Expand Up @@ -744,22 +747,36 @@ bool detectObstacle(){

#ifdef ENABLE_LIFT_DETECTION
#ifdef LIFT_OBSTACLE_AVOIDANCE
if ( (millis() > linearMotionStartTime + BUMPER_DEADTIME) && (liftDriver.triggered()) ) {
CONSOLE.println("lift sensor obstacle!");
statMowBumperCounter++;
triggerObstacle();
return true;
if (liftDriver.triggered()) {
if (liftTimeout == 0) {
liftTimeout = millis() + BUMPER_DEADTIME;
} else if (liftTimeout < millis()) {
liftTimeout = 0;
CONSOLE.println("lift sensor obstacle!");
statMowBumperCounter++;
triggerObstacle();
return true;
}
} else {
liftTimeout = 0;
}
#endif
#endif

if ( (millis() > linearMotionStartTime + BUMPER_DEADTIME) && (bumper.obstacle()) ){
CONSOLE.println("bumper obstacle!");
statMowBumperCounter++;
triggerObstacle();
return true;
if (bumper.obstacle()) {
if (bumperTimeout == 0) {
bumperTimeout = millis() + BUMPER_DEADTIME;
} else if (bumperTimeout < millis()) {
bumperTimeout = 0;
CONSOLE.println("bumper obstacle!");
statMowBumperCounter++;
triggerObstacle();
return true;
}
} else {
bumperTimeout = 0;
}

if (sonar.obstacle() && (maps.wayMode != WAY_DOCK)){
CONSOLE.println("sonar obstacle!");
statMowSonarCounter++;
Expand Down