It's
been a while since I posted an update and that's because I've had my
head buried in rather boring details. But it occurred to me
that these are exactly the kind of details that normally remain
hidden in the lab so why not reveal the ugly truth for a change?
After all, the life of a roboticist is not all glamor and talk
shows!
First, Pi is getting ready to do
some more ambitious exploring, both around the house and in a larger
outdoor environment with paved walkways. Pi is now 9.4 lbs
without batteries, so to go these larger distances, I needed to
build a larger base with additional batteries and a stronger set of
drive gears. The result is barely visible but here is a
picture of the new setup:
It can be surprising how
long such a simple upgrade can take to assemble. I'd much
rather buy an off-the-shelf setup but they tend to be very
expensive. At the high end, a robot base made by Segway costs
over $10,000! More commonly, hobby-level robot bases cost
between $500 and $3,000 depending on the size of the motors, chassis
and wheels. Another issue is battery power. I am currently using a
combination of Lithium ion and NiMH battery packs as they are many
times lighter than lead acid batteries. However, they are also
more expensive.
The final reason to enlarge
Pi's base platform was to accommodate his onboard mini-computer as
shown in the picture below:
As long as Pi is within a
couple hundred feet of my main computer, his "brain" can
reside on my PC and his sensors and motors can operate over a
wireless link. However, once he begins to venture further
away, he'll need to keep his head on his shoulders and carry his own
computer on board.
On the software side of
things, I am rewriting all of Pi's programming code in a language
called Python. This has been a great learning experience but
also very time consuming. Why on earth would I do this? Until
now, I have used Microsoft's C# programming language which is
similar to C++ (very popular in academia) but much more forgiving on
a "high level" programmer like myself. (In my case,
"high level programmer" means lazy and impatient.)
C# is very easy on my brain and makes for fast development of new
code. However, it runs on Windows computers only and is not
widely used in other robotics projects. Python is a relative new
language, but it is open source, runs on all three platforms
(Windows, Linux and MacOS X) and is really, really easy to program
with. In fact, it only took me about a week to get the hang of
it, probably because I already program extensively in PHP for my day
job and PHP shares some conceptual similarities with Python.
One of Python's strengths is
that it supports both "declarative" and "functional"
programming styles. Declarative programming is what most of us
think of as programming. For example, suppose we have a list
of fruits and we want to print out only those with "berry"
in their name. In a declarative language like C# we might do
something like this:
This example also illustrates
that Python is a "dynamically typed" language like PHP,
Perl, Lisp, Javascript and Ruby. This means that our code
samples can be relatively compact since we don't have to write out
all the type declarations for each variable and function as we did
in the C# example.
Perhaps most importantly for Pi
Robot, Python now sports many open source libraries that will come
in very handy as we go along. For example, there is NetworkX
for doing network graphs (think family trees and the traveling
salesman problem), PyBrain for coding artificial neural networks and
OpenCV for computer vision. What's more, Python will allow us
to use a relatively new open source robot programming framework
called ROS ("Robot Operating System") from Willow Garage
which is a very well funded start-up company located just down the
street from me and with strong roots at Stanford University.
In closing, I will leave you
with a little video that illustrates the use of Python to control
Pi's arms. This was a test case for me to get up to speed on
the new language as it involves multi-threading, list
comprehensions, and a low-level Python interface to the Dynamixel
servos. The code simply picks a random position for each of
Pi's 11 servos (don't forget his torso rotation!), then tells them
all to move to their new positions in a synchronous fashion so that
they all reach their target angle at the same time. Then a new
posture is chosen at random and the process repeats.