Fun with a Roomba

So I purchased a Roomba at the Woot off the other day. After I bought the condo, a good friend of mine (who also lives here) mentioned the device, but didn’t know the name. Being the consummate geek that I am, I knew he was talking about the Roomba, and furthermore knew that they had several flavors of it now. And the fact of the matter is that he was right, it seems perfectly suited for this place. So when I saw one at the Woot off for only $120 (+$5 shipping), it seemed like a good idea. In fact, I think it turned out to be one of the best bargains ever.

The one I got is a “Discovery 4296” which is nothing more than a word with a number, really. The thing is basically an automatic sweeper. With hardwood or low carpets/rugs (not shag) it’s clearly perfect. Basically it sweeps the floor with rotating brushes and sweeps the crap into a bin, whereupon you dump it. It’s particularly good with hair and other small debris, like the weird pebbles that keep falling out of my ceiling. It also does a decent job of dust in general, although it tends to throw it about a bit. But it seems to get it after a few passes.

One thing I do not like is the bin. It’s too small, and it’s positioned wrong. The upshot of this is that you have to use it every other day, and you have to be *extremely* careful when emptying it. The first time I emptied it, I dumped a large amount of crap onto the floor. Takes some practice, so expect it.

Naturally, being a geek, I’m interested in the algorithms involved. It has a few. They probably have technical names, but here’s the lowdown:
1. Roaming – It roams off in some random direction for a long distance. This is the primary way that it cleans the center of rooms. However, when you consider it, the center areas of rooms don’t tend to be the dirty ones.. It’s the edges that build up the mess. So it has…
2. Edge finding – I think the manual calls this wall roaming. It tends to do this a lot, however I’ve seen it walking the edge of my rug as well. Which is actually a good thing, as those edges tend to pick up debris too. Finally, it has:
3. Spot cleaning – This is an interesting mode. You can force it by placing it somewhere and hitting the “spot” button, but in normal “clean” mode, it will wander around and occasionally switch into this mode. A blue light labeled “dirt detector” comes on, and it runs around in circles for a while, eventually heading off in some random direction.

Few other things:
– Home base – If you get the model with the home base charger, then after it’s satisfied with the area or low enough on battery, it will go home and dock for charging. This can be forced as well with the remote (if you have one). Watching it dock is a lot of fun for your average geek, because the way it does it is clearly via two infrared beams on either side of the dock. It hits them, and turns away from them, back and forth, hunting, until it finds the home point. Very clever.
– Virtual Walls – These are similar, just infrared transmitters (each takes 2 D-cell batteries!) that shoot out a beam which cause the thing to act like it hit a wall and turn. It will follow the beam just like it follows walls. The beams are a bit wide, so put them back a bit inside doorways and such.

The primary way it knows about things is hitting them. The whole front piece, about 140-150 degrees or so, is a movable bump mechanism. When it hits something, this pushes in and the thing stops and turns around some seemingly random amount, or just a bit in edge finding mode. It also appears to be able to sense distance from any wall, because in edge finding, it will follow a wall very precisely without touching it at all, which is weird, because I can’t find any obvious sensors there.

As far as cleaning goes, the one I got is basically a sweeper/vacuum. Works great on hardwood, decent on low cut rug/carpet, probably would not work on shag or similar. The gist of it is that it has a side sweeper to pull in things, a front sweeper to push things up, a rotor brush to pull things in, and a ramp to force things into the bin. There’s also a spinning mechanism inside which might produce some very minor vacuum effect, to get things “over the hump” of the bin and keep dust inside. The bin is on the back, and it sucks. Pick the thing upright before removing the bin. You’ll see the method after 1 spill, trust me.

The docking station does not work particularly well on hardwood floors. It slides, and the Roomba drags it around while trying to disengage. Put it on rug or carpet. I ended up putting it on some carpet samples underneath my bar area. Speaking of which, the dock *MUST* be in an area where it has a pretty good view of the room. Otherwise the Roomba will not find it. So forget a closet or something, it must be in the main area, somewhere.

