Sensor Tile Project: 29 Oct 2014 Miles, Brian, Gabby

Today we found a bunch of information, and here is said information.

Blue = Gabby

Brown/Red/Maroon..? = Miles

 

(ノ ゜Д゜)ノ ︵ OI∩┴

 

https://trac.v2.nl/wiki/pyOSC

^ This is in Python, it’s another implementation of OSC.

http://casparcg.com/wiki/CasparCG_OSC_Protocol

Server side software to relay OSC messages to a client.

http://archive.cnmat.berkeley.edu/OSC/src/sendOSC/

^ that’s for C, Client

 

oscP5 (for processing)

https://processing.org/reference/libraries/ download it here

http://www.sojamo.de/libraries/oscp5/ last updated in 2012, better than 2008

http://learning.codasign.com/index.php?title=Sending_and_Receiving_OSC_Data_Using_Processing basic example

Python OSC (… for Python, duh)

https://pypi.python.org/pypi/python-osc download it here or pip install it whatevs

https://github.com/attwad/python-osc last updated a few days ago

Examples include making a server and a client

 

SimpleOSC for python (requires pyOSC, which is linked up top)

http://www.ixi-audio.net/content/body_backyard_python.html supposedly simplifies the API or whatever for pyOSC

 

osc  (for javascript)

https://www.npmjs.org/package/osc Woo

So to compare them…

 

oscP5 for processing:

 

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;

void setup() {
size(400,400);

// start oscP5, telling it to listen for incoming messages at port 5001 */
oscP5 = new OscP5(this,5001);

// set the remote location to be the localhost on port 5001
myRemoteLocation = new NetAddress(“127.0.0.1”,5001);
}

void draw()
{

}

void mousePressed() {
// create an osc message
OscMessage myMessage = new OscMessage(“/test”);

myMessage.add(123); // add an int to the osc message
myMessage.add(12.34); // add a float to the osc message
myMessage.add(“some text!”); // add a string to the osc message

// send the message
oscP5.send(myMessage, myRemoteLocation);
}

void oscEvent(OscMessage theOscMessage)
{
// get the first value as an integer
int firstValue = theOscMessage.get(0).intValue();

// get the second value as a float  
float secondValue = theOscMessage.get(1).floatValue();

// get the third value as a string
String thirdValue = theOscMessage.get(2).stringValue();

// print out the message
print(“OSC Message Recieved: “);
print(theOscMessage.addrPattern() + ” “);
println(firstValue + ” ” + secondValue + ” ” + thirdValue);
}

 

Python OSC:

 

(server)

 

import argparse
import math
 
from pythonosc import dispatcher
from pythonosc import osc_server
 
def print_volume_handler(unused_addr, args, volume):
print(“[{0}] ~ {1}”.format(args[0], volume))
 
def print_compute_handler(unused_addr, args, volume):
try:
  print(“[{0}] ~ {1}”.format(args[0], args[1](volume)))
except ValueError: pass
 
if __name__ == “__main__”:
parser = argparse.ArgumentParser()
parser.add_argument(“–ip”,
    default=“0.0.0.0”, help=“The ip to listen on”)
parser.add_argument(“–port”,
    type=int, default=5005, help=“The port to listen on”)
args = parser.parse_args()
 
dispatcher = dispatcher.Dispatcher()
dispatcher.map(“/debug”, print)
dispatcher.map(“/volume”, print_volume_handler, “Volume”)
dispatcher.map(“/logvolume”, print_compute_handler, “Log volume”, math.log)
 
server = osc_server.ThreadingOSCUDPServer(
    (args.ip, args.port), dispatcher)
print(“Serving on {}”.format(server.server_address))
server.serve_forever()

 

(client)

 

“””Small example OSC client
 
This program sends 10 random values between 0.0 and 1.0 to the /filter address,
waiting for 1 seconds between each value.
“””
import argparse
import random
import time
 
from pythonosc import osc_message_builder
from pythonosc import udp_client
 
 
if __name__ == “__main__”:
parser = argparse.ArgumentParser()
parser.add_argument(“–ip”, default=“127.0.0.1”,
    help=“The ip of the OSC server”)
parser.add_argument(“–port”, type=int, default=8000,
    help=“The port the OSC server is listening on”)
args = parser.parse_args()
 
client = udp_client.UDPClient(args.ip, args.port)
 
