Category: Assignment-09-Documentation

Rachel-Interactive Development Environment

 

 
 photo TIDE_zps1ac62372.jpg
The Interactive Development Environment: bringing the creative process to the art of coding.
TIDE is an attempt to integrate the celebrated traditions of the artistic process and the often sterile environment of programming. The dialogue of creative processes exists in the process of coding as frustration: debugging, fixing, and fidgeting over details until the programmer and program are unified. TIDE attempts to turn this frustration into the exhilaration of dialogue between artist and art.
The environment uses a Kinect to find and track gestures that correspond to values. Processing code is written with these values and saved in a .txt file. The result code creates a simple shape on screen. I want to expand this project to be able to recognize more gestures and patterns, allowing for much more complicated systems to be implemented. Ironically, I found the process of implementing and testing this project generating the very frustration and sterility I was trying to eradicate with the intuitive, free flowing motions I could get with the Kinect.
 

 photo Sketches9a_zps66e2853c.jpg

 photo FinalTxtFileScreen_zpsc25421bb.jpg
 photo FinalProcessingFileScreen_zps52cd8bed.jpg

"""
Rachel Moeller
EMS2 Asignment 9 
The Interactive Development Environment
"""
from pykinect import nui
from pykinect.nui import JointId, SkeletonTrackingState

import pygame
from pygame.color import THECOLORS
from pygame.locals import *
import os
import random

KINECTEVENT = pygame.USEREVENT



def writeFile(filename, contents, mode="wt"):
    #Got this from Kosbie's 15-112 Class
    fout = None
    try:
        fout = open(filename, mode)
        fout.write(contents)
    finally:
        if (fout != None): fout.close()
    return True

def post_frame(frame):
    """Get skeleton events from the Kinect device and post them into the PyGame event queue"""
    try:
        pygame.event.post(pygame.event.Event(KINECTEVENT, skeletons = frame.SkeletonData))
    except:
        # event queue full
        pass

def commitWidth(data):
    """This function adds the width to the file contents."""
    width=data.sizeWidth
    data.contents+=str(width)+","

def commitLength(data):
    """This function adds the width to the file contents."""
    length=data.sizeLength
    data.contents+=str(length)+");\n}\nvoid draw()\n{"

def commitShape(data):
    """This function adds the type of shape to the file contents."""
    data.contents+="\n"
    if(data.shape=="ellipse"):
        data.contents+="ellipse("
        data.shape="ellipse"
    elif(data.shape=="rect"):
        data.contents+="rect("
        data.shape="rect"

def commitShapeLoc(data):
    data.contents+=str((data.sizeWidth/2)-data.radius)+","+str((data.sizeLength/2)-data.radius)+","

def commitRadius(data):
    """This function adds the radius in to the shape definition."""
    radius=data.radius
    data.contents+=str(radius)+","+str(radius)+");\n}"
    data.isComplete=True

def computeShapeLoc(data,r):
    """This function figures out where to begin drawing the shape away from the center
       of the screen."""
    c=data.shapeColor
    x=400-r
    y=300-r
    data.shapeX=x
    data.shapeY=y

def drawShape(data):
    """This function draws the shape into the interface."""
    c=data.shapeColor
    if(not data.hasRadius):
        r=getRadius(data)
        computeShapeLoc(data,r)
    else:r=data.radius
    if(data.shape=="ellipse"):
        pygame.draw.ellipse(data.screen,c,[data.shapeX,data.shapeY,r,r])
    if(data.shape=="rect"):
        pygame.draw.rect(data.screen,c,[data.shapeX,data.shapeY,r,r])

def commitColor(data):
    """Sets the color in the file contents."""
    if(data.color=="red"):
        data.contents+="\nfill(255,0,0);\n"
    if(data.color=="green"):
        data.contents+="\nfill(0,255,0);\n"
    else:
        data.contents+="\nfill(0,0,255);\n"

def commitBG(data):
    """Writes the background command to the file contents."""
    data.contents+="\nbackground(255);\n"

def initBools(data):
    """This funtion inits the boolean variables controlling when
       code pieces are written."""
    data.hasWidth=False
    data.hasLength=False
    data.hasSetup=False
    data.hasBackground=False
    data.hasColor=False
    data.hasShape=False
    data.hasLocation=False
    data.hasRadius=False
    data.isComplete=False

def initJoints(data,skeleton):
    """Defines the Kinect Joints."""
    data.head=skeleton.SkeletonPositions[JointId.Head]
    data.rightHand=skeleton.SkeletonPositions[JointId.HandRight]
    data.leftHand=skeleton.SkeletonPositions[JointId.HandLeft]
    data.hip=skeleton.SkeletonPositions[JointId.HipCenter]

