Skip to content

How the project was coded

Tim Adamson edited this page Jul 3, 2018 · 6 revisions

Javascript Files

Non-Speech

The loadInterface() function is called when the body of the page is loaded, and it creates the first end effector (ee) setting up the goal and the controls used to move the ee. Because the ee is created in this file, the ee can also be destroyed and recreated to change the control of the ee.

Currently, most of the code for this repo resides within this file. EE (end effector) is responsible for creating the end effector with the desired control and creating the target pose. There are 9 possible controls, which come from the 6 found in the controlTypes array, and the fact that the 3 cursor controls can be activated by either mouseclick events, or mouseup/mousedown events. Which mode the cursor controls will use is determined by the inOneTouch boolean.

Global variables are found next at the top of the file, including global variables for the triangles, for the controls, and for the target.

createEE() is the main function that creates both the EE as well as the target (goal pose). A sequence of if and if else statements are used to set up the desired controls based on the selected control type. Because the cardinal speech control does not currently have a GUI, only the speech element is added when that control type is selected. When the trajectory or grid speech is selected however, both the speech element and the graphical element is added.

Besides creating the ee and the target, this code is also responsible for checking for the user's successful completion of the task, and responding accordingly. This is done using checkGoal and success.

The grid file has two functions: addGrid and addPie. As the name suggest, addGrid adds a grid to the work space that will cover part of, or all of the work space. The function is recursive, so when the user selects one of the cells of the grid, a new grid is added that covers the area of the previous cell. The recursion continues until the base case is met, which happens when the size of the grid/cells are small enough such that the user can correctly select the position of the target. addPie is similar to addGrid, except that it is used to select the orientation of the ee instead of the position. This function is also recursive, and has a base case of the pie/slices being small enough such that the user can correctly select an orientation within the acceptable threshold.

Speech

All 3 speech files use annyang to pick up on individual words spoken by the user and respond accordingly. A list of commands is added to annyang to listen for, and when a command is heard, a corresponding function is called.

cardinalSpeech listens for the commands "up", "down", "left", "right", "clockwise", "counterclockwise", and "stop". When one of the directional commands is given, the ee will begin moving in that direction, and will continue to do so until a different command is given. If the stop command is given, the ee will stop moving. Boundaries prevent the ee from going outside of the canvas.

trajSpeech (trajectory speech) listens for the numbers between 1 and 9 ("one", "two", ... "nine") and stop. When a number is selected, the ee will begin moving in the direction of that arrow, and will continue to do so until another command is given. If the stop command is given, the ee will stop moving. Boundaries prevent the ee from going outside of the canvas.

gridSpeech listens for the number between 1 and 9 ("one", "two", ... "nine"). When a number is selected, it will trigger the click event on the DOM element that has that number as its id. This can be used to select both grid cells as well as pie slices.

Clone this wiki locally