ME/CS 132a, Winter 2012, Lab 1
Exercise #0: Linux Primer (skip this if you had prior experience)
If you have not used Linux (or any UNIX-like OS) before, go to http://imss.caltech.edu/cms.php?op=wiki&wiki_op=view&id=324 to learn the basics of command line operations. It is important to go through this since we will heavily rely on the command line for the labs.
Exercise #1: Running Player/Stage Remotely
In order to run Player/Stage remotely, you'll need to access the course server using the login information provided by the TA. You'll need to have X-forwarding enabled. This is pretty straight-forward if you're running UNIX-like systems. See below for special notes on how to run using Windows.
- Server address: tokyo.cds.caltech.edu
- Connection type: SSH
- We will use the dollar sign "$" as the command line prompt. You shouldn't include this as part of the commands below.
Logging into the Player/Stage remote server (Linux/Mac OS X)
- Open a terminal window (that is X-friendly).
- Connect to robotics via SSH:
$ ssh -X email@example.com
and enter the password (where username needs to be replaced with the one received from the TA).
- The "-X" enables X11 forwarding, which is how you'll get the Stage windows and such to appear on your local machine.
- If this is your first login, be sure to change your password by running:
Logging into the Player/Stage remote server (Windows)
On Windows, there are at least two effective options. The first is to virtualize a Unix/Unix-like operating system. The second is to use cygwin.
- Go to this page and click on the link on the line that says "VirtualBox 4.1.8 for Windows hosts" to download Virtualbox.
- Run the downloaded executable to install Virtualbox
- Go to this page to download Ubuntu, the operating system the robots are running on. If you don't like Ubuntu, any other Linux operating system should be fine. The version of Ubuntu you get (64-bit vs. 32-bit and 11.10 vs. 10.04) does not matter. The robots are running Ubuntu 10.04. You should select to download an .iso image.
- Start Virtualbox, and create a virtual machine with these settings:
- At least 512 MB of RAM
- At least 10 GB of hard disk space. I recommend making a dynamically expanding image (you'll see when you get there) and just setting a very high number for the amount of available space.
- Start Ubuntu. Go to the bottom right-hand corner and hover over the icons. One will say "Install Guest Additions". Double -click (or right click) on the icon to install Guest Additions. You will probably be prompted to allow it to run on startup - click Yes. Once you have installed Guest Additions, you can then shutdown your virtual machine and then you will be able to let the virtual operating system take over your whole computer screen.
- The default text-editing program is gedit.
Once you have your virtual machine set up, your virtual machine will run within a Windows window, and while you're in that window, you can pretend that you're working in a unix environment.
- Go to this page and download setup.exe.
- Run setup.exe
- Select "Install from Internet"
- When you get to select which packages to install, make sure that the packages "openssh" and the set of packages under "X11" are set to be installed.
- Once you are done installing, go to your start menu and start the program "XWin Server". A terminal that you can use should pop up. You can use that terminal like any other Linux terminal.
- Change directory to the appropriate path that contains the player configuration file:
$ cd part1/me132_tutorial_player/configs
- Start up Player, using the test config file:
$ player simple.cfg -p <your_RPIN>
- your_RPIN is your robot port ID number which you were already assigned.
- You should see the Stage simulator and a simulated robot wandering around.
Exercise #2: Running Player/Stage with Your Own Client Code (Controller)
In Exercise #1, we have seen the simulated robot wander around, but now let's make it move in a controlled fashion by inserting our own controller (referred to as the client code).
- Follow the instructions as in Exercise #1, but this time use another config file:
$ player lab0014.cfg -p <your_RPIN>
- Open another terminal window. Connect to the server, and change to the directory containing the tutorial client code, e.g.:
$ cd part1/me132_tutorial_player
- Compile the C++ code to generate the binaries (i.e. executables). You only need to do this once, unless you change the source C++ code (.cc files):
- Run the following to start the client program. Take me132_tutorial_0 as an example:
$ ./me132_tutorial_0 -p <your_RPIN>
- You should see the robot moving in a circle in the Stage simulator.
- The reason that "./" (meaning "the current directory") is put before the executable is that Linux does not automatically look for the file in the current directory (unlike in Windows), so we need to explicitly tell its location.
Exercise #3: Controlling the Robot Using Player and Client Code
IMPORTANT: Read this before you come to the lab session.
In Exercise #2, we have made the robot move in a controlled fashion by inserting our client code. Now let us learn how to control a real robot using the same client code. You will only be able to do the following during the lab session, but it can save you a lot of precious lab time if you read this beforehand:
- When you are in the lab, connect to the lab wireless network Pandemonium.
- SSH to the laptop and copy your code/binaries to the laptop. This is similar to connecting to the course server, but with a different username and remote address:
- Username: me132
- You will be using a laptop called "hilo" or "honolulu". Their IP addresses will be written on the board in the lab. You can access both laptops with the command ssh me132@IP Address.
- Go to the configs directory. Use pioneer2.cfg or pioneer2_laser.cfg (when there is a laser scanner onboard) as the config file to run Player:
$ cd ~/configs
$ player pioneer2.cfg
$ player pioneer2_laser.cfg
Both config files will be given during the lab session. Note we do not give a RPIN during the lab session. Instead, we use the default one for convenience, since there won't be any other active users.
- Open another terminal window. Connect to the laptop, and start your own client program as in Exercise #2. You should see the robot move in your desired fashion. For me132_tutorial_0 to me132_tutorial_2, run them as before, but without the RPIN (to be consistent with Step 2). For me132_tutorial_3, you need to run it with one additional parameter, the camera ID, which will be given during the lab session:
$ ./me132_tutorial_3 <camera_id>
You will also need to copy the corresponding camera calibration file to the directory where me132_tutorial_3 is located:
$ cp ~/bb2_cal/<camera_id>.cal .