Archive for May 18th, 2007

com.sun.robot.humanoid — the Office Toy in JBoss/RedHat Austin

Friday, May 18th, 2007

Phillip and I bought the "Java robot" from JavaOne, and decided to keep it in the office as an "office toy". This is easily the coolest geek toy I have seen in years. It can walk around, sit / get up, pick up stuff with its hands, speak / sing (plays any MP3), play video / games on its LCD screen, and even take pictures. It detects and responds to sound, visual objects, and colors. It can even automatically recognize and follow humans. Of course, it can be remotely controlled as well.

Picture 7.png

But the best feature of all is that the robot runs Linux and can be programmed via a simple Java API! There is a simple Java wrapper class that allows your application to interact with all sensors and motors on the robot. You typically run your application in a loop, and try to make the robot respond to events coming in from the sensors. I have not tried but here is some sample code from the SDK. You are smarter than the robot and can figure out what it is supposed to do. :) Isn't that COOL!

JAVA:
  1. Humanoid humanoid = Humanoid.getInstance();
  2.  
  3. ... ...
  4.  
  5. while (true) {
  6.   // Turn off the bright LED in the eyes.
  7.   humanoid.enableLED(false);
  8.            
  9.   // Look around.
  10.   humanoid.VISION.track();
  11.            
  12.   // Check for color red in vision field. Run to red.
  13.   if (humanoid.VISION.getTarget(Vision.RED)) {
  14.     // Turn on the LED in eyes to signal that it sees RED
  15.     humanoid.enableLED(true);
  16.                
  17.     // Advance on target.
  18.     humanoid.WALK.walk(Walk.FORWARD_GAIT1, 10);   
  19.                
  20.     // Are we at the bump?
  21.     If (humanoid.TOUCH_LEFT_FOOT_FRONT.isTriggered()||
  22.               (humanoid.TOUCH_RIGHT_FOOT_FRONT.isTriggered()) {
  23.       // We are done.
  24.       break;
  25.     }
  26.   } else {
  27.     // Do not see RED in current vision field -- so the robot moves around to search for RED
  28.     boolean wanderLeft = 1 != rand.nextInt(1);
  29.              
  30.     // Wander left or right
  31.     if( wanderLeft ) {
  32.       humanoid.WALK.turnRight(2);
  33.     } else {
  34.       humanoid.WALK.turnRight(2);
  35.     }
  36.              
  37.     // Walk forward a bit
  38.     humanoid.WALK.walk(Walk.FORWARD_GAITFAST, rand.nextInt(3) + 3);
  39.   }
  40. }
  41.  
  42. // Raise the arm to declare victory
  43. humanoid.SHOULDER_LEFT_SERVO.moveToPosition(
  44.   humanoid.SHOULDER_LEFT_SERVO.maxPosition() / 4,
  45.   humanoid.SHOULDER_LEFT_SERVO.maxSpeed());
  46.  
  47. // Take a picture of the RED target and display it on the LCD
  48. String pictureFile = humanoid.CAMERA.takePhoto(0);
  49. humanoid.CAMERA.displayImage(pictureFile, 5000);
  50.  
  51. // Say something
  52. humanoid.AUDIO.playClip(mission_accomplished.mp3);
  53. ... ...

The robot is BIG -- it was a challenge to bring it back from San Francisco. :) Just notice how big it is compared with Phillip's 19" monitor in the background.

Picture 6.png

Anyway, we have not officially started playing with it yet (product release deadlines! ;)). I will continue to blog about it here in this blog as we discover its features. If you have ideas on applications, leave a comment -- we might implement it and post a video!