Modules

U Kinect

This UObject makes it possible to control the Microsoft Kinect interface (http://www.xbox.com/en-US/kinect) in urbiscript. This project is a part of the OpenKinect project (http://openkinect.org) that tries to make as many programming tools using Linux, Mac or Windows as possible compatible with the Kinect without having to use an Xbox360.

I believe this project is interesting as far as robotics goes and there's nothing like it for Urbi so far (i.e: http://www.ros.org/wiki/kinect). A binding with Linux would be very cool. Here's a Windows version implementing the "high-level" API (I'll make a full wrapper if others are interested). The package includes the prj VS2008 with the latest Windows driver available (source included).

UObject UKinect by Zappadoc (c)2010implementation and usage
var Global.kin = UKinect.new;UObject instance
kin.setDeviceID = n;default = 1 (first device)
kin.close;cleanup kinect session
kin.open;open session param: kinect ID
kin.deviceReady;device state (1 = ready)
kin.deviceCount;num of kinect device detected
kin.deviceID;current kinect device ID
kin.width;image width 640
kin.height;image height 480
kin.colordata;color or IR UBinary type image RGB 640 x 480
kin.depthdata;depth UBinary type image RGB 640 x 480
kin.val;depth UBinary type image RGB 640 x 480
kin.rgbmode = n;n= 0 = normal color - n= 1 to IR data
kin.showdepth;open kinect depth window
kin.hidedepth;close kinect depth window
kin.showcolor;open kinect color window
kin.hidecolor;close kinect color window
kin.showall;open kinect depth and color windows
kin.hideall;close kinect depth and color windows
kin.startcapture;start capture param: CAM ID
kin.stopcapture;stop capture CAM
kin.motor = n;move kinect vertically n from 0.0 to 1.0
kin.led = n ;change led color(mode) n from 0 to 7
kin.kX;accelerometer value X
kin.kY;accelerometer value Y
kin.kZ;accelerometer value Z
//-------------------------------------------------------------------------------
// kinectdemo()
// param: None
//-------------------------------------------------------------------------------
var Global.kinectdemo = function ()
{
 // kinect instance
 var Global.kin = UKinect.new;
 // open device
 if(kin.open==1)
 {
  echo(Start Demo);
  echo(Number of Kinect detected:  + 
   kin.deviceCount + \n);

  // move kinect motor (from 0.0 to 1.0)
  kin.motor = 0.6;

  // display accelerometer value
  echo(  X:  + kin.kX + 
    Y:  + kin.kY + 
    Z:  + kin.kZ);

  // change led mode
  for(var j = 0; j<8; j++){
   kin.led = j;
  };

  // show yellow led
  kin.led = 3;

  // show depth and color windows (use OpenCV)
  kin.showall;

  // Kinect WIN32 driver workaround
  // Use this workaround below to trigger color data...
  // start capture CAM
  kin.startcapture(1);
  // stop capture CAM
  kin.stopcapture;

  // rgbmode = 0 or 1 to swap from normal to IR color

  // use kin.close to cleanup the session
  echo(\nType: kin.kclose to end the demo\n\n);

 };
}|; 

Options: