Nick Apseloff 2nd Quarter

From WLCS

Goals

1. Research Wiimote. [X]

2. Research Wiimote head tracking. [X]

3. Build the infrared head tracking unit. [X]

4. Use the Wiimote as a mouse for the computer. [X]

5. Set up head tracking system. [X]

6. Read chapter 1 of Javanotes and take quiz. [X]

7. Install Java on home computer. [X]

8. Read chapter 2.1-2.2 of Javanotes and answer quiz questions 1-4,6,8,9. [X]

9. Read chapter 2.3-2.4 of Javanotes and answer quiz question 10. [X]

10. Read chapter 2.5-2.6 of Javanotes and answer quiz questions 5, 7, 11, 12. [X]

Documentation

Goal 1 (Wiimote research)

The Wii works by using two infrared LEDs (light emitting diodes) on a sensor bar that are picked up by the infrared detector in the Wiimote controller. The controller tracks the movement of the LEDs and this information is sent to the Wii console via bluetooth, which makes games capable of being interactive because of real time tracking of the location of the remote. The Wiimote also contains an accelerometer, which measures the physical movement of the remote. For example, if you tilt the remote to the side, the accelerometer detects the magnitude and direction of the tilting, and sends this information to the Wii wirelessly using bluetooth. The Wii Sports bundle that comes with the system uses the accelerometer for every game. In tennis, for example, the user swings the Wiimote to hit the ball on the screen, and the accelerometer determines how hard the swing is and whether or not the timing was accurate. In addition to the innovative methods of input, the Wiimote has a vibrate function and a speaker.

The bluetooth connectivity works up to 30 feet away, but the maximum distance that the IR sensor can detect the sensor bar is up to 16 feet.

Goal 2 (Head tracking research)

Using a mounted Wiimote above the computer monitor and a head-mounted tracking unit with two infrared LEDs (essentially a sensor bar), it is possible to track the movement of a person's head, and use that information to change an image on the screen being viewed in order to significantly enhance the feel of virtual reality. We found a website made by Johnny Chung Lee, a researcher with a PhD in human-computer interaction, demonstrating a head tracking program he created called WiiDesktopVR. In a video, he demonstrates how to use the program and how it works. The program has a three dimensional sample image of floating targets on different planes coming out of the background. When the person wearing the head tracking unit moves, the image changes in response to this movement, making the image seem like the targets are really there and that the monitor is just a frame into a virtual reality. As the person moves closer to the image, the targets seem to pop out of the screen, out in front of the actual monitor.

Goal 3 (Building head tracking unit)

Picture of the finished head tracking unit.

Supplies:

infrared LED (2), goggles (1), battery holders (2), AA batteries (2), soldering gun, solder

We started by figuring out which end of the LED was positive and which end was negative so we could properly solder the wires of the battery holders to the LED. Since the longer end of the LED is the anode, we soldered it to the red wire of the battery holder, and the shorter end to the black wire. We then taped the battery holders and LEDs onto the goggles, completing the head tracking unit. When the operator wants to activate the infrared emission, batteries are inserted into the battery holders. AA batteries were perfect for the LEDs that we purchased because the two batteries we tested were about 1.5 volts, which was the exact voltage required by the LEDs. This design mimics the Wii sensor bar, but is a simpler wireless head tracking unit.

Since infrared light is not in the visible light spectrum, it cannot be seen by humans, which means it was difficult for us to know whether the LEDs worked or not. The program we tested it out on didn't recognize any infrared light through the sensor of the Wiimote, so we had to figure out if the program wasn't working properly or if the light wasn't being emitted. Since fire emits light in the infrared wavelength, we tested out the sensor using a lighter and indeed we saw a little dot moving around on the screen. We then determined that the first time we tried to build the tracking unit, we had the wiring backwards (longer end soldered to the black wire). We knew the longer end was the anode, but in chemistry the anion is negative, while in physics the anode is positive. This was easily fixed by unsoldering and resoldering the LED the correct way, and the head tracking unit was fully working.

Goal 4 (Wiimote mouse)

Screenshot of Wiinremote in action.

Since we connected the Wiimote to the computer using a USB bluetooth adapter and the location of the Wiimote can be tracked, it is simple to use the remote as a mouse for the computer. This is basically the opposite of head tracking: we mount the LED head tracking unit and use the remote as the mouse input device. We downloaded a program called WiinRemote, which enables the Wiimote to be used as a mouse using either infrared tracking or the accelerometer. The accelerometer can be used for the mouse by tilting the remote forward, backward, left, and right to move the cursor up, down, left, and right, respectively. In the screenshot to the right, you can see the motion sensor tracking graph responding to our shaking of the Wiimote.

