It's been a while since my last post - as it happens the past few weekends were full of other activities - but I decided that today I'd write a bit about the workflow I devised for updating my little robo's software.
The Software
The robot will have a whole bunch of software on it eventually, and as we are living in modern times, one language will not fit it all. As of now, we have to account for three different programming languages:
| Language | Used for | Deployment |
|---|---|---|
| Python | Most of the robot's logic, sensor measurements, server-side UI code | Compiled to byte-code upon execution. Just copy to the robot and execute. |
| Arduino Sketch | Used for controlling the Arduino motor shield. | Must be compiled and uploaded to the Arduino. Two options:
|
| JavaScript | Client-side UI logic. | The client-side UI will make extensive use of Google Closure Library. JavaScript can generally be executed as is, so copying to the robot is all that is needed. However, as the JavaScript code grows more complex, it might be interesting to apply Closure Compiler to make it more efficient |
Suddenly, the task of deploying a whole new set of software to the robot seems to have gotten a whole lot more complex. Wouldn't it be nice to deploy all the above with a single command and then maybe even reinitialize the robot so it runs our new software?
Editing software on the robot
OK, this is going to be a longer post (this is why it is using headings, in a desperate attempt to give it some structure). As long as we've been just fooling around on the software side it was fine to do everything on the Raspberry Pi itself. In fact, Raspbian comes with a decent set of editors, compilers and interpreters so you can get started right away. But here comes the first downside to this: My little Robo is headless. Both in a very literal way and because it does not have a display attached to the Raspberry Pi. In fact, the way it is constructed right now the Pi's HDMI connector is not easily accessible. And even if it were, I wouldn't want to plug a keyboard, a mouse and a display into the robot everytime I want to change it's software. Moreover, I might have to debug it while in action later on, and I have a feeling that a robot dragging mouse, keyboard and display after it while roaming around wouldn't make this task any easier.
WIFI, we need WIFI
So to make my life quite a bit easier, I ordered a Wireless USB 11N Nano Adapter from http://www.rasppishop.de/, a mere € 6.99 that are well-invested indeed. To get the WIFI up an running, you have to configure it to connect to your router of course. If you are interested, howtogeek.com has instructions for Raspbian.
Talking to my little Robo, remotely
Now that WIFI is setup, I should be able to talk to my robo as long as it is in WIFI range. No need to attach keyboard or mouse, or even a network cable. To log into the robot, we need one more thing: SSH. If your desktop PC or laptop runs Linux or Mac OS X, you are all set already. All you need to know is the robot's IP address or, more elegantly, its hostname (which can be set in /etc/hostname on your Raspberry Pi). When you connect to your robot, you have to specify a username that exists on the robot. Raspbian comes with a default user called "pi". This is what I'm using on my robot, I merely gave it a new password. To connect to the robot as user "pi", open a terminal window on your PC and type
ssh -l pi mylittlerobo
During the first login, ssh will ask you to confirm the identity of the host you are connecting to. In a controlled environment like ours (the robot being on the same network), it should be safe to just answer yes to this question and not be bothered with it again.
You can now work on the commandline, e.g. start your favorite editor and start writing software. If you are working on Linux (or OS X with an X window system installed), you can specify the -X when logging into the robot. This will enable X forwarding, so you can even start graphical applications such as the Arduino Sketch editor:
If you are missing out on a piece of software, type apt-get install <package-name> to install it. This is clearly a start.
To recap: With the right tools installed, we can now log into our robot and use it to program our robot right there. All software, regardless of language, lives on the robot. We can even use Git or Mercurial to do version control (locally or with a remote repository e.g. on https://github.com/).
There are disadvantages to this setup, however:
ssh -l pi mylittlerobo
During the first login, ssh will ask you to confirm the identity of the host you are connecting to. In a controlled environment like ours (the robot being on the same network), it should be safe to just answer yes to this question and not be bothered with it again.
You can now work on the commandline, e.g. start your favorite editor and start writing software. If you are working on Linux (or OS X with an X window system installed), you can specify the -X when logging into the robot. This will enable X forwarding, so you can even start graphical applications such as the Arduino Sketch editor:
If you are missing out on a piece of software, type apt-get install <package-name> to install it. This is clearly a start.
To recap: With the right tools installed, we can now log into our robot and use it to program our robot right there. All software, regardless of language, lives on the robot. We can even use Git or Mercurial to do version control (locally or with a remote repository e.g. on https://github.com/).
There are disadvantages to this setup, however:
- Especially when using a graphical IDE such as the Arduino Sketchpad, you will usually notice quite a bit of latency.
- Version control in its simplest form will be done locally. Sure you can upload your stuff to Github, but you will want to put some thought into this, because you might not want to share all your sources with the world (or at least not at the very beginning).
- We will write lots of code and as our software grows more complex, less and less of it will interact with hardware directly. During development, we will have tons of tests we want to execute instead. While our Raspberry Pi is fast enough for controlling a robot, wouldn't it be nice if we could execute our tests at "maximum speed", that is, using a powerful desktop CPU instead of the Pi's ARM CPU?
We will tackle these disadvantages in part two of this post. Stay tuned for more :-)

















