Ami Main Steps


Ami Main Features

Sensing

Multiple sensors collect data regarding the status of soap, trash and toilet paper of every bathroom.

Reasoning

The data collected is processed and compared to threshold values in order to differentiate critical, not-so-fine and fine conditions.

Acting

Users are notified whenever the system recognizes a critical condition, only about their favorite bathrooms (if inserted) and only during work/class time (if inserted).

Interacting

Users can interact with the system by tapping on a bathroom’s icon on the map in order to get the info previously collected.


Ami Features


Ami Features

Sensitive

See sensing section.

Responsive

The system is able to respond to the cleaning staff needs of hurrying to manage the critical conditions of some specific bathrooms.

The system is able to respond to the students needs of knowing if the bathroom they chose provides what they need.

Adaptive

The system adapts to the different situations: it is able to recognise when to notify users about critical conditions.

Transparent

All the hardware components are hidden from sight.

Ubiquitous

Not so much.

Intelligent

The system is able to learn when to increase or decrease the checking frequency, depending on the usage of the bathroom.


Purpose and Scope


W.C. is a system that allows users to check the bathrooms' status, in terms of amount of garbage in trashcans, amount of soap, presence (or lack) of toilet paper.

It consists of a map of the Politecnico, that shows where all the bathrooms are located and indicates, using different colors (red, yellow, green), whether that place is in a critical condition or not.

W.C. provides also a notification system, that can be enabled/disabled:

if enabled, users can decide to add some specific bathrooms to their preferences to be notified about, or they can add their working/class schedule to set when to be notified;

if disabled, they can always check a particular bathroom status by tapping on its icon: this will show, using the same color pattern described before, the status of each one of the three items, and also the time when this data was last collected.

The system is able to learn when to increase/decrease the automatic checking frequency: if the last data collected differs considerably from the current one, the sampling frequency increases, if not, it decreases accordingly.


Definitions

Glossary

system = the W.C. mobile application and all the other hardware/software components

map = a Politecnico map provided by the W.C. application

users = either a cleaning staff member or a student in need of a bathroom

preferences = a list of specific-located bathrooms whence the user can receive notifications and check the status

icon = a bathroom identification icon on the map which can assume three different colors depending on the condition (green, yellow, red) and three different pictures for bathroom reserved for men and women or with disability access

items = soap, trash, and toilet paper in each bathroom (see definition)

bathroom = a room equipped with a sink and a toilet that includes at least one of the three items

data = the amount of toilet paper, soap, trash in the bathroom.

upper threshold (item) = threshold above which the item is almost or completely full

lower threshold (item) = threshold below which the item is almost or completely empty

fine condition (item) = the amount of toilet paper is above its upper threshold, the amount of soap is above its upper threshold, the amount of trash is below its lower threshold

not so fine condition (item) = the amount of each item is bewtween its lower and its upper threshold

critical condition (item) = the amount of toilet paper is below its lower threshold, the amount of soap is below its lower threshold, the amount of trash is above its upper threshold

upper threshold (bathroom) = threshold above which the average condition of its items is fine

lower threshold (bathroom) = threshold below which the average condition of its items is critical

fine condition (bathroom) = the average condition of the three items inside that bathroom is above the upper threshold

not so fine condition (bathroom) = the average condition of the three items inside that bathroom is between the lower and the upper threshold

critical condition (bathroom)= the average condition of the three items inside that bathroom is below the lower threshold

working/class schedule = time intervals to choose from, during which users will be notified

Actors

Students in need of a bathroom

Bathroom-cleaning staff


Requirements

