170 likes | 184 Views
Explore the fundamentals of programming robots with Java through a hands-on project at Linglestown Middle School in Spring 2010. Get insights on ASIMO, LEGO Mindstorms, and Roomba technology for a comprehensive understanding. Learn about key Java classes like TextLCD, Motor, Sound, and Button to control robot features effectively. Experience creating a program displaying text, controlling motors, and playing sounds with a descending arpeggio. Dive into the world of robotic programming and enhance your skills!
E N D
Programming Robots using Java Linglestown Middle School Penn State Harrisburg Spring 2010 Jane S. Kochanov
http://marsrovers.jpl.nasa.gov/mission/spacecraft_surface_rover.htmlhttp://marsrovers.jpl.nasa.gov/mission/spacecraft_surface_rover.html
Roomba Intelligent Floorvac Robotic Vacuum • Roomba 4100 Intelligent Floorvac Robotic Vacuum - Red. • Dirt detection and infra-red cliff sensors. • Auto adjusts to any floor surface • 2-hour continuous cleaning • Virtual wall for confining to designated area • Rechargeable APS battery, 7-hour charger • Measures 13 by 4 inches www.totalvac.com
Virtual Guard Dog • It sports a digital camera, infrared sensors and videophone capability so absent homeowners can be notified of intruders. • 280,000 yen ($2,600) contraption by Japanese robot maker Tmsuk Co. Ltd. and Sanyo Electric Co. Ltd. http://www.cnn.com/2005/TECH/ptech/06/02/roborior.ap/
Hospital Courier • TUG • 50 pounds • Ferries linens, X-rays, drugs, food • Made by Pittsburgh-based Aethon • Uses wireless radios to call elevators or open automatic doors http://www.aethon.com
ASIMO • Advanced Step in Innovative Mobility • Humanoid Robot built by Honda • Introduced in November 2000 • ASIMO video
LEGO Mindstorms Robot • Robot Kit includes: • RCX (Robotics Command Explorer) • 2 Motors • 2 touch sensors • 1 light sensor • USB infrared transmitter tower • A “gazillion” lego parts to build a robot
LEGO Mindstorms Robot • RCX runs on 6 AA batteries • When batteries are low, battery icon with an “X” across it will appear in the display • 3 gray ports labeled 1, 2, 3 • Sensor ports • 3 black ports labeled A, B, C • Motor ports
LEGO Mindstorms Robot • 4 buttons • On-Off • Run to execute and stop a loaded program • Prgm to scroll through the loaded programs • May load up to 5 programs at one time • View allows you to view information on a sensor or motor
LEGO Mindstorms Robot • Display Window • A little person standing or running • Indicates that a program is loaded or running respectively • To the right of the little person, a number indicating which of 5 programs will be active when the Run program is pressed • To the left of the little person, the Software Watch • Shows program being downloaded. It counts units of 100 bytes, so a 3 Kb program counts up to ~ 30 • Shows the voltage level of the battery
LEGO Java Operating System • Provides a Java package to control the RCX: josx.platform.rcx.* • Provides Java classes for working with the RCX features: • Motors • Sensors • Display • Sound • Buttons • IR tower
LEGO Java Operating System TextLCD class: • Uses the display to show text messages. This class uses a great deal of memory. The letters are approximations since the display was originally intended for numbers. print (“text”) - prints the text on the LCD. Only the first five letters are displayed.
LEGO Java Operating System Motorclass: • Used to control the RCX output ports which control the motors. The class contains 3 static Motor instances, A, B, and C, which correspond to the 3 output ports. setPower(int) - sets the current power level of the motor from 0 to 7. backward( ) - moves the motor backwards. forward( ) - moves the motor forwards. stop( ) - stops the motor. reverseDirection( ) - no matter which way the motor is turning, it makes it turn the other way.
LEGO Java Operating System Soundclass: • The robot is able to play sounds for different tasks you might want to program playTone(int Frequency, int Duration) - - plays a tone in the range 1 - 20000 Hz given by Frequency. The tone is played for Duration: to play 1 second, use 100. It is truncated at 256, meaning that 2.56 seconds is the maximum duration possible.
LEGO Java Operating System • systemSound(true/false, int Code ) – plays one of the predefined tones.
LEGO Java Operating System Buttonclass: • Encapsules 3 RCX buttons View, Prgm, Run. You may call a static instance of each button using VIEW, PRGM, and RUN. waitForPressAndRelease( ) throws InterrupedException - wait until the button is released
Let’s Try • Create a simple program together that: • Displays a word to the LCD • Start one motor • Start the other motor • Play a descending arpeggio before the motors start • Run until the RUN button is pressed