Categories
Uncategorized

Miltalkee (The Talking Robot)

Miltalkee

Wow, somehow it’s been months since I first mentioned my entry in the Great Robot Showdown, and it’s been another (or a few more) since I promised a write-up on said robot… so here it is.

Proposal

For the Flying Car Milwaukee 2013 event there were a number of competitions held, one of which was the “Great Robot Showdown” which tasks people to “create an energetic, entertaining robot that actually does what it’s designed to do.” And noted that the robots would be “unleashed at the Flying Car Gala to delight and entertain the crowd.”

How could I resist? I had already shown things like the Friday Night Drawbot and the Arc-O-Matic at previous events in Milwaukee, so I figured I needed something new, something specifically for this event.

Miltalkee

I wrote up a proposal describing what I planned to build, included a quick sketch, and some links to previous projects, and mailed it in. About a week later Dana and I were putting a bid on a house, and I got a call. I checked my voicemail later and found out I was selected, which was awesome, but it also meant I had about 30 days to build the robot, move everything I own, and also take part in a gallery night I had committed to. Fun!

Miltalkee

It was time to get to work! My plan was to cut all the pieces of the robot from 3mm Baltic Birch plywood. That stuff is great to work with if you’ve got a laser cutter handy, and we happen to have one at Milwaukee Makerspace! There was a lot of cutting to do. Basically the robot consists of 8 “boxes” of various sizes to comprise the body, head, legs, feet, and arms. After cutting and assembling everything (with glue and strategically placed magnets) the pieces were painted with grey primer, and then with metallic silver paint. All sprayed in my home-built spray booth.

Miltalkee

I ended up spending the majority of my time doing the physical build, all the time thinking the programming would be the easy part. I was (mostly) right. Since I was using a Raspberry Pi I was in my comfort zone. A bit of sudo apt-get for the right packages, some Perl, a text file, and we had a talking robot. I ended up abandoning the idea of a screen or LCD display of any kind due to time constraints, but it’s an idea for the future.

Miltalkee

There is a hole in the center of Miltalkee’s chest where a speaker goes. It’s a powered speaker, using 3 AAA batteries, which works well in a semi-quiet room, but in a large room filled with people and music, it’s not exactly loud. (I should thank Dori Zori for turning down the music a bit!) If I ever want Miltalkee to be extra loud, I can always run the output to an external amp I guess.

One of the neat things about Miltalkee is the construction. The faceplate and chestplate are interchangeable, and if I get ambitious in the future, I can swap them out for new ones. This should make upgrading to a screen fairly easily.

There’s a bunch of technical stuff I’ve not included in this post, mainly because I’ve already rambled too much. In future posts I’ll talk about the Raspberry Pi, the code, and a few other construction secrets.

Miltalkee

Enjoy!

Categories
Uncategorized

TLBot 4: CameraPi

CameraPi

If you wondered why I needed a Raspberry Pi case that could also hold a Raspberry Pi Camera… well, seriously, don’t you people know me by now!? :)

This ‘CameraPi’ is a prototype for Time Lapse Bot 4, and if you’re not familiar with my time lapse hardware experiments, check out the Time Lapse Bot project page for a good introduction.

My Time Lapse Bots have always relied on old computers, and while you can typically get old computers pretty cheap, they are also, well… old. They run old software, they often have hardware failures, non-working batteries, are heavy, and a lot of other things that are (sometimes) fine, but sometimes annoying.

Enter the Raspberry Pi, a small, inexpensive, low-power, modern Linux computer that can use an add-on camera module to create an all-in-one solution to time lapse captures. This is the kind of stuff I love playing with!

So here’s the story of making the CameraPi. I’ll avoid getting into code at this post and just talk about the process and some applications.

At raspberrypi.org I grabbed the NOOBS install, mainly because I wanted to test it out, and it worked well! I went with Rasbian. I think it had all the camera software baked in, but if not, it’s easy to add.

AppleTalk

