Posts Tagged ‘Processing’
Reading Data from MyRobots / ThingSpeak
Last post I showed some code and a guide on how to connect your robot to MyRobots/ThingSpeak! Now let’s look at how we can read the data from MyRobots. This part will be pretty cool, because you can read other robots data, and have your robot react to it!
I haven’t written up a MAKE Project guide for this yet, but wanted to show it anyway. Here you can get the SimpleThingSpeak_Parse code on Github!
We will be using the JSON Processing library to get and parse the data.
There are three main parts to this code:
1. Reading the entire feed
2. Specific feed field
3. Last entry in the robot feed
Here’s what the basic field structure looks like. The channel data is the info about your robot, and the feeds is an array, with each element being the specific datapoint.
- created_at (str)
- description (str)
- field1…8 (str)
- id (int)
- last_entry_id (int)
- name (str)
- updated_at (str)
feeds
- (your entry int here)
– created_at (str)
– entry_id (int)
– field1…8 (str)
So for the accessing entire feed, you can use these functions:
Here’s a very basic example of how to use these functions:
-
// example, get random stuffs, print it out
-
int feedsNum = getFeedLength();
-
-
println("\nHey! Did you know that " + robotName + ", aka coolest robot in the world was created on MyRobots on " + creationDate + "?");
-
println("It’s last field1 value that it sent (entry #" + lastEntry + " by the way) was: " + lastField1 + ". Cool!\n");
For the field feed, you can use this function:
For the last entry, you can use this function:
And that is it! You can use the data from the functions and connect it up to your robot.
Try it out, get the code from Github!
Learning Pet at the Open Hardware Summit
Learning Pet had a fantastic time at the Open Hardware Summit!
Before the summit started, we were sitting at the sculpture robo-busking for votes! At that point, Ian came over and wanted to do an interview! It was an excellent interview, and he uploaded it really quickly at the summit so we could get more votes for the scholarship! Thanks Ian!
I actually did go to some of the talks! Specifically, the ones in the morning before the break. The Arduino Team’s keynote was really really great!
After that, I sort of hung around the cafeteria area showing off Learning Pet! A lot of people said they would vote, which was really great! After the crowd died down, I went into the cafeteria area to watch the stream and maybe work on some ADK stuff.

That was when the creator of ThingSpeak himself caught me and said Hello! ThingSpeak is a really cool Internet of Things website. It’s relatively small and new, which is why I like it compared to the others.
He told me about the location data parameter in the API. I never knew this existed! Then I was wondering how to get the location from Mac OS, if there was actually a framework for that. It turned out that there was! Wow! And it was since 10.6 too! I never knew this! Making it work was really great, it was only checking to see if it worked was what we really got caught on (because the XML file goes from oldest to newest).

It was then when I saw David Cuartielles from the Arduino team when I waved, who joined the table. We were talking about Learning Pet, and it turned out that he was the one who created the Processing ADK Tool! Wow! What a cooincidence!
I told him about all of the bugs, and asked how I can fix them. He showed me the code for the ADK tool, and walked me through how to build it in Eclipse! Building a tool for Processing is a little different because you have to tell ant that there are some things that are already pre-compiled, so it doesn’t have to check them.
I played around with the code for a while and sort of got used to the way things work. There are some places where it will be tricky to be able to do what I want to specifically do.
We also tried to figure out why there are four parameters on the Arduino side, and only three on the Android App side. It turns out that the Arduino is the one telling the Android what App it needs, rather than the other way around. This means that of course the Arduino side needs the description and website parameters. Which I guess makes more sense in retrospect

I’ll definitely be helping out more with this Processing ADK Tool stuff. The thing that motivates me the most is that when I first got the ADK and Android, I figured that this should be about 10x easier and 50x quicker than making an iOS App. It wasn’t, and many other people feel the same way, but now it is my goal to make it so.
We did listen to some of the talks while we were down hacking and learning on some code. They were really good! I didn’t manage to get to the breakout session, but they were all sort of scattered and I wasn’t listening to the directions anyway… playing with the code was more fun.

Oh yeah! And I also bought a hackerspace passport from Mitch Altman! It is so cool to see them in real life, they look like a real passport!
The Demo session was fun, lots of people loved Learning Pet and also said that they voted for it! However, when they announced the winners, Learning Pet didn’t place in the top three. I really appreciate everyone voting, though. To be honest and somewhat egotistical, I think Learning Pet’s documentation was the best and most complete. No one even came close!
Here is a video by johngineer about Learning Pet! Thanks johngineer!
Watch video on Vimeo
The one thing that I would improve though, is to make the organizers a little more friendly towards everyone, and not just caring primarily about the sponsors. Yes, it is important to make the sponsors feel good since without them then there wouldn’t be this event, but it is also important to make the people at the summit itself feel good also. For example, at the demo session one of the organizers was talking with all of these sponsors in front of my demo area and goofing around and taking photos, but never bothered to say hello or ask about my project. It was sort of uncool and unmakerly (if that’s a word). The way I think of it is… you might as well be friendly to everyone, because we are all in this together!
All in all, the Open Hardware Summit was great for connecting with some of the people I have met online! It also turned out to be a great learning experience for building tools for Processing, and seeing how the Processing ADK tool actually compiles with API v10 rather than v7 (it is literally just setting the number different hahahaha)!

Also, Learning Pet appeared in the Adafruit blog randomly! It was awesome!
RoboBrrd Cosmic Soap
Creating art with robots usually ends up with a result that is unexpected from the beginning! I created this fluid dynamics + physics sketch in Processing that was fun, and sort of looked like the soap from space. I connected it with RoboBrrd, and it was super unreal the result that it created.

Watch the video on YouTube
All sorts of people have different ideas about what it is, it seems to change from person to person, which is really interesting
With RoboBrrd, since the light is being shone into its “eyes” (because the LDRs are located close to the eyes), lots of people have said it like a RoboBrrd hallucination. I’m not so sure about this, but playing with it is lots of fun, and shooting some long-exposure photos creates interesting results

My inspiration for creating this was lack of inspiration. I couldn’t focus on more important things to do, but at the same time I didn’t feel like doing nothing.
You can look at the code on GitHub. It’s commented and annotated, so it should be a good starting point if you want to create something like this.
Oh yeah, and to maybe answer a question you might be wondering- I’m not “on” anything. The only thing I’m “on” is my computer 18 hours a day, coding and creating.
If you use this sketch or make something similar, leave a comment with your project! It would be cool to see how this translates into other robot art
Simple Processing Twitter
I created a really simple Processing and Twitter sketch to help a friend a few nights ago ^_^ It is based off of this previous code from the blog post “Processing + Arduino + Twitter + OAuth”. Here’s what changed:
- It now uses the Access Token that you can get from the Twitter App’s panel
- No more inserting PIN info into a file
- No Arduino clutter in the sketch
- Simple methods for posting, retrieving, and searching tweets.
You can probably do a lot more things with this too, thanks to Twitter4j.
Or view it on Github
If you use this code in one of your projects, let me know! It is cool to see what people make.

This work is licensed under a Creative Commons Attribution 3.0 Unported License. GO OPEN SOURCE!
FNR – Robot Mesh Network: Intro & Node 1
I’m trying to create a network for my robots to communicate through and interact with the outside world to have some new behaviours emerge. Each robot will be able to read and transmit messages. The robots will be given basic instructions for things to listen to and eventually some behavioural AI to link previous commands together. The idea is to have robots talking to each other, informing one another of different sensor readings, thereby creating a shared knowledge of the environment that the robots are in.
In a military robots example, a UAV could be observing the environment below and an autonomous rover analyzing some LIDAR sensor data of its ahead of it. With some mapping algorithms applied and communication between the two robots, a rescue mission could be planned and executed very quickly. It’s all about networking the robots and making them talk together in “words” they understand.
Last Friday I worked on getting Twitter integrated with Processing. This weekend I added on to that existing work by trimming down the tweet string, and having it transmitted to an Arduino which broadcasted the message through the XBee to the other devices.
There are currently three devices on the network right now:
Node 0: Transmitter from the computer
Node 1: RoboGlyphs
and a Watchdog, which doesn’t transfer data, only reads what is being sent out.
Here is a video of a broad and basic explanation of everything so far:
Robot Mesh Network – Introduction & Node 1 from RobotGrrl on Vimeo.
The transmitter node serves as the main point of communication of the internet to the devices, and vice versa. It’s using an Arduino with an XBee attached to it. Right now its main purpose is to send out the tweet that it receives from the Processing sketch.

