In order to actually hack the Roomba and control its actions, I first had to learn how to use the programs Realterm and LabVIEW, the latter being the most important.
This program is essentially a serial terminal program, by which information could be sent to the Roomba via Bluetooth. In using this program, I was introduced to the way in which ROI, binary system, and hexadecimal system actually operate. In comparison to LabVIEW, this program seems rather primitive, but was necessary in providing a solid foundation in sending opcodes and data to the robot.
I first practiced turning on the motors and LEDs. By using the ROI references I had, I turned the decimal numbers of the opcodes and data into hexadecimal numbers the Roomba would recognize. From then on I learned how to drive the Roomba. However, all these commands had to be typed in separately, and a stop command was needed to be sent in order to stop the previous command. This obviously was time consuming, and LabVIEW appeared as though it would be a breath of fresh air.
It was a little disheartening when Farid pulled down from his shelf the 1,000 page “LabVIEW for Everyone” guide book, but in hindsight, the program now seems fairly simple.
A VI is a Virtual Instrument and is the driving force of LabVIEW, and a much needed concept to understand. It is a data flow model, consisting of data inputs and outputs, and countless other tools and equations, all connected by wires. Data from an input flows through wires and performs the following equations or guidelines of various data sinks throughout the model, resulting in an output or the like. As I learned more and more about the program, the VIs became much more complex.
The front panel is the graphical interface of the VI, displaying buttons, knobs, gauges, inputs, outputs, graphs, etc… Front Panels can be customized to suit the users needs, and there are various options in changing the characteristics. The Front Panel shown above displays the controls to drive the Roomba, and control the LEGO arm. There are several buttons, each with a different command attached to them, and there is also a gauge that changes the speed of the Roomba.
Every front panel has its counterpart: the block diagram. The block diagram describes the actual logic behind the buttons and tools on the front panel. It is in the block diagram that you wire the flow of data to the correct data sinks. The block diagram above is that of the driving and arm controls. As seen on the left, the buttons are wired to various cases and nodes, all following a logic that converts the action of pressing a button on the front panel to the actual movement of the Roomba.
Below are the front panel and also a section of the block diagram of the music command:
The functions palette is associated with the block diagram, and it possesses items such as numeric operations (addition, multiplication, greater/less than), and various structures (like while loops and case structures). The controls palette is associated with the front panel, and it contains various controls and indicators, like Boolean buttons, LEDs, numeric inputs/outputs. The tools palette is available in both the front panel and block diagram, and is primarly for the use of wiring, moving objects, and editing texts.
CONTROLS AND INDICATORS:
The most commonly used data source is the Control, whereas the most common output of data is the Indicator. Many objects in LabVIEW can be changed from controls to indicators, like the Boolean buttons and LEDs.
Control (block diagram): Indicator (block diagram):
Control and indicator in front panel.
According to “LabVIEW for Everyone,” an array is an “ordered, indexed set of data elements of the same type.” Arrays made it possible to arrange, in my case, a set of Boolean buttons into a single orderly unit. From this array, depending on which Boolean button was pushed, a binary number was created. Say there are buttons 1, 2, and 3 lined up. If you push button 2, the binary number produced would be 010, because button 1 is off, button 2 is on, and button 3 is off.
Just as in mathematics, the functions are what help create the logic in order to reach a desired output. As seen above, there is a simple addition function with the constant 10. This means whatever is placed in the input will have 10 added to it in the output. Other mathematical functions include subtraction, multiplication, greater than or less than, and so on. Above to the right is another type of function, called Boolean array to number. This function changes a Boolean number (or binary number) into a decimal number and would be found after an array. This is especially helpful in the creation of formula nodes. These functions are only seen in the block diagram.
A formula node is a node that performs the formulas within it. This is helpful in that it is much more efficient than writing lengthy formulas that would be difficult to create in block diagram form. The formula nodes I used had the same job. The logic within the node converts a decimal number (one already converted from the binary number), into a case number. Therefore, to start at the beginning, the information of which button was pushed would go through an array, converted to binary, converted from binary to decimal, and then in the formula node the decimal number would determine the case number. The logic’s structure inside the formula node is similar to that of a C Program.
A case structure is a control structure that follows the logic and functions of only one of its subdiagrams. The specific subdiagram (also called a case) is chosen based on a received variable input. A case structure can have several different cases within it. This structure was used in every program I developed. The case structures were needed to provide an efficient means by which the commands could be sent to the Roomba. As shown above, each case holds a specific command, whether it is to play the middle C piano tone or to drive forward at a slow speed. On the left of each case, there is an input source, and in my programs, the input source was an array formed from Boolean buttons and also formula nodes. Depending on which case is specified by the input variable, the command in the corresponding case can be sent to the Roomba.