for x in range(10):
  msg = osc_message_builder.OscMessageBuilder(address = “/filter”)
  msg.add_arg(random.random())
  msg = msg.build()
  client.send(msg)
  time.sleep(1)

 

pyOSC

(send)

  1. #!/usr/bin/env python3
  2. from OSC import OSCClient, OSCMessage
  3. client = OSCClient()
  4. client.connect( (“localhost”, 7110) )
  5. client.send( OSCMessage(“/user/1”, [1.0, 2.0, 3.0 ] ) )
  6. client.send( OSCMessage(“/user/2”, [2.0, 3.0, 4.0 ] ) )
  7. client.send( OSCMessage(“/user/3”, [2.0, 3.0, 3.1 ] ) )
  8. client.send( OSCMessage(“/user/4”, [3.2, 3.4, 6.0 ] ) )
  9. client.send( OSCMessage(“/quit”) )

 

(receive)

  1. #!/usr/bin/env python3
  2. from OSC import OSCServer
  3. import sys
  4. from time import sleep
  5. server = OSCServer( (“localhost”, 7110) )
  6. server.timeout = 0
  7. run = True
  8. # this method of reporting timeouts only works by convention
  9. # that before calling handle_request() field .timed_out is
  10. # set to False
  11. def handle_timeout(self):
  12.   self.timed_out = True
  13. # funny python’s way to add a method to an instance of a class
  14. import types
  15. server.handle_timeout = types.MethodType(handle_timeout, server)
  16. def user_callback(path, tags, args, source):
  17.   # which user will be determined by path:
  18.   # we just throw away all slashes and join together what’s left
  19.   user = ”.join(path.split(“/”))
  20.   # tags will contain ‘fff’
  21.   # args is a OSCMessage with data
  22.   # source is where the message came from (in case you need to reply)
  23.   print (“Now do something with”, user,args[2],args[0],1-args[1])
  24. def quit_callback(path, tags, args, source):
  25.   # don’t do this at home (or it’ll quit blender)
  26.   global run
  27.   run = False
  28. server.addMsgHandler( “/user/1”, user_callback )
  29. server.addMsgHandler( “/user/2”, user_callback )
  30. server.addMsgHandler( “/user/3”, user_callback )
  31. server.addMsgHandler( “/user/4”, user_callback )
  32. server.addMsgHandler( “/quit”, quit_callback )
  33. # user script that’s called by the game engine every frame
  34. def each_frame():
  35.   # clear timed_out flag
  36.   server.timed_out = False
  37.   # handle all pending requests then return
  38.   while not server.timed_out:
  39.       server.handle_request()
  40. # simulate a “game engine”
  41. while run:
  42.   # do the game stuff:
  43.   sleep(1)
  44.   # call user script
  45.   each_frame()
  46. server.close()

 

SimpleOSC:

from simpleOSC import initOSCClient, initOSCServer, setOSCHandler, sendOSCMsg, closeOSC, \

createOSCBundle, sendOSCBundle, startOSCServer

 

 

def myTest():

“”” a simple function that creates the necesary sockets and enters an enless

loop sending and receiving OSC

“””

import time # in this example we will have a small delay in the while loop

 

initOSCClient() # takes args : ip, port

initOSCServer() # takes args : ip, port, mode –> 0 for basic server, 1 for threading server, 2 for forking server

 

# bind addresses to functions

setOSCHandler(‘/check’, checkcheckcheck)

 

startOSCServer() # and now set it into action

 

print ‘ready to receive and send osc messages …’

 

try:

while 1:

sendOSCMsg(“/test”, [444]) # !! it sends by default to localhost ip “127.0.0.1” and port 9000

 

# create and send a bundle

bundle = createOSCBundle(“/test/bndlprt1”)

bundle.append(666) # 1st message appent to bundle

bundle.append(“the number of the beast”) # 2nd message appent to bundle

sendOSCBundle(bundle) # !! it sends by default to localhost ip “127.0.0.1” and port 9000

 

time.sleep(0.5) # you don’t need this, but otherwise we’re sending as fast as possible.

 

except KeyboardInterrupt:

print “closing all OSC connections… and exit”

closeOSC() # finally close the connection before exiting or program.

 

 

“”” Below a function dealing with OSC messages RECEIVED into Python.

 

Here you can set all the responders you need to deal with the incoming

OSC messages.

“””

 

def checkcheckcheck(addr, tags, data, source):

print “CHECK CHECK CHECK…”

print “received new osc msg from %s” % getUrlStr(source)

print “with addr : %s” % addr

