The centerpiece of the system used to communicate commands to the robot is the server. The server stores several different types of information, and uses various types of persistent storage to communicate information between the webpage to the robot, and from the robot to the webpage. In order to communicate commands issued from the webpage to the robot, the server has a table in it's sqlite3 database commands.db, which stores all the commands sent by the webpage as well as the time that the command was added to the database. The robot will be periodically making get requests to the server, checking for new additions to this database. If it sees any new commands, it will retrieve all of them via a GET request and execute them in the order they were added to the table. A similar process is used to communicate sensor readings like temperature and distance(via the ultrasonic sensor) from the robot to the webpage, where it is displayed. Whenever a command is issued to take a reading for one of these values, a POST request is made to the server, which will then add the temperature or distance readings to the temptable or ustable, used for storing temperature data and ultrasonic readings respectively. While this is happening, the webpage is using javascript to read from each table, and displaying the most recent addition. Pictures are communicated from the robot to the server as well, except instead if being stored in a database, the image is encoded into Base64 on the robot, where it is then posted to the server and written to a txt file. This txt file is then read using javascript on the webpage by looking directly at the Base64 string.
Every post request that is made to the server has a parameter named "type", which is used to indicate the type of data that is being posted to the server. For example, if the "type" field has the value "commandpost", then that means that it will have an additional field "command", which stores a string which will be directly added to the command table in the server's sqlite3 database. These commands are used to initiate readings on the robot, play sounds, take pictures, and other commands which don't have an changeable amount parameter. If the specified type is "control", that means that the post was initiated from a movement command on the webpage, and will have two additional field: "command", which indicates the type of movement, and "amount" which indicates how much to move. These two data fields are concatenated and then added to the same command table used for "commandpost". However, the server must also be able to handle the posting of sensor and image readings to the other databases on the server. If the "type" field has the value "temppost", then it expects an additional field "temp" which stores a temperature reading from the robot, which is then appended to the temptable table on the sqlite3 database. Similarly, "uspost" has an additional field "dist" which stores a distance reading from the ultrasonic sensor, which is added to the "ustable" table. The final post type is "imagepost", which is used to handle images being posted to the server. These images are received in Base64 under the "img" field, and is then written to a txt file named "capture.txt". This text file will store the image in its encoded form so that it can be directly sent to the webpage when requested.
The server also handles GET requests which are used to retrieve information from the server. Similar to POST requests, the GET expect a query value "type" which indicates what kind of data to return. For example, if type equals "picturetext", then it will return the Base64 encoded data of the most recent image, which is stored in the "capture.txt" file. If type equals "temprequest", it will return the most recent temperature from the "temptable" table in the sqlite database. Ultrasonic readings are retrieved from the "ustable" table using the "usrequest" type. Commands are slightly more complicated, as they may need to return multiple commands if multiple commands have been added to the database since the last time it was checked. To account for this, the type "commandrequest" takes an additional field "lastrequest" which stores the time of the last get request that was made. Using the value of "lastrequest", it will retrieve all the commands from the table that were added after that time, and return them seperated by commas. Additionally, it will return the time that the request was completed on the second line, which will be used for the next request as the new value for "lastrequest".
A webpage (http://iesc-s1.mit.edu/608dev/sandbox/connora/eBot/server.py?type=control) acts as the control module for LASSIE. Several commands can be send from the webpage to the robot through the server system described above using buttons. These buttons trigger POST requests to the server, which add commands to the database. Some of these POST requests also take advantage of sliders to indicate amounts to be used for "control" requests, which are used to indicate robot movements. This webpage also servers as a way to view the most recent images and data which has been uploaded to the server database. The webpage includes javascript code which continuously checks for changes to the "capture.txt" file used to store the image Base64 encoded data. This is accomplished by making GET requests through javascript. If a change is detected, it will update the source value of the image so that it displays the recently uploaded image. Get requests are also being made to check for updates to the temperature or ultrasonic distance database, and changes in either of those will update the labels on the webpage. For example, the code will make a request to http://iesc-s1.mit.edu/608dev/sandbox/connora/eBot/server.py?type=temprequest in order to get the most recently uploaded temperature data. The value of the temperature label is then updated to be the value that is received from that request. This interface allows the user to control the robot's ability to move forward or backward at any increment, turn left or right at any increment, play specific sounds from the speaker, initiate temperature readings, ultrasonic distance readings, and take pictures.