Once up and running, I added Avahi to give the Raspberry Pi a nice network name (camerapi.local) and I also installed Netatalk to allow my Mac OS X machines to easily connect to it. Neither of these are required for the camera stuff, but I tend to drop these on most Linux machines I use.

As for the image capture, while the camera utilities have some time lapse capabilities, they did not work for me, which is fine, I created my own. (I should note that the Raspberry Pi is for educational use, so I try to follow that idea and, well, learn a lot while using it.)

I wrote a simple bash script to capture a new image every 60 seconds. You can set whatever interval you like, but I like 60 seconds. For one day that gives you 1440 images, if you’re keeping track at home. Depending on your image size and compression settings that could be over 1GB per day of still images. I’m currently using 1280×720 for my image size, as that works well when compiling video.

Photo

As long as we’re capturing images every minute, why not have a way to display them remotely via a web browser? Sure! I also installed Apache for that. There are lighter HTTP servers, but I like Apache. I wrote a simple CGI script to grab the latest image file and display it on a page… and there’s also a link to all the images for the day. Oh, and the page auto-refreshes so it keeps showing the latest image. (The images are named like so: 20130905140427 using the YYYYMMDDHHMMSS format.)

Files

OK, so we now have this running archive of photos. At some point (like, the second day) you’re going to have way more images in that folder than you want. Another shell script is the answer! Script #2 runs after midnight, grabs the date of the previous day, and moves all images matching that date to their own folder. (Oh, where do we store all these images? On a tiny USB thumb drive. It’s an 8GB drive. We figured filling that was better than filling the SD Card that contains the system.)

Files

Now we’ve got a folder named 20130905 with 1440 images in it. We should probably do something with it… Make a video! Once the files are moved we run a command with mencoder to compile all the JPG files (sorted by name, which is also sorted by date) into an AVI file. I don’t really care for AVI files though, so when that is done (and, it takes about 6 hours due to the high-quality encoding settings I use) we then use avconv (which used to be ffmpeg, sort of, oh, Linux!) to convert the AVI to an MP4 file. That does not take hours. This is all messy and could be done better.

Video

So after all that, we now have an MP4 file we can view in our browser, though it’s a silly MP4 that needs to completely load before it starts. Silly! There must be a better way.

Yes. There must be a better way. I’m sure there is. Here’s the thing. I really just started hacking. I didn’t know where I was going, so it’s all been guessing and trying things along the way. That’s the beauty of it. I’m not building this for a client. I’m not building a commercial product. I’m just playing and learning. I love it.

Oh, I forgot, I also set my capture script to launch at startup as a service. That means it also stops cleanly when you halt the system. Also, you can halt the system via another CGI just by loading a web page. Secure? Probably not. Ideally I’d like to be able to have the Pi create a WiFi network I can attach to from my phone and control. That would be nice. I’m sure it’s doable, I just need to dig in more. Dig. In. More.

Well that was fun! Thanks for reading this. If anyone really wants more info on the code, I could clean it up a bit (or not) and post it. As always, improvements are very welcome.

Update: Here’s an example video.

Categories
Uncategorized

Raspberry Pi case (with Camera!)

Raspberry Pi with Camera

I really like the Stacking Pi Case and I’ve laser cut a bunch of them at Milwaukee Makerspace, including the one I used for my Radio Milwaukee Radio, but when I got a Raspberry Pi Camera, there was no easy way to include it…

Raspberry Pi with Camera

I ended up making a derivative of the Stacking Pi Case and calling it the Raspberry Pi Case (with Camera) because, that’s what it is. I just made the Stacking Case taller and added in some holes to mount the camera.

Raspberry Pi with Camera

So if you’ve got a Raspberry Pi and Camera Module, this case might do well for you, since it’ll hold them both. Grab it from Thingiverse!

I’ll get into what I’m doing with this thing in a future post… obviously it will be related to images, time lapses, web stuff, etc.

Oh, and if you’re wondering why the top of the case is purple, it’s due to some crazy experiment I did with dying wood last time I dyed a bunch of t-shirts. And yes, you can totally dye wood.

Categories
Uncategorized

MPD Radio Controller