print “typetags :%s” % tags

print “the actual data is : %s” % data

if __name__ == ‘__main__’: myTest()

 

lalala

 

 

Posted in Uncategorized | Leave a comment

Sensor Tiles Project: Unity Team: Frank & Dwayne – Re-research Unity Licenses

For today, we had to step a back with our project because in the Terms Of Agreement for Unity, not all licenses can be mixed in terms of features, functionality, and content with the Pro version of Unity. However, we have rectified the problem thus far and are now working to collborate with Walle and plan our next move.

Onto lighter news though, since we started with Walle, we have managed to narrow our focus for using Unity to the point where we now know which licenses must be used, although we need to refine a couple of minor details such as which license to use for the remainder of the semester. However, if all goes well on this portion of the project, it is possible that this version of Unity we use can be used for other classes in the Emerging Media Technology program.

Our next step is to figure a permanent workstation for the Unity Team so that we can install the potential license onto that computer and continue to work on using Blender to create our objects and animations and then be able to move those objects and continue our workflow in Unity.

Posted in Assignments, Damon Baker, DOCUMENTATION, Journals, Lab Notes, Lab Reports | Tagged , , , , , , , , , , , , | Leave a comment

Sensor Tiles Project: Unity Team: Frank & Dwayne – Similarities and Differences Between Blender and Unity

For today, we conducted research into how similar in functionality Blender and Unity really are. During the course of these 3 weeks since we have started our research into using Unity, we have always asked ourselves how similar are the two programs and can we really use both programs in tandem to further our progression in this project.

Thus far, we have decided to narrow our focus to utilizing animation, objects and game programming with Python.

We have several videos that helps to address many of our concerns regarding the two programs and our options for using both in as a long term juncture.

Using Blender with Unity:

https://www.youtube.com/watch?v=6dhK1UGzbUU

These series of videos helps to answer our question regarding interface and workflow:

Blender To Unity 3D

This forum also helps to answer some of our nagging questions between both programs:

Yahoo Answers

This blog talk in depth about the differences, similarities and strengths about many of today’s most popular game engines and 3d modeling software, including Blender and Unity.

Which Software To Use In The 3D Modeling World

Our next step is to collaborate with Wale and discuss our options regarding licenses and which ones could be appropriate for our project going forward.

Posted in Assignments, Damon Baker, DOCUMENTATION, Journals, Lab Notes, Lab Reports | Tagged , , , , , , , , , , , , | Leave a comment

Further

Still having path issues, but we’ve chewed through G++ a little.

the command g++ -fPIC -I/path/to/python.3.3/include/python3.3/ LeapPython.cpp /usr/lib/leap/libLeap.so -shared -o LeapPython.so isn’t complete.

First, we need to make that “path/to/python/3.3/include/python3.3” bit actually go to our Python directory. It occurs to me to use $PYTHONPATH, however this is blank.

When re run Python, and print out sys.path, we get our Anaconda directory. So Anaconda hijacks our path variable and takes its place. Not a problem, just an observation.

So now we have the command g++ -fPIC -I~/anaconda3/include/python3.4m/ LeapPython.cpp /usr/lib/leap/libLeap.so -shared -o LeapPython.so

Same error, and we look inside of Leap.i because this is what SWIG uses to generate our LeapPython.cpp file. We see that it also includes “Python.h” and so we append our anaconda directory to it, resulting in ‘#include “~/anaconda3/include/python3.4m/Python.h” and this gets us to Leap.h not found. We find Leap.h in Leap.i and repeat, now with “~/leapmotion-blender-master/pack/Leap.h” and we still get Leap.h not being found.

However, by some strange magick, typing in the full /home/ada/leapmotion-blender-master/pack/Leap.h works! We compile our LeapPython.so successfully!

I notice that we’re using an anaconda environment 3.4 where Blender uses 3.3. We should change that environment to make it work for next time.

Posted in Assignments, DOCUMENTATION | Tagged , , , , , , , , , , , , , | Leave a comment

Leap Motion + Linux

Gabby (in Studio Blue [↓]) Remy, Xuemin

Ok! So, no post from last week because we were too aggravated and ashamed to write about how we growled and kicked at it for hours, got it to work once and then broke it immediately afterwards to write anything, so today we’re starting over and thus far we have good things!

We took Ishik’s recipe from here and inserted the full file path of the needed Leap SDK files (Leap.i) and ran the conda build leapmotion-blender command. This gets us through the hurdle of Leap.i not being found, and it allows us to step forward with the next command: the g++ stuff.