This method is not as precise for moving the cursor on the screen compared to infrared tracking, because the infrared detector in the Wiimote is much more sensitive to smaller movements than the accelerometer. The detector in the Wiimote works by tracking the LEDs as two points. As the user moves the remote up, the dots move down. The program running registers this downward movement of the two dots and changes the location of the cursor on the screen, moving it up. This all happens in real time with both the X and Y axis being taken into account.

Goal 5 (Head tracking system)

Picture of the targets.

After the setup of building the head tracking unit and connecting it to the computer through the bluetooth adapter (which was very time consuming and frustrating, because the adapter would not recognize the Wiimote), the WiiDesktopVR program was pretty simple to use. The only variable we needed to put into the configuration file of the program to make it work was the distance in millimeters between the two LEDs on the head tracking unit so that the program would be able to accurately identify the X, Y, and Z axis. The Z axis is necessary for virtual reality so that the user can view the monitor as basically like a frame. As they step closer to the monitor, they can see more of the image, just like as if they were stepping closer to an empty frame. The distance between the LEDs is necessary for the Z axis because as the detector sees the two dots moving farther apart, the program registers this as the Wiimote moving away from the monitor. Likewise, when the dots move closer together, the program recognizes the user moving closer.

The image shows the floating targets that move in response to the wearer of the head tracking unit's movement, as can be seen in the picture. The program worked as planned just like in Lee's video. The weakest link in our setup was the LEDs because the soldering was not perfect so the image intermittently flickered if the battery wasn't seated right or if the head tracking unit was jostled too hard. Also, the fact that we were using a small monitor limited the distance we could travel to the left or right of the screen while still being in the range of the image. To improve our system, we could set up a switch to turn the infrared light on and off without having to insert and remove batteries as well as use a larger screen.

Goal 6 (Javanotes Ch 1)

Up until this point, my only computer programming experience is with Guido van Robot and Python. To familiarize myself with Java, a new and more advanced language for me, I read the introductory chapter of Javanotes (Introduction to Programming Using Java, Fifth Edition) by David Eck at http://math.hws.edu/javanotes/. At the end of the seven sections, I took the chapter quiz.

1. One of the components of a computer is its CPU. What is a CPU and what role does it play in a computer?

  • The CPU is the Central Processing Unit and its job is to execute programs. The CPU consists of a square chip with millions of tiny transistors that switch on and off, which can be interpreted as binary digits 1 and 0.

2. Explain what is meant by an "asynchronous event." Give some examples.

  • An asynchronous event is a event handled by the CPU that occurs at an unpredictable time. An example of an asynchronous event is when a computer-user clicks a mouse button or keyboard key and the CPU is temporarily interrupted to process the input.

3. What is the difference between a "compiler" and an "interpreter"?

  • A compiler takes a high-level computer language program such as Java or C++ and converts it to machine language so that the CPU can execute it. An interpreter acts like a CPU itself and runs in a loop in which it reads the instructions of a program one by one, executing the corresponding machine language commands. Because of the loop process required, compiled programs are faster than interpreted programs.

4. Explain the difference between high-level languages and machine language.

  • Machine language is made up of simple instructions that can be executed by the CPU. High-level languages are what almost all programs are written in. In order for the CPU to execute high-level language programs, they must first be translated to machine language. High-level languages are more user-friendly and simpler to develop. Machine language is like bleep bleep bloop.

5. If you have the source code for a Java program, and you want to run that program, you will need both a compiler and an interpreter. What does the Java compiler do, and what does the Java interpreter do?

  • The Java compiler converts the program written in Java into Java byte-code, which is the machine language for the Java virtual machine. The virtual machine installed on the computer then interprets the Java byte-code to run the program. Java is a versatile language in this way because a Java program can be run on any computer that has a Java byte-code interpreter installed.

6. What is a subroutine?

  • A subroutine is a set of instructions grouped together and given a name that can be substituted for the same set of instructions later on in the program. Subroutines help to save typing and organize programs.

7. Java is an object-oriented programming language. What is an object?

  • An object is a module comprised of data and subroutines (states and messages). The states can respond to the messages. For example, if the state is a list of names and the message is telling it to print the data, in response the names will be printed.

8. What is a variable? (There are four different ideas associated with variables in Java. Try to mention all four aspects in your answer.)

  • A variable is a memory location assigned a name so that it can be later used in the program. The four types of variables are integers (e.g. -1, 2), floating point numbers (8.16, 15.0), characters ('X', ';'), and strings ("Hello World!", "You need more rams.")

9. Java is a "platform-independent language." What does this mean?

  • This means that Java programs can be run on any platform (Windows, Mac, Linux) because Java utilizes a virtual machine interpreter. The interpreter software is different for each platform, but the actual compiled Java program can be run on any computer that has the virtual machine installed.

