1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

amstracker in nodebox

Posted by tiep on Aug 31, 2007



for who it might be of interest .. or just for the fun.

AMSTracker is a command-line program that retrieves acceleration data from the Sudden Motion Sensor in Apple notebook computers.

download amstracker at
http://www.osxbook.com/software/sms/amstracker/


you can create a pipe that will transfer data from the command line tool to nodebox by using popen() command.

in this case ..

size(400,400)
speed(10)
from math import *
from os import popen
global count
count = 0
trail,this = [],[]
 
'''
READS AND CLEANS GIVEN DATA FROM AMSTRACKER 
Only X and Y are in use here/ there is also a Z output
(doesnt seem to do that much)
AMSTRACKER MUST BE IN APPLICATIONS FOLDER.
the popen() command opens a pipe to read directly 
from a command line based app or tool
'''
def readsms():
    global Xas,Yas
    pipe = popen('/Applications/AMSTracker','r')
    liner = pipe.readlines()
    clean = liner[1]
    this.append(clean)
    if len(this) >= 2:
        del this[0]
    all = this[0]
    Xas = all[0:4];Yas = all[10:15]
    #print Xas, Yas # uncomment to see if you get the input..
 
def draw():
    translate(WIDTH/2,HEIGHT/2)
    readsms()
    global count
    count+=0.25
    fill(0)
    # DEFINE SOME VARIABLES
    m1 = 60.0
    x1 = float(Xas)*2.0-70
    y1 = float(Yas)*2.0
    xxx1 = x1*sin(count)
    yyy1 = y1*cos(count)
    # BUILD A LIST OF POINTS FOR A TRAIL FX
    punt = xxx1,yyy1
    trail.append(punt)
    if len(trail)>=15:
        del(trail[0])
    # DRAW THE THING: i-loop for WORM c-loop for 'HEAD'
    for i in range(len(trail)):
        # STORE EVERY POINT, 1 POINT BACK AND FIRST POINT 
        pt = trail[i]
        pr = trail[i-1]
        pf = trail[len(trail)-1]
        strokewidth(5.0)
        if (i>0):
            stroke(.8,(15-i)/16.0,0.4,.8);  
            line(pt[0],pt[1],pr[0],pr[1])
            strokewidth(.1)
            line(pt[0],pt[1],pf[0],pf[1])
            groot = m1+15.0*sin(i)
            fill((15-i)/16.0,.8,0,.6);strokewidth(.5)
            oval(pt[0]-groot/2,pt[1]-groot/2,groot,groot)
            for c in range(9):
                nostroke(); fill((15-i)/16.0,.8,0,.2);
                tal = random(.1)*FRAME;Hb = groot*.5
                xp = (m1/2*sin(c*tal))+Hb/2
                yp = (m1/2*cos(c*tal))+Hb/2
                oval(pt[0]-xp,pt[1]-yp,Hb,Hb)
start throwing the machine :)


 
Posted by tiep on Aug 31, 2007

im having trouble with the codepart in the editor (help-:)
you might remove the ' between STORE and EVERY .
copy and paste seems to do the trick..
action: http://www.youtube.com/watch?v=nNZG54qE94U



Posted by Tom De Smedt on Sep 05, 2007

It would be nice if we bundled this into a library. However, the author of AMStracker prohibits redistributing his application. If we could get his permission to bundle the tool in a NodeBox library we would have a fun little toy.

Best regards,
Tom



Posted by tiep on Sep 11, 2007

do I or do U send him a mail ?
or did you already ? it would be
stupid to do it twice ..



Posted by Tom De Smedt on Sep 11, 2007

Best if you do it. Then you can give an example of possible usage with your project.