def init(data):
    data.contents="/*TIDE shape*/\nvoid setup()\n{\nsize("
    data.x=10
    data.y=10
    data.space=20
    data.font=pygame.font.Font(None,20)
    data.typeWords=["void"]
    blue=0,0,255
    green=0,255,0
    data.typeColors=[blue,green]
    data.plainTextColor=0,0,0
    data.lineNums=2
    data.sizeWidth=500
    data.sizeLength=500
    data.shapeColor=0,0,0
    data.shape=None
    data.backgroundColor="white"
    data.tracked=False
    data.frameCount=0
    data.headThresh=0.8
    data.displayText="User not detected"
    data.radius=100
    initBools(data)

def redrawAll(data):
    """This function handles display screens"""
    c=255,255,255
    pygame.draw.rect(data.screen,c,[0,0,800,600])
    c=0,0,0
    msg=data.displayText
    font=pygame.font.Font(None,28)
    text=font.render(msg,True,c)
    data.screen.blit(text,[20,20])
    if(data.hasShape):
        drawShape(data)
    pygame.display.flip()

def checkForComplete(data):
    """This function checks to see if every checkpoint in the code has been reached."""
    return data.hasWidth and data.hasLength and data.hasSetup and data.hasBackground and data.hasColor and data.hasShape and data.Location and data.hasRadius


def getBGColor(data):
    """This function sets a background color"""
    data.backgroundColor="white"


def getRadius(data):
    """This function gathers radius information from the kinect."""
    if(not data.hasRadius):
        data.radius=200*abs(data.hip.y-data.head.y)
        data.hasRadius=True
        return 200*abs(data.hip.y-data.head.y)

def getColor(data):
    picker=random.randint(0,4)
    print picker
    if(picker==1):
        data.hasColor=True
        data.shapeColor=255,0,0
        data.color="red"
    if(picker==2):
        data.hasColor=True
        data.shapeColor=0,255,0
        data.color="green"
    else:
        data.hasColor=True
        data.shapeColor=0,0,255
        data.color="blue"

if __name__ == '__main__':
    WINSIZE = 800, 600
    pygame.init()
    class Struct: pass
    data = Struct()
    init(data)
    data.screen = pygame.display.set_mode(WINSIZE,0,16)    
    pygame.display.set_caption('Interactive Environment.')
    data.screen.fill(THECOLORS["white"])

    with nui.Runtime() as kinect:
        kinect.skeleton_engine.enabled = True
        kinect.skeleton_frame_ready += post_frame
        # Main game loop    
        while True:
            e = pygame.event.wait()
            frame = kinect.skeleton_engine.get_next_frame()
            for skeleton in frame.SkeletonData:
                if skeleton.eTrackingState == nui.SkeletonTrackingState.TRACKED:
                    data.tracked=True
                    initJoints(data,skeleton)
                    data.displayText="Need a Shape"
                    if(not data.hasShape):
                        getColor(data)
                        if(data.head.y

Swetha- Final Project

“Manjal Neerattu Vizha” By Swetha Kannan

The project, “Manjal Neerattu Vizha”, uses an arduino and an ultrasonic distance sensor in order to activate an artificial period. The period is activated inside a doll which wears the traditional indian woman’s garment, the sari. The project is as much a look into indian culture as it is a look into feminism.

In india, and more specifically in Tamilnadu, when a young girl first gets her period, there is a celebration that is held that can be considered a sort of ‘coming of age’ ceremony. It is also at this time that the girl is first allowed to wear a ‘sari’, until then she was probably wearing ‘churidars’ or other small dresses.  My own such ceremony left a large impression on me because of the grand amount of people that attended the celebration, the large amount of money that went into preparing the ceremony, and above all else the awkwardness of letting everyone know that I was on my period and, essentially, on display because of it. This project does not seeks to undermine the ceremony since I have many fond memories of participating in it. The project instead seeks to explore this ceremony and let the viewer become a participant in a re-contextualized version of the ceremony. I am deeply interested in menstruation as being part of a ‘display’ for people to see. in order to explore this concept, I have created a menstruation that is triggered by the arrival of people and which performs for the viewer until he/she moves on . By the end of the performance, the sari is drenched with blood on the tails of its skirt and the blood has spread over the ground.

Video:

 

Fritzing:

For the diagram, I used a 9v battery instead of a 12v like it should be. And Please ignore the fourth prong on the ultra magnetic sensor. Mine only had three and I don’t yet know hoe to edit parts on fritzing.

pumpWithSensor_bb

 

Code:

int TIP120pin = 3; 
int sensorPin = 7;
void setup()
{
pinMode(TIP120pin, OUTPUT); // Set pin for output to control TIP120 Base pin
pinMode(sensorPin, INPUT);

analogWrite(TIP120pin, 255); // By changing values from 0 to 255 you can control motor speed
Serial.begin(9600);
}

void loop()
{
  int sensorValue = analogRead(sensorPin);
  Serial.println(sensorValue);
  
  sensorValue = map(sensorValue,0, 100, 0, 255);
  Serial.println(sensorValue);
  
  analogWrite(TIP120pin, sensorValue);
  
  
}