Functional Requirements

  1. DATA COLLECTION AND ELABORATION
    1. The system must be able to collect data from the surrounding environment. (priority: 1)
    2. The system must detect when the amount of toilet paper is under the threshold. (priority: 1)
    3. The system must detect when the amount of soap is under the threshold. (priority: 1)
    4. The system must detect when the amount of trash is above the threshold. (priority: 1)

  2. NOTIFICATIONS AND PREFERENCES
    1. Users must be able to activate/deactivate the notification system. (priority: 1)
    2. The system must send a notification whenever a bathroom reaches a "critical condition" (priority: 1)
    3. Users must be able to add specific bathrooms to their preferences. (priority: 2)
      1. If there are bathrooms in their preferences, users will receive notifications regarding only those bathrooms. (priority: 2)
      2. If there are no bathrooms in their preferences, users will receive notifications about all the bathrooms. (priority: 2)
    4. Users must be able to set their own working/class schedule. (priority: 3)
      1. If the working schedule is inserted, the system must send notifications to users only during work/class time. (priority: 3)
      2. If the working schedule is not inserted, the system must send notifications to users whenever a bathroom reaches a "critical condition". (priority: 3)
  3. INTERACTIVE MAP
    1. When a bathroom is in a “fine” condition, its icon turns green. (priority: 1)
    2. When a bathroom is in a “not-so-fine” condition, its icon turns yellow. (priority: 1)
    3. When a bathroom is in a “critical” condition, its icon turns red. (priority: 1)
    4. The map must show if the bathroom is men-only, women-only, both men-women or with disability access using some icons. (priority: 4)
    5. Users must be able to manually check a bathroom status by tapping on its icon in the map. (priority: 1)
      1. When an icon is selected, the system shows the status of toilet paper, trash and soap for that bathroom, together with the time that data was collected. (priority: 1)
  4. AUTO-LEARNING
    1. The system must automatically change the checking frequency. (priority: 1)
      1. If the current data differs consistently from the previous one, the system increases the checking frequency. (priority: 1)
      2. If the current data doesn’t differ consistently (or doesn’t differ at all) from the previous one, the system decreases the checking frequency. (priority: 1)

Non Functional Requirements

  1. PRODUCT REQUIREMENTS
    1. The system must be compatible with Android 4.4 +
    2. The system needs to be powered at all times.
      1. In case of lack of power, the system must not lose the collected data.
    3. The system supports English language.
    4. The system is supposed to have a response time of less than 10 seconds.

  2. EXTERNAL REQUIREMENTS
    1. The system needs to be connected to the Internet to work properly.
      1. In case of lack of connection, the system will not work as expected.

  3. ORGANIZATIONAL REQUIREMENTS
    1. The system must have a structure that allows future implementations.


System Architecture


System Architecture

Hardware Architecture

  1. Computational nodes
    1. Central Server
      1. Anywhere in the web, always-on system
      2. Data Elaboration
      3. Data Storage (internal Database)
      4. Intelligence
    2. Local Gateway
      1. One for each bathroom
      2. Data collection and conversion
      3. Intelligence
    3. Smartphone
      1. Data Storage
      2. Data Elaboration
      3. Intelligence
  1. Sensors
    1. One for each container (trash container, toilet paper container, soap container)
    2. Placed inside the top-part of a specific container
    3. Detects the distance, in terms of cm, from the corresponding item (trash, toilet paper, soap)
  2. User devices
    1. A smartphone running the W.C. mobile application.

Software Architecture

  1. Central Server
    1. Elaborates data sent from the Local Gateway
    2. Stores data into an internal database
    3. Infers each bathroom's status from the data inside the database
    4. Decides when to increase (or not) the sampling frequency, and communicates this to the Local Gateway
    5. The central server has a world-accessible public IP address and communicates with the local gateway and with the mobile application via HTTP

    The following functional requiments are implemented by the server:

    1. 1.2 - 1.3 - 1.4: DATA COLLECTION AND ELABORATION
    2. 4: AUTO-LEARNING
  2. Local Gateway
    1. Collects raw data from the sensors and converts it to a distance (in cm)
    2. Sends data to the central server
    3. Changes the sampling frequency according to what the server says
    4. Communicates with the central server and with the mobile application via HTTP

    The following functional requiments are implemented by the Local Gateway:

    1. 1.1: DATA COLLECTION AND ELABORATION
  1. Mobile Application
    1. Runs on every phone with Android 4.4+
    2. Elaborates data taken from the server and changes the icons on the map accordingly
    3. Stores users favorite bathrooms and schedule
    4. Provides an interface that allows users to check a bathroom's status by clicking on its icon
    5. Notifies users whenever a bathroom reaches a critical condition
    6. The mobile application communicates with the local gateway and with the central server via HTTP, and interacts with Google Maps via Google Maps APIs

    The following functional requiments are implemented by the mobile application:

    1. 2: NOTIFICATIONS AND PREFERENCES
    2. 3: INTERACTIVE MAP

REST API

Bathrooms


METHOD: POST

