ROVer is online | last fetch at :: | status:

Live Camera Feed

ROVer Robot D85: Troubleshooting Sensor Data to Eliminate Outliers and Enable Autonomous Navigation

More than you ever wanted to know about sensor data! :p

Wether we’re talking the speed and distance readings from the primary motor encoders or the proximity values from any of ROVer’s 5 (so far) distance sensors, getting reliable data has proven a bit challenging. The problem stems from the fact that we’re requesting those values many times each second and once in a while, we get a bad reading. That one bad reading, however, can through a serious wrench in the works when it comes to obstacle avoidance and/or navigation.

I think I’ve found a solution (code sample below, of course 🙂 that will bump-out the anomalies and keep the “good” values so that we can get averages that make sense.

The next step is to plan for contextual events via programs…

…what I mean by that is when ROVer is executing a program, say a program designed to navigate my hallway, we may want him to respond differently to a Forward Sensor Obstacle Event than if he were doing a spin turn out in the open, outside, for example. That ability to provide ROVer with different command options related to the circumstances in which he finds himself is critical to efficient navigation.

Arduino UNO processOutliers Function/Method

int processOutliers(int32_t vars[]) {
  int32_t avg, avg2; uint8_t count = 0; uint8_t size = 4;
  foreach(int32_t, v, vars, 4) {
    if(direction == 1 && vars[count] > 0) {
      avg = avg+(vars[count]);
      Serial.print("vars[count]: ");
      Serial.print(vars[count]);
      Serial.print(", avg: ");
      Serial.println(avg);
      count++;
    }
  } avg = avg/count; count = 0;
  Serial.print("AVG: ");
  Serial.println(avg);
  foreach(int32_t, v, vars, 4) {
    if(vars[count] > (int32_t)(avg*1.2) || vars[count] < (int32_t)(avg*0.8)) {
      Serial.print("excluding: ");
      Serial.println(vars[count]);
      vars[count] = 0; size--;
    } else {
      Serial.print("keeping: ");
      Serial.println(vars[count]);
      avg2 = avg2+vars[count];
    }
  count++;
  }
  return avg2 = avg2/size;
}

Leave a comment