Grasshopper

algorithmic modeling for Rhino

Hi everyone,

I am working on a project that involves a pixy cam (from Charmed Labs). It is a simple camera made specifically for low-capacity devices such as Arduino and is meant to track (colored) objects.

Now, this is a prototype, as I am aware of the fact that linking such a camera directly to grasshopper is sub-optimal (why not use a better camera?). But I happened to have a Pixy Cam already and the fact that it is sort of pre-coded to send only the data I need, I thought I could set it up quite quickly to link to grasshopper (with or without Arduino).

Sadly I do not have much experience with programming myself (outside of Grasshopper) and was hoping that I could make it work with the existing codes and interfaces.

Could someone tell me what would be a logical way to link the data that I need to grasshopper? It involves the basic parameters that already show up in PixyMon (the standard app that comes with the pixycam), such as object size (amount of pixels), color (signature) and coordinates (x,y).

I hope my question is clear enough and that someone can help me with this. Thanks in advance!

Stef

Views: 987

Replies to This Discussion

Ok,

I have been trying a few ways to get the data I need inside grasshopper.

For now, I think the easiest way to get this to work is through the (pre-made) arduino sketch from the people that made the Pixy Camera.

I am currently using their example file ('hello world') to send the required data (# of blocks, coordinates, size etc.) to the serial. When I open the Serial Monitor in Arduino I can see that the data is being sent correctly.

Afaik, it should be possible to simply open up firefly in grasshopper, and then use the 'generic serial read' component (with the correct port and baud rates) with a timer to update and retrieve the same data that I get in Arduino's Serial Monitor inside grasshopper. I'm quite sure I should not need to add/use the firefly firmata sketch since I only have to read the serial port data.

However, when I try to do this, everything seems fine (port is open, 'hooray message', etc.) but the output from the serial read component gives an <empty> output.

If you know whether this setup should work, and if so, what I am doing wrong, please let me know.

Stef

Hello again everyone :P

I managed to get the data streaming into firefly by adding a simple Serial.prtln() inside the loop for printing the object data from the camera. This seems to trigger Firefly to register what is happening on the serial port. A small nuisance this causes is that it prints an extra blank line between items, but this shouldn't matter as long as it is still processed as a single string (i can filter it in grasshopper).

Overview of current Arduino Sketch and Serial Monitor output (with the extra blank lines):

The main problem I'm left with is that the data is not sent correctly as a 'single string' per update (every 50 frames the data is printed to the serial). I guess this has something to do with how grasshopper (and/or the timer component) will not automatically synchronize with the data stream from Arduino. This causes problems such as strings that are doubly sent or broken up where they shouldn't be.

The way it should be:

All the data of the objects in view are stored in one string each. This is what occurs most of the time. But after a while, especially when new objects are introduced in the camera's view, the data logging in grasshopper becomes offset/desynchronized, which causes the strings to repeat and/or break up into pieces (multiple items):

I assume this has to do with the (clumsy) way that I set up the Arduino sketch. If anyone knows how I can fix it so that the data from one loop will always be registered as a single string (item) in Grasshopper, please let me know!

Stef

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service