10. What is the "Internet"? Give some examples of how it is used.

  • The Internet is a world-wide network of millions of computers. It can be used for e-mail, instant messaging, file sharing, and accessing the World-Wide Web. Each service th at the Internet provides has its own set of standards, or protocols, that enable it to be interoperable and seamless.

Goal 7 (Install Java)

In order to easily run JDK (Java Development Kit) files through command line in Windows, a PATH variable must be assigned after installing the JDK software.

I installed JDK and jEdit (a programming text editor with syntax highlighting.) JDK is the "Java virtual machine" that converts Java code into Java bytecode. Java bytecode is the machine language for the Java virtual machine. The reason the Java code isn't converted directly to the machine code of my CPU is because Java is made to work on any computer system that has the virtual machine installed, which makes it a versatile high-level programming language.

To set the PATH variable on my Windows computer, I had to edit the "System variables" list (Start > Control Panel > System > Advanced > Environment Variables). Under the "Path" variable, I had to add the JDK directory (C:\Program Files\Java\jdk1.6.0_11\bin) to the list of other Path directories.

I used the following sample Java code[1] to test out the Path in command line:

class myfirstjavaprog
{  
        public static void main(String args[])
        {
           System.out.println("Hello World!");
        }
}

I compiled the Java code using the javac command, creating a .class file in the directory. I then executed the program, resulting in the text "Hello World!"

Java1.bmp

Goal 8 (Javanotes Ch 2.1-2.2)

1. Briefly explain what is meant by the syntax and the semantics of a programming language. Give an example to illustrate the difference between a syntax error and a semantics error.

  • The syntax of a language consists of the rules and vocabulary that allow the program to be compiled and executed. Programs that contain syntax errors are rejected and fail to compile. The semantics of a program is its meaning. A program with correct semantics does what you wanted it to do. An example is if your syntax was correct, that is your code was written properly with no mistakes, but the result is "!dlroW olleH" instead of "Hello World!". There is no error in compiling because all of the syntax is correct, but the semantics are wrong because the program did not do what it was meant to do.

2. What does the computer do when it executes a variable declaration statement? Give an example.

  • When the computer executes a variable declaration statement, it sets aside memory for the variable so that the variable can later be executed. Example:
String nickApseloff; //Variable declaration statement

3. What is a type, as this term relates to programming?

  • Types are the kinds of characters and digits syntactically allowed to be stored in Java variables. The eight types in Java are byte, short, int, long, float, double, char, and boolean.

4. One of the primitive types in Java is boolean. What is the boolean type? Where are boolean values used? What are its possible values?

  • The boolean type is either true or false, and represents a value, not a variable. They are generally used in conditional statements where a comparison is necessary.

6. Explain what is meant by an assignment statement, and give an example.

  • An assignment statement gives a variable a data value. Example:
nickApseloff = "Wiki master"; //Variable assignment statement

8. What is a literal?

  • A literal is a constant value like a character or a number.

9. In Java, classes have two fundamentally different purposes. What are they?

  • The two purposes of classes are to contain subroutines and describe subroutines and objects.

Goal 9 (Javanotes Ch 2.3-2.4)

10. What is the difference between the statement "x = TextIO.getDouble();" and the statement "x = TextIO.getlnDouble();"

  • In TextIO.getlnDouble(), all characters entered after the input are discarded, while TextIO.getDouble() saves those extra characters in the input buffer. The program will then look at the input buffer before the user response when next prompted for an input.

Goal 10 (Javanotes Ch 2.5-2.6)

5. Give the meaning of each of the following Java operators:

a) ++ -> x = x + 1
b) && -> and (used to combine two boolean values)
c) != -> not equal to

7. What is meant by precedence of operators?

  • Precedence of operators is to Java as order of operations is to math. In math, you have the acronym PEMDAS (parentheses, exponents, multiply, divide, add, subtract) that tells you in what order to perform operations. In Java, there is a set order in which operators take precedence over others when evaluating an equation.

11. Explain why the value of the expression 2 + 3 + "test" is the string "5test" while the value of the expression "test" + 2 + 3 is the string "test23". What is the value of "test" + 2 * 3 ?

  • The reason is because of the order of operations. In the first expression, the order goes as follows: (2 + 3) + "test" = 5 + "test" = "5test". In the second expression, it is evaluated: ("test" + 2) + 3 = "test2" + 3 = "test23". The final expression would be evaluated as: "test" + (2 * 3) = "test" + 6 = "test6".

12. Integrated Development Environments such as Eclipse often use syntax coloring, which assigns various colors to the characters in a program to reflect the syntax of the language. A student notices that Eclipse colors the word String differently from int, double, and boolean. The student asks why String should be a different color, since all these words are names of types. What's the answer to the student's question?

  • String is a different color because it is a name of a class, while the others are just types.

References