URL: /api/v1.0/bathrooms/bathroom/updateItem

INPUT: JSON Object with one key and an array as value

RETURN: JSON Object with one key and a string as value

Updates the amount of an item in a certain bathroom and establishes how the sampling period should change

Input Description
key status
value[0] A string representing the floor where the bathroom containing the specified item is located
value[1] A string containing the name of the bathroom in which the item is located
value[2] A string containing the name of the item
value[3] A float representing the value of the measure taken by the sensor
value[4] A string representing the day of the measure (dd/mm/yyyy)
value[5] A string representing the time of the measure (hh:mm)
Return value Description
key action
value: decrease The sampling period must be decreased
value: reset The sampling period must be restored to the initial value
value: stay The sampling period must remain the same

NOTE: the values described above refer to time, so decreasing the sampling period actually means raising the checking frequency


METHOD: GET

URL: /api/v1.0/bathrooms/bathroomID

INPUT: Bathroom ID

RETURN: JSON Object with the amount of each item in the specified bathroom

Provides the condition of all the items in the selected bathroom

Input Description
bathroomID The name of the bathroom you're interested in
Return value Description
key Each key corresponds to the name of an item
in the specified bathroom (e.g Toilet paper 1,2..., Soap 1,2...)
value[0] An integer representing the amount of the item (%)
value[1] A string that specifies when the data was collected,
using the following format: (dd/mm/yyyy hh:mm)

METHOD: GET

URL: /api/v1.0/bathrooms/map/floor

INPUT: floor

RETURN: JSON Object with the condition of each bathroom in the selected floor

Provides the situation of each bathroom in the selected floor

Input Description
floor The selected floor (e.g 0, 1)
Return value Description
key Each key corresponds to the name of a bathroom
in the specified foor
value An integer between 0 and 2 representing the condition of the bathroom
[0 = critical, 1 = not so fine, 2 = fine]

Device

METHOD: POST

URL: /api/v1.0/device/register

INPUT: JSON Object with the registration ID

RETURN: JSON Object with the device ID

Manages the registration of a device on the server

Input Description
key registrationID
value A string containing the registrationID assigned by Google Cloud Messaging service
Return value Description
key deviceID
value An integer corresponding to the deviceID assigned by the server

METHOD: POST

URL: /api/v1.0/device/setNotification

INPUT: JSON Object with the device ID and an action

RETURN: No value returned

Enables or disables the notification system for a device

Input Description
keys deviceID, value
value An integer containing the deviceID obtained during the registration
[ key: deviceID ]
A string (yes/no) to enable/disable the notification system [ key: value ]

METHOD: POST

URL: /api/v1.0/device/setSchedule

INPUT: JSON Object with the deviceID and the selected schedule

RETURN: No value returned

Allows a device to set a specific schedule

Input Description
key deviceID and the name of the days of the selected schedule (Monday,Tuesday...)
value An integer containing the deviceID obtained during the registration
[ key: deviceID ]
For each day, a value that could be a single string or an array of strings, each one containing a time interval (e.g: 11:00-13:00, 17:30-19:30)
[ key: name of the day ]

METHOD: POST

URL: /api/v1.0/device/favorites

INPUT: JSON Object with the deviceID, the action to be performed and the bathroom

RETURN: No value returned

Inserts or removes a bathroom to/from the list of favorites of a device

Input Description
key deviceID, action, bathroomID
value An integer containing the deviceID obtained during the registration
[key: deviceID ]
String containing the action to be performed (add/remove) [ key: action ]
String containing the name of the bathroom [ key: bathroomID ]

Component Selection

  1. Software Components
    1. Raspberry Pi2: Python Modules
      1. RPi.GPIO
      2. time
      3. requests
      4. json
      5. threading
    2. Laptop: Python Modules
      1. sqlite3
      2. flask
      3. datetime
      4. json
      5. time
      6. gcm
    3. Mobile Application
      1. Built with PhoneGap using HTML, CSS, JavaScript
      2. Google Maps APIs
  1. Hardware Components
    1. Off The Shelf
      1. Central Server: laptop
      2. Local Gateway: RaspberryPi 2
      3. Sensors: 3x HCSR04 ultrasonic proximity sensors
      4. User device: any mobile phone with Android 4.4+
      5. Resistors
      6. Breadboard and wires