We’re now having trouble where G++ can’t find Python.h. We tried to remedy this by installing python-dev, which includes this, however g++ can’t find it. Until next time!

Posted in DOCUMENTATION | Tagged , , , , , , , , | Leave a comment

Sensor Tile Project: Gabby, Miles, Brian, Kenneth, Al, Reno

For today, we re examined the code from the previous class and used the previous blog post as a reminder of what we had done. We looked through the various java files that were apart of the jar that were apart of the TUIO client. This included the library for OSC/TUIO itself and the wrapper for processing. We attempted to add functions for changing, inserting, or otherwise printing the port to no success. This did not work because java’s encapsulation methods are foreign to both Miles and Gabbys programming experience. So, we further tried to modify demo in processing to no avail. We used http://www.tutorialspoint.com/java/java_encapsulation.htm as a reference and looked into extending and implementing an interface in java in an attempt to make the code work. This also failed epically. For next class we will gather more information to further our progress.

Measurements are still in progress of transferring to a digital interface.

Posted in Uncategorized | Leave a comment

Sensor Tiles Project: Unity Team: Frank & Dwayne – Moving Assets Between Blender and Unity Interchangeably

For today, we conducted further research into the extent that one program is able to move assests into another. We focused primarily on moving objects, animations, artwork from Blender into Unity and how much Unity will accept of Blender’s features (i.e. shapes, colors, vectors, keyframes, meshes, etc.).

Thus far, we have found this very helpful tutorial by Blender ‘s website which teaches you how to create an object, move it into Unity, how much Unity accepts from Blender and how you move the asset back into Blender.

Here is the video:

Animated Door Created For Unity 3D

Our next step is to collaborate with Walle and conduct research into how we can how we can fully utilize Unity’s playback, animation and Game related features.

Posted in Assignments, Damon Baker, DOCUMENTATION, Journals, Lab Notes, Lab Reports, PROJECTS | Tagged , , , , , , , , , , | Leave a comment

Sensor Tile Project: Brian, Kenneth, Reno, Al, Miles, Gabby

For today, we re-verified all steps to complete setup of sensor tile project. Port forwarding was setup and confirmed to work. Gabby was informed that some writing was already done regarding the use and setup of port forwarding. Following this, Miles and Gabby attempted to use the processing version of the TUIO client to no success. They looked at the code for TUIO client using a .jar de-compiler.  We attempted to make a modified .jar file. Also to no success even after attempting to edit the code in Eclipse. For next class we will set up Eclipse to export a .jar file and hopefully it will work. Taking more measurements of room and will will begin to convert measurements into autocac For next class we will be conducting more research at http://www.tuio.org/?java. We are also going to change the port to 514.

Posted in Uncategorized | Leave a comment

Sensor Tiles Project: Unity Team Frank & Dwayne – Blender Into Unity Workflow

For today, we have conducted research as to how we can work on an object created and started in Blender and then import those objects into Unity to continue the workflow.

Thus far, we have been creating our own video to demonstrate this process. However, for the time being we will be using this video as a reference to convey our purpose for the video we will create.

Our next step is to conduct research into creating and moving assets interchangeably between Blender and Unity and understanding how we can use the unique strengths of each software to further our progression of this project.

Posted in Assignments, Damon Baker, DOCUMENTATION, Lab Notes, Lab Reports | Tagged , , , , , , , , , | Leave a comment

Leap and Blender

Gabby, Ishik, Remy, Xuemin

Ok so we’ve gone around in circles a little lot. We were following the guide here telling how to use SWIG to wrap from Python 2.7 to Python 3.3. So we set off downloading Visual Studio 2012 and SWIG, couldn’t figure out how to get SWIG working on Windows (which we did figure out within the last minutes of class), got our hands on Ishik’s recipe from last semester which turns out is Linux and OS X only, and we also figured out how to have the user deal with using Python requiring the SDK because it’s not quite clear which files are and aren’t redistributable (need to figure this out, I’ve found one that is not redistributable and none that specifically are [the SDK says you have to use specifically redistributable stuff])

Next class plan: Get this to definitively work on Linux, then OS X, and have someone else find other Python packages to have ready for demo at the Blender conference. If we have spare time, tackle windows (like a wall).

Pure Python packages to get working: ipython

Posted in Assignments, DOCUMENTATION | Tagged | Leave a comment