The cat is completely freaked out by the thing, but the Roomba does not appear to mind his presence. 😀

It’s loud. Not as loud as an actual vacuum cleaner, but the Roomba takes longer. However, given that mine has a scheduling feature, I can set it to work when I’m not here. Haven’t tried that yet, might try it later this week. The scheduler is cool, built into the remote. You program the times, and then send the schedule to the Roomba and to the virtual wall units. It runs for that time and the wall units turn on at the same moment. Very conservative on battery power that way.

One thing that bugs me is that the remote doesn’t offer any easy way to really remote control the thing. You can send it commands, but they’re really more like suggestions as far as I can tell. Which is frankly too much work. It covered my living room and kitchen by itself twice before running out of power, and since I didn’t follow the charging directions, it didn’t find home base when it did so. Follow the damn directions, charge it for 16 hours before the first use. Trust me on this one.

Hacking: There are myriad abilities to hack the thing. It has a serial port, and can accept commands to move around and such, as well as provide feedback of all the sensors on it. Worth a look if you’re into that sort of thing. I’m considering building a bluetooth serial link to it and hacking it a bit. With some minor effort (okay, maybe not so minor), I could control the thing and make it work much better for my specific space. Given that the unit’s more or less “random” method works pretty well, it does seem to take a while to accomplish anything. I mean, it works, but seems inefficient. I could improve that. I browsed through the documentation on irobot.com while it was working, and it’s pretty comprehensive. Worth a look if you’re the hackish type.

All in all, I’d say it’s worth the $125. Maybe $170. But not the default $220 price. Find the bargains on it, stick with those. Amazon has the remanufactured ones on the cheap (this is the same one I got). And if you’re all hardwood with no rugs/carpets, look for the one that actually mops instead of just sweeps and vacuums.

Fully Integrating Google Apps for your Domain

Having two email accounts can be a pain. I’ve been using my GMail account for a long time, but I like the niceness of my ottodestruct.com domain better. It’s cleaner, overall. A bit more professional as well.

I also use Firefox with the Google Toolbar. One of the nice things about it is the little GMail icon that checks your GMail every 10 minutes or so, and shows if you have new messages. It also lets you search your email right from the toolbar. Very handy.

However, I also use Google Apps for your Domain for my email. This basically makes all my ottodestruct.com email go through Google and their GMail interface. The Google Toolbar doesn’t work too well with that.

So I got bored and fixed all that. How to do it can be found after the jump…

Continue reading “Fully Integrating Google Apps for your Domain”

Geekery and Beer

So, I’m sitting here drinking some of my new homebrew. It’s a rather nice cherry wheat that came out a tad more spicy than I was actually expecting. I think I rather overdid it on the cinnamon. I figure that after another couple of weeks of bottle conditioning, it might turn out to be a rather good beer.

One thing I have noticed is that it’s a lot stronger than I was expecting. After just one, I’m catching a buzz. Very nice.

Anyway, while I’m basking in the sun and enjoying a frosty beverage, I figured I’d putz around with the website a bit. Those of you of a geekish bent might try looking at the site on your mobile phone or whatever handheld device you happen to prefer. Through the magical power of the interwebs, the blog should now look different on the handheld devices, more suited to smaller screens. It’ll eliminate the sidebars and rejigger the display a bit. Since I’ve been using the mobile web a lot more, I find this quite cool.

Also if, for some demented reason, you feel it necessary to produce hardcopy of my random meanderings, you’ll find that the excessive imagery disappears on the printout, leaving you with just the basic text and little else. This should all be automatic if you have a modern browser, no strange trickery required. Although I’m dubious as to why anybody would want to print out my worthless words, the option is now there, if you happen to come up with a reason.

Those of you interested in the technical details can read on after the jump…
Continue reading “Geekery and Beer”

Blog by phone: Not so simple

