emoc

Joined: Aug 24, 2006 Posts: 12 Location: France
|
Posted: Fri Sep 07, 2007 3:44 pm Post subject:
Chuck, Reactivision & OSC Subject description: an attempt to use the reactable software |
 |
|
Hi,
I'm trying to implement the reactivision TUIO/OSC receiver for ChucK.
Reactivision is the open-source software behind reactable. It runs a communication protocol based on OSC called TUIO (tangible user interface..., ). A "Tuio simulator" (java applet) helps debugging. This simulator is already a nice interface : each object can be rotated & moved and physics data are transmited through TUIO / OSC
reactable : http://mtg.upf.edu/reactable/
TUIO http://modin.yuri.at/publications/tuio_gw2005.pdf
TUIO simulator http://mtg.upf.edu/reactable/?software
To fully implement, the receiver must catch three different message : alive, set, and fseq. 'set' and 'fseq' are predefined formats but alive changes with how much objects are on the table. 'set' messages are the most important because they carry physics data (motion, position) and you can already have fun with it! (and the script below)
Code: | /tuio/[profileName] set sessionID [parameterList]
/tuio/[profileName] alive [list of active sessionIDs]
/tuio/[profileName] fseq int32 |
The script chuck below catch 'set' & 'fseq' messages, but to catch 'alive' messages, you'll need flexible pattern matching, if there's any way to do it with ChucK ???
A dirty hack & code nightmare could be to add as much osc receivers as objects on the table each trying to catch one more integer...
Code: | // 7 sept. 2007 / chuck 1.2.1.0 /
// nom de l'hote et port par défaut
"localhost" => string hostName;
3333 => int receiverPort;
<<< "port de reception pour les messages OSC:", receiverPort >>>;
// objet OSC pour la réception
OscRecv receiver;
receiverPort => receiver.port;
// commencer l'écoute sur le port
receiver.listen();
// créer une adresse réceptrice des messages, y stocker la valeur de fréquence reçue
receiver.event( "/tuio/2Dobj,s,i,i,f,f,f,f,f,f,f,f" ) @=> OscEvent oeset;
receiver.event( "/tuio/2Dobj,s,i" ) @=> OscEvent oe1;
string a_type; int a_sessionid; int a_fiducialid; float a_xcoord; float a_ycoord;
float a_angle; float a_xmov; float a_ymov; float a_rotation;
float a_movaccel; float a_rotaccel; int frame_id; int nb;
fun void oesetListener() {
while ( true ) {
oeset => now; // en attente de l'arrivée d'un message OSC
// capturer le nouveau message
while ( oeset.nextMsg() != 0 ) {
oeset.getString() => a_type; // = set string
oeset.getInt() => a_sessionid; // session ID, temporary ID, int32
oeset.getInt() => a_fiducialid; // fiducial ID number, int32
oeset.getFloat() => a_xcoord; // position, range 0..1, float32
oeset.getFloat() => a_ycoord; // position, range 0..1, float32
oeset.getFloat() => a_angle; // angle, range 0..2PI, float32
oeset.getFloat() => a_xmov; // movement vector, float32
oeset.getFloat() => a_ymov; // movement vector, float32
oeset.getFloat() => a_rotation; // roration vector, float32
oeset.getFloat() => a_movaccel; // motion acceleration, float32
oeset.getFloat() => a_rotaccel; // rotation acceleration, float32
<<<"set : ", a_sessionid, a_fiducialid, a_xcoord, a_ycoord,
a_angle, a_xmov, a_ymov, a_rotation, a_movaccel, a_rotaccel>>>;
}
}
}
spork ~ oesetListener();
fun void oe1Listener() {
while ( true ) {
oe1 => now; // en attente de l'arrivée d'un message OSC
while ( oe1.nextMsg() != 0 ) { // capturer le nouveau message
oe1.getString() => a_type; // = fseq || alive string
oe1.getInt() => nb; // frame ID || object sessionID,int32
<<<a_type, " : ", nb>>>;
}
}
}
spork ~ oe1Listener();
while (true) {
0.5::second => now;
}
|
_________________ codelab.fr |
|
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Sep 07, 2007 7:36 pm Post subject:
Re: Chuck, Reactivision & OSC Subject description: an attempt to use the reactable software |
 |
|
emoc wrote: |
The script chuck below catch 'set' & 'fseq' messages, but to catch 'alive' messages, you'll need flexible pattern matching, if there's any way to do it with ChucK ???
A dirty hack & code nightmare could be to add as much osc receivers as objects on the table each trying to catch one more integer...
|
Hmmm, A good first step might be one OSC receiver that would parse OSC, then send ChucK events for the different shreds? That would at least save the OSC receivers. I'm not sure wether you can make a array of events but that would be a possible solution.... You could just make a array of those that's longer then the amount of blocks that you have and asign one to each shred as you start it. I don't think unused events have any real overhead that matters.
Disclaimer; it's 4:30 here and I haven't thought this through. _________________ Kassen |
|