ME/CS 132a, Winter 2011, Lab 1: Difference between revisions

From Murray Wiki
Jump to navigationJump to search
No edit summary
 
(16 intermediate revisions by the same user not shown)
Line 3: Line 3:


== Exercise #1: Running Player/Stage Remotely ==
== Exercise #1: Running Player/Stage Remotely ==
In order to run Player/Stage remotely, you'll need to access the robotics server using the login information provided in class.  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.
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'''
* '''Server address: tokyo.cds.caltech.edu'''
Line 11: Line 11:
=== Logging into the Player/Stage remote server (Linux/Mac OS X) ===
=== Logging into the Player/Stage remote server (Linux/Mac OS X) ===
# Open a terminal window (that is X-friendly).
# Open a terminal window (that is X-friendly).
# Connect to robotics via SSH:<BR> <TT>$ ssh -X username@tokyo.cds.caltech.edu</TT> <BR> and enter the password (where ''username'' needs to be replaced with the one given out in class).
# Connect to robotics via SSH:<BR> <TT>$ ssh -X username@tokyo.cds.caltech.edu</TT> <BR> and enter the password (where <tt>username</tt> 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.
#* 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 <TT>passwd</TT> in the command line.
# If this is your first login, be sure to change your password by running: <br><TT>$ passwd</TT>


=== Logging into the Player/Stage remote server (Windows) ===
=== Logging into the Player/Stage remote server (Windows) ===
Line 22: Line 22:
# Open up your SSH client program, and change the appropriate settings to enable X11 forwarding.
# Open up your SSH client program, and change the appropriate settings to enable X11 forwarding.
#*  For Putty, this is under "Connection-->SSH-->X11 forwarding"
#*  For Putty, this is under "Connection-->SSH-->X11 forwarding"
# If this is your first login, be sure to change your password by running <TT>passwd</TT> in the command line.
# If this is your first login, be sure to change your password by running: <br><TT>$ passwd</TT>


=== Running Player/Stage ===
=== Running Player/Stage ===
# Change directory to the appropriate path that contains the Robotics lab stage world file: <BR><TT>$ cd worlds </TT>
# Change directory to the appropriate path that contains the player configuration file: <br><tt>$ cd part1/me132_tutorial_player/configs</tt>
# Start up Player, using the Robotics lab world config file: <BR> <TT>$ player simple.cfg -p <your_RPIN></TT>
# Start up Player, using the test config file: <BR> <TT>$ player simple.cfg -p <your_RPIN></TT>
#* <TT>your_RPIN</TT> is your robot port ID number which you were already assigned.
#* <TT>your_RPIN</TT> is your robot port ID number which you were already assigned.
#* You should see the Stage simulator and a simulated robot wandering around.
#* You should see the Stage simulator and a simulated robot wandering around.


== Exercise #2: Running Player/Stage with Your Own Client Code (Controller) ==
== Exercise #2: Running Player/Stage with Your Own Client Code (Controller) ==
In Exercise #1, we see 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'').  
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 world config file. This simulates the floor plan of the lab.:<BR> <TT>$ player lab0014.cfg -p <your_RPIN></TT>
# Follow the instructions as in Exercise #1, but this time use another config file:<BR> <TT>$ player lab0014.cfg -p <your_RPIN></TT>
# Open another terminal window. Connect to the server, and change to the directory containing the tutorial code:<BR><TT>$ cd tutorials </TT>
# Open another terminal window. Connect to the server, and change to the directory containing the tutorial client code, e.g.:<BR><TT>$ cd part1/me132_tutorial_player </TT>
# 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 (<TT>.cc</TT> files): <BR><TT>$ make</TT> <BR>
# 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 (<TT>.cc</TT> files): <BR><TT>$ make</TT> <BR>
# Run the following to start the client program. You should see the robot moving in a circle in the Stage simulator:<BR><TT>$ ./me132_tutorial_0 -p <your_RPIN></TT>
# Run the following to start the client program. Take <TT>me132_tutorial_0</TT> as an example: <BR><TT>$ ./me132_tutorial_0 -p <your_RPIN></TT>
#*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.
#* 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 ''arena''.
# 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
#* IP address: 10.0.126.13 (laptop #1, aka ''honolulu''), 10.0.126.14 (laptop #2, aka ''hilo'')
# Go to the <TT>configs</TT> directory. Use <TT>pioneer2.cfg</TT> or <TT>pioneer2_laser.cfg</TT> (when there is a laser scanner onboard) as the config file to run Player:<br><tt>$ cd ~/configs </tt><BR> <TT>$ player pioneer2.cfg</TT><BR>or <BR> <TT>$ player pioneer2_laser.cfg</TT><BR>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 <tt>me132_tutorial_0</tt> to <tt>me132_tutorial_2</tt>, run them as before, but without the RPIN (to be consistent with Step 2). For <tt>me132_tutorial_3</tt>, you need to run it with one additional parameter, the '''camera ID''', which will be given during the lab session: <br><tt>$ ./me132_tutorial_3 <camera_id></tt><br> You will also need to copy the corresponding camera calibration file to the directory where <tt>me132_tutorial_3</tt> is located: <br><tt>$ cp ~/bb2_cal/<camera_id>.cal .</tt>

Latest revision as of 06:51, 16 March 2011

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)

  1. Open a terminal window (that is X-friendly).
  2. Connect to robotics via SSH:
    $ ssh -X username@tokyo.cds.caltech.edu
    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.
  3. If this is your first login, be sure to change your password by running:
    $ passwd

Logging into the Player/Stage remote server (Windows)

In order to use Windows, you'll need to install X-Win32, which is freely available through Caltech's software service, as well as an SSH client, such as Putty.

  1. Once X-Win32 is installed on your machine, start up the X-Win server.
    • This should put a little "X" icon in your system tray.
  2. Open up your SSH client program, and change the appropriate settings to enable X11 forwarding.
    • For Putty, this is under "Connection-->SSH-->X11 forwarding"
  3. If this is your first login, be sure to change your password by running:
    $ passwd

Running Player/Stage

  1. Change directory to the appropriate path that contains the player configuration file:
    $ cd part1/me132_tutorial_player/configs
  2. 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).

  1. Follow the instructions as in Exercise #1, but this time use another config file:
    $ player lab0014.cfg -p <your_RPIN>
  2. 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
  3. 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):
    $ make
  4. 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:

  1. When you are in the lab, connect to the lab wireless network arena.
  2. 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
    • IP address: 10.0.126.13 (laptop #1, aka honolulu), 10.0.126.14 (laptop #2, aka hilo)
  3. 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
    or
    $ 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.
  4. 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 .