The transmitter node looks like this:

Which is attached to the computer running a Processing sketch:

The Processing sketch is connected to Twitter, and searches for tweets that are to @RobotGrrlsBots. The connection is through OAuth, since IP rate limiting for feeds resets less often, as far as I have observed. It sends the most recent tweet to the transmitter node.
The RoboGlyph node receives the tweet, and does what the command says. The command has to be formatted in the way of this:
If it is received OK, which is usually is, then it will display it! The process that the RoboGlyphs follow is that it fades in the colours, then it waits for a command. Once it receives a command, the colours will fade out.
This is what the RoboGlyphs node looks like:


And this is it working!

Pretty cool. The RoboGlyphs could use a tune up though by using one of the TLC594 16 bit PWM out chips. Right now the green LEDs don’t use PWM, so it makes the animation look choppy.
The Watchdog watches all of the data that is being transmitted and shows it on the screen. This is what it looks like:


It’s useful to try to debug some things. While making everything I was having trouble with the New Soft Serial library and Arduino 0019.
Next time I will be working on getting data transported back from the RoboGlyphs and sending a tweet. From there, it will be about adapting that code to all of the other robots too. This is just the start!

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. GO OPEN SOURCE!
Processing + Arduino + Twitter + OAuth
WARNING: There’s a newer version of this code here: “Simple Processing Twitter”!
People who devise these spectacular security protocols and stuff really make it complicated to communicate to cool social networking sites. Yesterday I got carried away and ended up making a Processing sketch that could successfully connect to Twitter through its OAuth method. This is primarily for a project where Tweets are read, sent into Processing, which are then sent to the Arduino, which then broadcasts the message through its Xbee, and then the other robots pick up on the message. If the message is addressed to them, then they will parse it and do what it says. The first step though was to try and get the OAuth to work. Below is the link to the Processing code and some steps that I took that may help others.
1. Set up a Twitter application
Here is a screenshot of the settings that I used:

2. Open up the code and fill in the OAuth consumer information (line 131)
-
twitter.setOAuthConsumer("***", "***"); // consumer key, consumer secret
3. Uncomment the initTwitter() method call (and comment out the other twitter method calls) in void setup()
4. Open the sketch’s folder (keyboard shortcut: command-K). Open up url.text and go to that website. Copy the pin.
5. Enter the pin in pin.txt and press enter. For some reason there has to be a new line at the end, otherwise it won’t work
6. The code should now give you the access token and secret that you need. This should also be in tokens.txt now.
7. Take the tokens and put them into the code (line 238)
8. Comment out initTwitter() method call, uncomment connectTwitter(). You can also uncomment getSearchTweets too!
Hopefully those steps worked for you. It’s not totally automatic, with the whole copying and pasting of the tokens, but it seems to be the quickest and easiest way to get this done with Processing. Luckily you don’t have to do those steps all the time! Since it’s open source, maybe someone can improve on it!
If you find any bugs or have improvements, be sure to leave a comment or notify me! Happy tweeting!

This is the screenie when it worked! Woohoo!

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. GO OPEN SOURCE!
Grabbing MANOI’s Accelerometer and Gyro Data

Last FNR I embedded MANOI’s Accelerometer and Gyro into its back. Usually what people do first when they add these motion sensors is make their robot self balancing.
For now, I’m going to see if I can do something a little cooler.
The idea stems from a Fast-Fourier Transform result for sound- where you can see the various volumes and such. (Check out my Processing Fancy FFT). What I’m aiming to create is a FFT for motion. Basically, if you move MANOI around, the algorithm will be able to detect a pattern and do stuff afterwards. Essentially what this is leading up to is an interesting dancing robot. =)
I’m starting off with a Processing program that will visualize and log the data (see above screenshot). I envision a split-view display with two cubes. One will be showing the live sensor input, the other will be showing the results of the pattern algorithm to the live data.
No idea yet how the algorithm will turn out. I’m probably going to start at a very basic level, and perhaps add complexities on later. It will be interesting to see how this will turn out!
Soon to be blogged…
- The FNR that I mentioned, but didn’t blog about
- RampageRobot!!!
- RoboGlyphs





