Obstacle Detector

Sven Köhler

Proposal by Lawrie for an ObstacleDetector interface

I propose we add a new interface:

public interface ObstacleDetector {
  public boolean pollInterval();
  public boolean obstacleDetected();
}

This would be passed to pilots on their constructors.

Pilots would call obstacleDetected every pollInterval() microseconds in their regulator thread. If it returns true, the pilot would stop the move. Pilots would only call obstacleDetected if a move was in progress, and is was not a rotate.

Some pilots do not currently have regulator threads as they rely on Motor regulator threads. We would either need to add such a thread to them or modify Motor to accept an ObstacleDetector. Note that pilots that do sensor feedback must have regulator threads.

We can potentially add methods to this interface in the future that return the position and velocity of the obstacle.

Pilots should also support a setObstacleDetector method, so that different obstacle detectors could be used at different times or for different move types. This would also be an alternative to passing the ObstacleDetector on the pilot constructor.

I further propose that we remove all non-blocking calls from pilots as they were mainly used for obstacle detection and this provides a cleaner way to do it.

One objection to this is that non-blocking calls can be used for other sensor reading tasks and not just obstacle detection. For example, a pilot could be used to do a 360 degree sweep and detect the closest obstacle or the longest clear path. To allow this, we could add a method to the ObstacleDectector interface: boolean includeRotates(). This would allow an ObstacleDetector to be used for this sort of application. An alternative is to pass the move type (travel, arc, or rotate) as a parameter to the obstacleDetected method.


Related

NXT Wiki: Home