Archive for March, 2006

Thesis Design Project: Robot Pictures

Tuesday, March 28th, 2006

A colleague and I took a few final photos of our robot today.
You can read more about our final product here.

Update: Proof of Concept 3 pictures can be seen here.
Update: Proof of Concept 2 pictures can be seen here.
Update: Read about the final product here.
Update: Videos of the robot can be seen here.

Robot Pic1Robot Pic2Robot Pic3Robot Pic4Robot Pic5

How-to: Use __sleep() to serialize your class

Tuesday, March 28th, 2006

A lot of people run into this problem, and so did I when I first tried this. To make a long story short, I had a class which I wanted to serialize and store in a session variable. I would serialize the class, but when I would echo the output I’d get this:

Code:
N;

This would happen regardless of what was in the class. The class used a ‘magic’ function __sleep() to close the db connection. I had read that serialize() automatically calls __sleep(), but I didn’t know is that __sleep() needed to return an array of properties of the class.

Here is some example code to try out. Use it as is, and then comment out the contents in __sleep().

Code:
<?php

class sleep_example {
private $var1 = "george";
public function __construct() {}

public function __sleep() {
return array_keys(get_object_vars($this));
}
}

$obj1 = new sleep_example();
$srlz = serialize($obj1);
echo $srlz;

?>

Hopefully you’ll read this before you waste time googl’ing and looking through PHP Bug reports..

How-To: Set up SVN with Apache2 in Linux (Ubuntu)

Friday, March 24th, 2006

Initially I didn’t plan on writing anything up about this, since its pretty basic to setup. But I ran into a slight problem, which I imagine others might run into also. I guess most would have Apache running already, so all that is needed is SVN:

Code:
> apt-get install subversion libapache2-svn

Say you have a domain already set up, call it abc.com. You want to be able to checkout a repository from abc.com/svn.

Open the following file (/etc/apache2/mods-available/dav_svn.conf) in an editor and follow the instructions. In the most basic form (with no authentication) you’ll have something like this when your done:

Code:
< Location /abc.com/svn >
DAV svn
SVNPath /svn
< /Location>

Inside the < Location /abc.com/svn > that path must point to a directory in your web server which does NOT exist. abc.com will exist, but make sure svn doesn’t. The SVNPath will point to the actual repository which MUST be outside your web server space.

This way, if you go to a browser and type: http://www.abc.com/svn nothing will show up, but when you checkout your repository, you will be re-directed to the actual svn directory (in this case /svn).

Now create the SVN repository, in directory /svn

Code:
> svnadmin create /svn

Be sure to change the permissions on this directory, so the web server can write to the folder:

Code:
> chown -R www-data /svn

Restart Apache2:

Code:
> /etc/init.d/apache2 -k restart

Now from a remote computer, you should be able to type:

Code:
svn co http://xxx.xxx.xxx.xx/abc.com/svn < name >

(were xxx.xxx.xxx.xxx is your server ip and name is what you want to call the local folder)

Thesis Design Project: Done

Wednesday, March 22nd, 2006

This past Sunday was the final competition to the IBM judges for my team’s thesis design project. The project consisted of making an autonomous robot (out of Lego) that would go into a network, and rescue hallow eggs.

There were 2 parts to the project. The first is the graphical user interface, which uses a map of the network to determine execution paths, trasmit/receive with the robot, etc. The second part is designing the actual robot. Both components had a lot of effort put into them, and collectively we are very proud of the final product.

Our company name was MBI (MicroBot Initiative) and the product name was nexSAR (Next Generation Search and Rescue). Highlights of the finished product?

  • Capable of rescuing 3 eggs in under 25 seconds (using the network provided).
  • Custom designed ’stay straight’ algorithm, which polls light sensors to remain centered in the hallway.
  • Upon exiting the network, the robot uploads its log, and the GUI creates a VRML (3D) log re-enactment. This is complete with victim voices, which get louder as the robot nears.
  • Ubuntu Live CD. Just put the CD in the CD drive, reboot, and all the software you need is ready to go. We have a live CD for both PowerPC and for Intel.
  • USB Rescue Key. Capable of booting to DSL (Damn Small Linux) straight from a USB drive. This also has all the software pre-loaded and ready to go.
  • Complete GUI with map editor and path generation.

Here are the slides that we used in our final presentation.
The slides use 3 videos of the Robot in action – Video1Video2Video3 – (sorry 2 of the videos are large ~50mb).

Update: Final photos of the Robot (taken March 28/06) can be seen here.
Update: The Robot Java code can be downloaded here (April 4/06).
Update: The videos above have been uploaded to Google Video, you can see them here (July 2/06).

Here is a screen shot of the GUI:

Here is a screen shot of the VRML log re-enactment:

Why to use PEAR

Saturday, March 11th, 2006

A comment was posted on a tutorial I wrote How to: Install Apache, PHP, PEAR, MySQL & phpMyAdmin for Windows XP. The comment said:

What does PEAR do that can’t be done (otherwise) … Like, I can do all the usual stuff with the database now, so am I missing anything by not installing PEAR? What does PEAR do?

Good questions, hard to answer.  I came up with a few…

1)

I’m from Canada, and believe me, it gets cold up here. When it’s -20 (Celsius), I could go outside wearing a spring jacket, but the smart thing is to put a big winter jacket on. Eventually, it’ll become summer, and there is no need for a winter jacket. But as seasons are cyclical, it will become cold again. PEAR is a lot like that, you can do a lot of PEAR’s features with normal PHP, but as you use PEAR more, you’ll see it’s like wearing a winter jacket (even when you don’t have to). Plus there are so many cool packages available and in the works.

2)

Straight from the PEAR website it says:

PEAR is short for “PHP Extension and Application Repository” and is pronounced just like the fruit. The purpose of PEAR is to provide:

  • A structured library of open-sourced code for PHP users
  • A system for code distribution and package maintenance
  • A standard style for code written in PHP, specified here
  • The PHP Extension Community Library (PECL), see more below
  • A web site, mailing lists and download mirrors to support the PHP/PEAR community

PEAR is a community-driven project with the PEAR Group as the governing body. The project has been founded by Stig S. Bakken in 1999 and quite a lot of people have joined the project since then.

3)

If you’ve ever seen Tommy Boy, you’ll know a classic line by Chris Farley:

I can get a good look at a T-bone steak by sticking my head up a bull’s ass, but I’d rather take a butchers word for it.

Your Ad Here