I’ve been trying to get the ability to post pictures to my blog from my phone working for the last week or so. Previously, I used Postie for this sort of thing, but since I’ve switched to GoDaddy hosting, I’ve discovered that that method just don’t work. The fault is, basically, GoDaddy’s shared hosting plan and their insane method of supporting PHP. Ugh. I will not be renewing my hosting with them. I may switch hosts and attempt to get a refund on the remainder, actually.

So I tried a few other tricks. XML-RPC works and I can post from my phone with it, however the clients I’ve put on the phone don’t support pictures too well, or the phone doesn’t support the clients too well, or some damn thing like that. I dunno yet. I tried to get a cable for my phone to let me hack it open a bit wider and allow that sort of thing to work, but finding one turns out to be difficult on short notice. Stores just don’t have them.

So I tried blogmailr. It’s a service that combines the two.. You send email to it, it converts it into an XML-RPC post to your blog. That works too, but photos don’t seem to survive the transition. I suspect this is a problem with blogmailr.

All in all, it looks like I’ll be unable to post photos of my trip this next week on a “live” basis. So just look forward to a gallery of images when I return instead. I’ll have to sort out the live posting capabilities that I used to have sometime later.

Fun with PHP and WordPress

Guy over here asked how to display hockey scores on his blog. Here?s my solution?

Edit: Fixed a minor problem with the regular expression. Some of the soccer team names caused problems on that feed.

A quick googling tells me that exactscores.com seems to have feeds for scores for lots of stuff, however they also put horrible amounts of advertising into the RSS feed. Nevertheless, that can be worked around, if you want. )

The actual score information in the feeds comes in the titles, and it looks like this:

(No)001/1 (BST+2h,Start at)03:00 (Home Team)EDM OILERS (Final)3-6 (Away Team)ANA MIGHTY DUCKS (Status)Finished (First Period)0-3 (Second Period)3-2 (Third Period)0-1 (Full Time)3-6 (Over Time)- (Penalties)- (Scorers)LUPUL(19)

Now, that is pretty ugly. But, at least it?s in a semi normalized format: (Key)Value? The Scorers at the end isn?t pretty, but we can deal with that later. Also, thankfully, the actual scores in all the ones I checked always start with (No), so we can use that to determine which bits of the feed are actual scores and which are not.

So here?s a simple script to retrieve a feed and then display only those bits that start with (No):

< ?php
require_once(ABSPATH . WPINC . '/rss-functions.php');
$rss = fetch_rss('http://www.exactscores.com/HockeyLivescoreRss.xml');
echo '
    '; foreach ($rss->items as $item ) { if (preg_match('/^(No).*/i',$item['title'])) echo '
  • '.$item['title'].'
  • '; } echo ''; ?>

Obviously, the output of this is ugly, but it proves that we?re only getting scores out of the feed.

So, now we need to parse that string and get more useful data out of it. Here?s where preg_split and some rather disturbing regular expression syntax is your friend?

$uglyscores = preg_split('/^(([^)]*))[^s]|s(([^)]*))[^s]/',
	$item['title'], -1, PREG_SPLIT_DELIM_CAPTURE);

I called it $uglyscores for a reason. This returns an array with the bits of the scores nicely parsed out, but because of the regular expression I used, there?s a blank string between each pair of data, so let?s reformat this mess into something nicer:

$i=1; // skip the first element
$scores = array();
while ($i<count ) {
	$scores[$uglyscores[$i]]=$uglyscores[$i+1];
	$i+=3; // skip the blank separator
}

This gives us a nice array of elements that we can then reference by the key names. So we can use stuff like $scores[?Final?] and such.

So now that we don?t have to display everything, let?s put it all together. Here?s a combination of all of the above that outputs the two teams and the final score only:

