oF Syjunta is like a knitting circle, but instead of knitting we’re coding. We meet up, hack a bit on our stuff, chat, have a coffee, exchange ideas, tricks and code.
We want it to be an open place for anybody who use openFrameworks and wants to meet other people doing the same in Stockholm. You can come when you like and leave when you’re tired, there are no talks or lectures planned, but it’s totally ok to demo you latest work or hack.
We hope to have an OF Syjunta once or twice monthly starting on Thursday October 30th. We’ll be in Münchenbryggeriet, at Doberman (map) and we’ll be there from 18.00 to 22.00. It doesn’t matter if you’re up for some coding, or just have time to say hi, swing by!
Living systems are inhabited by organisms with complex forms of communication and information processing. Suitcase Science is an attempt to package these systems and tap into them in order to form new alliances between nature and technology.
Suitcase Science represents a turn from the Modernism’s use of technology to control nature to a postmodern use of nature to enliven technology. By approaching living systems as technology Suitcase Science challenges traditional views of nature and suggests that new relationships to nature can be formed.
More concretely the Suitcase Science project investigates how living systems can be sustained in portable controlled ecological life support systems (CELSS) and how system parameters like environmental conditions, volatile organic compounds and electrophysiological activity can be intercepted and interpreted.
Suitcase Science is a project sprung out of the recently started Strange Eden Lab at the Interactive Institutes Art and Technology Program, it was most recently shown at New Media Meeting 3. Suitcase Science is a work in progress, more information will be available at SuitcaseScience.net as the project develops.
Suitcase Science is a collaboration between Erik Sjödin and Michel Bussien.
I’ll be at Ars Electronica in Linz, Austria September 4 - 8. In between the tremendous amount of art and technology sightseeing I plan to do with the Interactive Institute, I’ll be dropping by the OF Lab to finalize the Arduino class in cppGlue.
“The OF lab will focus on creating new works that come directly out of suggestions from the festival audience members, and over the course of the event, create a feedback loop between suggestions, experimentation, making projects, exhibiting the results and most importantly, exposing the process”.
Besides from being used by tinker.it, as3Glue has been used to teach physical computing and prototyping at Stanford and at least one commercial project (the Spelar roll exhibition by Doberman). So far I’ve had around one thousand downloads of the code, and since I’ve received no bug reports since the last update it looks like it is working pretty well. Glue is the first library I’ve released as open source so I’m really happy about this…
One of the beauties of OF are the addons that simplify installation and use of libraries such as openCV. I’m currently in the process of reworking cppGlue, a collection of classes that I’ve developed for my own OF projects, into a proper OF addon. cppGlue is built on top of POCO C++, a very capable general purpose library which I hope will be part of the OF core in the future. I’ve been experimenting with openFrameworks since v0.01. Already in the first pre-releases it was stable and structured enough to be used in “real” projects. It’s improving drastically with every release and with POCO C++ at it’s core it would take another giant step forward.
I have just committed an alpha version of as3Glue to Google Code. as3Glue is an open source physical interaction libary for ActionScript 3. It enables communication between ActionScript 3 applications and Arduino boards. It can be used to monitor sensors such as rotary encoders and motion detectors, control actuators such as LEDs and motors, and to interface other electronics such as RFID readers from within Flash / Flex and Air applications.
Code optimization might seem daunting but you can get pretty far with a few tweaks. I recently ported a Java physics engine to ActionScript 3, the first results were rather depressive. When rendering a particle system with one hundred particles connected by 180 springs the frame rate dropped from 45 frames per second to about 15. By tuning the code I managed to get it back up to 40 fps which is pretty ok. More than twice as fast as the original code… The thing here is that I didn’t have to change anything fundamentally, I only had to tune the existing code a bit.
Some of these “tweaks” might not be so obvious so I though I’d share them. I won’t explain why these practices improves performance in AS3 (and AS2) as there are plenty of in depth discussions on other blogs. Take my word on it, google it or test it your self. Don’t overdo the optimization though. Sometimes it’s better to have well structured and clean code than optimized code and sometimes optimization just isn’t worth the trouble (more on this here). In general you should consider optimizations like these when you have code that is executed on every new frame or code with a lot of loops and/or iterations…
Practices for faster code:
- Do not use Array.length in loops
- Avoid array lookups.
- Access variables directly without using getter and setter functions.
- Use int for counters and array lookups.
- Use multiplication instead of division.
- And (this should go without saying) always declare the types of all variables…
Here are two implementations of the same loop:
//Slow loop:
for(var i = 0; i < particles.length; i++){;
if(particles[i].isFree()){
particles[i].getX() = vectors[i].getX()/2;
particles[i].getY() = vectors[i].getY()/2;
particles[i].getZ() = vectors[i].getZ()/2;
}
}
//Fast loop:
var np:int = particles.length, i:int=0;
for(i = 0; i < np; i++){
p = particles[i];
v = vectors[i];
if(p._free){
p._x = v._x*0.5;
p._y = v._y*0.5;
p._z = v._z*0.5;
}
}
Note: Variables are usually prefixed with underscores to indicate that they are private. I generally leave the underscores on variables which should be private and accessed through getters/setters but are made public for optimization reasons…
Here’s some Arduino code that improves stability and fixes a couple of errors in the Arduino Playground code for the Parallax RFID reader. The second example uses SoftwareSerial which is handy if you don’t want to block the serial port (note that the wiring is slightly different).
// RFID reader for Arduino
// Wiring version by BARRAGAN <http://people.interaction-ivrea.it/h.barragan>
// Modified for Arudino by djmatic
// Revised by Erik Sjodin <http://www.eriksjodin.net>
//Connect:
/*
* Arduino RX to RFID SOUT
* Arduino GND to RFID GND
* Arduino Digital pin 2 to RFID /ENABLE
* Arduino 5v to RFID VCC
*/
int val = 0;
char code[10];
int bytesread = 0;
void setup() {
Serial.begin(2400); // RFID reader SOUT pin connected to Serial RX pin at 2400bps
pinMode(2,OUTPUT); // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(2, LOW); // initialise the reader with a reset cycle
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(2, LOW);
delay(100);
}
void loop() {
digitalWrite(2, LOW); // activate reader
if(Serial.available() > 0) { // if data available from reader
if((val = Serial.read()) == 10) { // check for header
bytesread = 0;
while(bytesread<10) { // read 10 digit code
if( Serial.available() > 0) {
val = Serial.read();
if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading
break; // stop reading
}
code[bytesread] = val; // add the digit
bytesread++; // ready to read next digit
}
}
digitalWrite(2, HIGH);
if(bytesread == 10) { // if 10 digit read is complete
//Serial.begin(115200); // transmit with 115200 bps
Serial.println(code); // print the TAG code
//Serial.begin(2400); // read with 2400 bps
}
Serial.flush();
delay(500); // wait for 500 millisecond
}
}
}
#include <SoftwareSerial.h>
// RFID reader for Arduino
// Wiring version by BARRAGAN <http://people.interaction-ivrea.it/h.barragan>
// Modified for Arudino by djmatic
// Modified to use SoftwareSerial by Erik Sjodin <http://www.eriksjodin.net>
//Connect:
/*
* Arduino pin 3 to RFID SOUT
* Arduino GND to RFID GND
* Arduino Digital pin 2 to RFID /ENABLE
* Arduino 5v to RFID VCC
*/
int val = 0;
char code[10];
int bytesread = 0;
int rx=3;
int tx=4;
// set up a new serial port
SoftwareSerial rfidSerial = SoftwareSerial(rx, tx);
void setup() {
pinMode(rx, INPUT);
pinMode(tx, OUTPUT);
rfidSerial.begin(2400); // RFID reader SOUT pin connected to Serial RX pin at 2400bps
Serial.begin(115200);
pinMode(2,OUTPUT); // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(2, LOW); // initialise the reader with a reset cycle
delay(100);
digitalWrite(2, HIGH);
delay(100);
digitalWrite(2, LOW);
delay(100);
}
void loop() {
digitalWrite(2, LOW); // activate reader
if((val = rfidSerial.read()) == 10) { // check for header
bytesread = 0;
while(bytesread<10) { // read 10 digit code
val = rfidSerial.read();
if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading
break; // stop reading
}
code[bytesread] = val; // add the digit
bytesread++; // ready to read next digit
}
digitalWrite(2, HIGH);
if(bytesread == 10) { // if 10 digit read is complete
Serial.println(code); // print the TAG code
}
delay(500); // wait for 500 millisecond
}
}
I’ve just released Arduino for Flash, an ActionScript 3.0 package that makes it easy to control Arduino boards with the Firmata 1.0 firmware from Flash.