If you read about my Radio Milwaukee Radio and thought having just one station to listen to was rather silly, we can do something about that.

One station means no choices (and no controls) but with multiple stations we need a way to select which one you want to hear, and there are clients that can make that possible. Since the Raspberry Pi is on our home network via WiFi, that means any other device on the network can control it.

mpd

I first tried MPD-Web-Remote, which looks great on iOS devices, and fine in any WebKit-based browsers, but I’m a Firefox fan, and it looks like total crap in Firefox, so I kept looking…

mpd

I prefer MPD-Webinterface, which looks good in Firefox, and not as great on iOS devices. Of course, since these are just web applications running on the Raspberry Pi you can install as many of them as you like. (You’ll obviously need to have a web server running on your Pi. I dropped Apache on mine along with PHP using the standard apt-get method.)

And since these are PHP web apps, you’ve got the source, and can edit the CSS as you see fit, so customizing the look should be pretty simple.

Want more options? There’s a giant list of MPD clients on the Music Player Daemon Community Wiki.

And hey, if you’re wondering how I got 3 stations listed instead of just one, compare the original code to this code:

#!/bin/bash
 
mpc clear
mpc add http://radiomilwaukee.streamguys.net:80/
mpc add http://129.89.70.253:80/wuwm_1.mp3
mpc add http://75.102.5.99:80/wpr-ideas-mp3-64
mpc play
 

This creates a playlist with 3 items, and will start playing the first item in the list, so put whatever you want as the default first. This list will play the 88.9 Radio Milwaukee stream until you select another one.

mpd

You can even add new streams (temporarily) using the MPD-Webinterface. At the bottom of the interface is a text field, just paste in a stream URL and hit return to add it to the list. (I pasted in http://wmse.msoe.edu:9000 for WMSE 91.7) I said ‘temporarily’ because only the three that are hard-coded in our bash script above will survive a reboot/restart.

Oh, keep in mind you need the actual stream URL, not the playlist URL, which is one that usually ends with a .pls file extension. Normally you’ll need to view the source of a .pls file to see the stream(s) listed within it.

That’s it for now kids… have fun with your Raspberry Pi Radio!

Categories
Uncategorized

Radio Milwaukee Radio

Radio Milwaukee Radio

I started working on this project months and months ago, so I should probably share what I’ve got so far… as always, it’s a work in progress.

If you live in Milwaukee and listen to the radio, you’re probably familiar with 88.9 Radio Milwaukee. I’m certainly familiar with it, as it’s a great station, and not just for the music, but for their pieces that spotlight the great things happening in Milwaukee.

Since I don’t actually live in Milwaukee right now, it’s a little difficult to pick up the broadcast at home, but no worries, since they stream it over the Internet, we can use a Raspberry Pi (a cheap single-board computer) to play the stream.

Radio Milwaukee Radio

All we need to do is add some power and some speakers (and a little bit of code) and the Radio Milwaukee Radio is ready to go!

I used this post to figure out how to run a script at system startup. Since the Raspberry Pi runs Linux, I’m comfortable mucking around on the command line via SSH, others might not be, but since the worst thing you can do is destroy the entire system and have to re-load it onto an SD card, the risks are small.

Oh, and here’s the script.

#!/bin/bash

mpc clear
mpc add http://radiomilwaukee.streamguys.net:80/
mpc play

MPD is the Music Player Daemon, which deals with playing the stream, and MPC is the Music Player Client which controls the MPD server. The script tells mpc to clear whatever it’s doing (just in case) and then add the 88.9 stream, and start playing it.

(It’s a bit more complex that just that, as there are some startup services that need to be added, but I still need to clean up that code.)

I’ve seen a lot of complex Raspberry Pi radio streaming projects, and while I’ve also played around with different clients to control things remotely via a browser running on a phone or tablet, I wanted to keep this really simple, and create a single-purpose device that did one thing… play the awesome stuff I hear on Radio Milwaukee.

(I also put together a short video showing it in action.)

Note: I also wrote up a post about laser etching the logo on the Milwaukee Makerspace site.