< ?php
require_once(ABSPATH . WPINC . '/rss-functions.php');
$rss = fetch_rss('http://www.exactscores.com/HockeyLivescoreRss.xml');
echo '
    '; foreach ($rss->items as $item ) { if (preg_match('/^(No).*/i',$item['title'])) { echo '
  • '; $uglyscores = preg_split('/^(([^)]*))[^s]|s(([^)]*))[^s]/', $item['title'],-1,PREG_SPLIT_DELIM_CAPTURE); $i=1; // skip the first element $scores = array(); while ($i<count ) { $scores[$uglyscores[$i]]=$uglyscores[$i+1]; $i+=3; // skip the blank separator } echo "Home Team: ".$scores["Home Team"].""; echo "Away Team: ".$scores["Away Team"].""; echo "Final Score: ".$scores["Final"]; echo '
  • '; } } echo ''; ?>

And there you have it. If you want to display different information, just modify the stuff in those echo lines towards the end.

The key is finding the RSS feed with the data you?re interested in. Once you have that, it?s usually fairly straightforward to parse it and redisplay it nicely. )

Some inventions are just pure genius…

Check this one out: The Lazydrinker

It’s a modified portable cooler that is designed to hold, cool, and mix up to 16 bottles of beverages. Basically it pressurizes the bottles and uses that to pump the liqour out, which then goes into your drink. It therefore produces whatever drink you want on command. The mixer device is reprogrammable via a PC to put in your favorite mixed drinks, and the thing uses a CO2 tank to pump out the sweet, sweet candy.

Some pictures:

Lazydrinker interior Lazydrinker mixing output

At $750, it’s a bit too expensive for my tastes. However, they offer a $550 DIY kit, which seems like it would be an excellent addition to a home bar. )

Fun with Widgets

Note: The ExecPHP widget does not work in the upcoming WordPress 2.5. Therefore, if you upgrade to 2.5, you will need to install the updated version of this widget. It can be found here, now and forever more: http://wordpress.org/extend/plugins/php-code-widget/

A new plugin for WordPress came out that’s kinda cool. It’s called Widgets, and the general idea of it is to make the sidebars on your blog a bit more configurable, a bit more easily.

So, I decided to spend an hour or so converting my sidebars to Widgets so I could manage them a bit simpler. Editing PHP code is easy but time consuming, while dragging stuff and dropping it to rearrange the blog, well, that’s quick and easy.

Few things I learned:

  1. The Widgets Plugin does not like Windows. Since I run this site on a Windows box (edit: I did then, I don’t anymore, and anyway, they have fixed this problem since then), it needed some tweaking to make it work. For those who want to know, the problem is in the sidebar_admin_setup() function in widgets.php. More info on this problem is in the comments of this post.
  2. Text boxes are extremely useful when converting from your existing customized webpage to a widgets based one, as you can simply cut and paste chunks of HTML into them and voila, you’ve got a sidebar widget. However, there’s not a lot of text widgets available. If you need more text widgets, you will need to edit these functions: widget_text_setup(), widget_text_page(), and widget_text_register(). As it turned out, I didn’t need but 4 text widgets because:
  3. Despite how useful text boxes were for a quick migration, they were not enough.

So, I ended up writing two plugins of my own.

The first one is a Google AdSense plugin. You can download it here: gadsense.zip. It’s exactly the same as the Text widgets, but with (very) minor tweaks specifically for inserting Google Ads in the sidebars. Also, it shows a name of “Google AdSense” in the widgets panel, which is nice. Like the Text widget, you can have more than 1 of them, but unlike the Text widget, you can only have 4 of them, since Google’s TOS only allows 3 ads and 1 link block on a page.

The next one is also like the Text plugin, however it will also let you put PHP code into the text and have it actually work. Here’s the download: execphp.zip. Like the Text plugin, you can have up to 9 of them (more if you want to tweak the code). Note that any PHP code you put into the widget MUST be surrounded by <?php and ?> tags, just like writing PHP normally. Also note that this is isn’t exactly safe, as it’s just doing an eval() on whatever you put in there, so you have complete and full access, as does anybody else who can get to your admin screen. Still, it’s very useful.

Both of those are plugins. Just drop them in the widgets folder under the plugins folder, and activate them on the plugins screen. Then the widgets will be available for you to use on the widgets screen.

Hope these help somebody. They sure helped me. )

css.php