Sentry

In this page we will describe our approach in solving following sentry behaviour problems:
  • patroling the predefined environment,
  • detecting an intruder while patrolling, and
  • following an intruder from a safe distance.
We recongnize that sentry behaviour listed above is usually demonstrated by an intelligent agent. Usually, behaviour of simple intelligent agents are described by the following diagram.



Our sentry agent collects information (i.e., percepts) about the environment through three different sensors. They are:
  • passive infra-red,
  • sonar (ultrasonic range finder to be specific), and
  • virtual wall.
The percepts (information) it gathers about its environment are:
  • presence of an intruder using a PIR sensor,
  • location (distance and angle) of an intruder using a sonar and a Roomba Discovery, and
  • presence of a virtual wall using IR sensor found inside a Roomba Discovery.
The actions of the sentry are:
  • patrol in the safe empty rectangular area delimited by virtual walls,
  • detect the presence of an intruder,
  • find the distance between the agent and an intruder, and
  • follow an intruder from a safe distance while remaining inside the predefined area.
The sentry does not physically manipulate any objects in the environment. However, in order to perform its required actions listed above it needs to move around in the environment. In this sense, the sentry drive system is its effector. We have used the following as our drive system:
  • Roomba Discovery.
The sentry operates in a very simple environment. The environment is an empty rectangular area. Each side is only eight feet long. The boundaries of the empty rectangle is delimited by iRobot Virtual Walls. This limit on the length of a side is due to the maximum beam length of iRobot Virtual Walls used in the project. We further assume for testing that this empty space is placed at the centre of another empty space of dimension 24 feet by 24 feet. This is to ensure that the sentry robot does not consider a wall or any other obstacle as the location of an intruder when its PIR sensor is active. We will talk more about this in Section Discussion. The environment of our sentry robot can be understood with the help of the following image.



At any moment during its operation, the sentry is in one of three states. These states are:
  • patrolling,
  • locating, and
  • following.
The sentry collects information about the environment through three different sensors described above. Based on its sensory inputs it decides that any one of following events in the environment has occurred:
  • intruder detected,
  • virtual wall was hit,
  • intruder detected and virtual wall was hit simultaneously,
  • intruder located (i.e., angle and distance of the intruder is found using the sonar and Roomba),
  • intruder located and virtual wall was hit simultaneously,
  • virtual wall was hit while following the intruder,
  • intruder is stationary,
  • nothing.
We define three different controllers to collect sensor data. These controllers are as follows:
  • PIR controller,
  • sonar controller, and
  • virtual wall controller.
These controllers are hardware interrupt driven and timer based. They contain buffers that can be accessed by the main program. PIR controller sets intruder detection variable to true on the rising edge of the sensor and sets it to false on the falling edge of the sensor. Sonar controller also maintains a buffer of distance values. Sonar is triggered by a timer by a pre-specified number of times every second. We activate sonar only when the PIR sensor is activated to reduce power consumption. Virtual wall controller checks for the presence of IR signal a pre-specified number of times every second. The following data-flow diagram shows how we make use of these controllers.



The Motion Controller interprets these sensory inputs. The following table describes how the sensory inputs are interpreted as one of the above mentioned events.

PIR active Virtual Wall hit Locate cycle < MAX_LOCATE_CYCLE Min distance < 8 meters Event
false false false false nothing
false false false true intruder stationary
false false true false intruder detected
false false true true intruder located
false true false false virtual wall hit
false true false true virtual wall was hit while following an intruder
false true true false virtual wall hit while locating an intruder
false true true true this never happens*
true false false false intruder detected or intruder lost
true false false true intruder located
true false true false intruder detected
true false true true intruder located
true true false false virtual wall was hit while an intruder is detected
true true false true virtual wall was hit while following an intruder
true true true false virtual wall was hit while an intruder is being detected.


The Motion Controller is a Finite State Machine. Based on its current state and the event that had just taken place the Motion Controller performs an action and either remains in the same state or moves into a different state. Following table summarizes this.

Current state Event Action Next state
Patrolling Nothing Patrol Patrolling
Patrolling Intruder detected Locate intruder Locating
Patrolling Virtual wall was hit Move to safe location Patrolling
Patrolling Virtual wall was hit and an intruder is detected Move to safe location Locating
Locating Intruder detected Locate Locating
Locating Virtual wall was hit Move to safe location Locating
Locating Intruder located Follow Following
Locating Intruder lost Patrol Patrolling
Locating Intruder located and virtual wall was hit Move to safe location Following
Following Virtual wall was hit while following an intruder Move to safe location Following
Following Intruder located Follow Following
Following Intruder lost Locate Locating
Following Intruder stationary Follow Following


Following is a simplified Finite State Machine (Mealy machine to be particular) diagram for the Motion Controller.

The Motion Controller is also controlled by a timer. The sentry performs one of the actions uninterrupted for one second and at the same time collects sensory inputs. The sentry then invokes the Motion Controller to decide which action to perform next.