Assignment 1
Doodle sheet to signup for slots: http://doodle.com/uzpeuucbpdvm6xs4
Submission: You need to demonstrate your assignment directly to me before class on Monday (October 8). Please send me an email when you would like your assignment to be graded. If I am free and available in the lab, you can do so whenever you finish. If not, let me know the night before.
Using the workstation
- Locate the workstation you will use for this assignment (it has vision-1 written on top). This is one of the closest machines to the main lab door.
- Power the machine on if it is not already on. Due to some bug, the Ubuntu splash screen is not displayed correctly sometimes. Do not fear, as Ubuntu will still load properly.
- Log into the workstation. If you have not changed the password already, use the following user/pass combination:
- Username: <firstname>
- Password: <lastname>
- If this is the first time you are logging into the machine, then change your password. See http://gerardmcgarry.com/blog/ubuntu-change-your-password-using-command-line
- Every time you log in, make sure you have internet access. Ensure that you are connected to “Wired Connection 1”. Open up https://horatio.cs.utexas.edu in firefox. Log in with your CS username and password. You can also get internet access on a wireless device by connecting to the “CS Wireless Network” and following this step.
Obtain the code
- You only need to carry out the steps in the section once. In the following steps, we'll install all the ROS code that you need to locally build on your machine. We'll use the rosws step to install all the code. To read more about rosws, check out http://www.ros.org/doc/api/rosinstall/html/
- First, create a ROS workspace to use:
cd mkdir ros cd ~/ros rosws init rosws merge /opt/ros/fuerte/.rosinstall
- Next, lets tell rosws to download our code-base, the segway driver, tutorials from last semester, and the blob detection code (for detecting the orange ball) on this workstation. The segway driver is not really required on the workstation, but having it can facilitate debugging. The last step tells rosws about the package that you will create for this assignment
rosws merge http://utexas-ros-pkg.googlecode.com/svn/trunk/rosinstall/experimental.rosinstall rosws merge http://utexas-ros-pkg.googlecode.com/svn/trunk/rosinstall/segway_rmp.rosinstall rosws merge http://utexas-art-ros-pkg.googlecode.com/svn/trunk/rosinstall/sandbox.rosinstall rosws set cmvision --svn https://code.ros.org/svn/wg-ros-pkg/branches/trunk_cturtle/vision/cmvision rosws set asst1_controller
- Next, download all the code. This step may take several minutes (without much output):
rosws update
- Now you have downloaded our code. Let's make this ROS workspace your default workspace. You can setup the appropriate ROS workspace using by adding appropriate lines to your ~/.bashrc file. The last line sets your IP address automatically.
export PATH=${PATH}:~/ros/experimental/scripts
source ~/ros/setup.bash
source set_addr.sh
- At this time, restart all open terminals. Terminals will be aware of the newly downloaded ROS packages. Try running the following commands to make sure everything went ok till now.
roscd segbot_run roscd segway_rmpX echo $ROS_HOSTNAME
- In the echo command above, ensure that the output was something like 128.83.158.XX. Typically, it should be 128.83.158.52 as the IP addresses generally don't change, but can do so on occasion. Here, 128.83.158.52 is the IP of your workstation. You can also check the IP of the workstation using the network manager applet, or typing ifconfig on the command line.
- Create an empty package to hold the code for your assignment. Build all the code you will need for this assignment.
roscreate-pkg asst1_controller rosmake segbot_run rosmake bwi_person_controller rosmake cmvision
- If you need to refer example code from last semester and see one of the example packages from last semester in action, run the rosmake command to build the appropriate package, and follow the instructions in last semester's slides to run the code
- You might want to refer to the ROS cheatsheet for assistance. You can find it here
Disconnecting the robot from the chargers
- Every time you start working with the robot, you should disconnect it from charging at the wall. Locate the robot with the blue tape on it.
- Ask Piyush for help if you have not done this step before
- Remove the marine batter charger and the laptop charger plugs from the wall
- Disconnect the white connector coming out of the battery compartment from the opposite connector on the battery charger
- Connect the battery connector to the opposite connector on the power inverter. The connector very occasionally produces a spark. This is fine.
- Before leaving, ensure that you connect the robot back to the chargers. Follow the instructions at the bottom of the page.
Turning the robot on
- The robot machine is already set up. You now need to go through the ritual of turning it on.
- To turn the power inverter on, flip the switch on the power inverter that rests in between the battery box and the kinect. An led will turn on indicating that the inverter is on and powering the Kinect and the Segway.
- Now turn the Segway base on. Locate the power buttons. First press the green to power the base, you'll feel it sink and stay sunken. Then press the yellow button to turn the segway processors on; you'll hear an audible beep. A picture of the segway buttons for reference is available here
- Finally, turn the segway laptop on. Open up the laptop lid, and press the power button (top-right). Use the user/pass lab/longhorn to log onto the machine.
- Open up a terminal once you are logged in (Ctrl + Alt + t). Obtain the IP address for the robot. Similar to the workstation, it should be in the 128.83.158.XX range. As of right now, the robot typically comes up as 128.83.158.41, but this may change.
- Close the lid, and ensure that the laptop is still properly seated on the segway base.
- You won't be directly working on the robot machine, but will run any commands that you need using SSH from the workstation.
Teleoperation (3 points)
- Open up one terminal on the workstation and start the ROS master. This master will be used by both the workstation and the robot.
roscore
- Open up a terminal on the robot. You can do this by opening a terminal window on the workstation, and connecting to the robot over SSH. First use the ping command for a few seconds to ensure that the robot is reachable (i.e. all the settings are correct and the cables are properly secured). You need to use the IP address that you determined on the robot here:
ping 128.83.158.41 ssh lab@128.83.158.41
- Note: Sometimes it may be confusing whether a terminal is on the workstation or on the robot. Terminal windows logged into the robot will read lab@pharos in the shell. Terminal windows on the workstation will read <your-username>@vision-1
- Ensure that the robot has the correct IP address for the workstation. In the robot terminal, first run the following command:
echo $ROS_MASTER_URI
- If the output of the above command is NOT:
http://<ip-of-desktop>:11311
then you will have to let the robot know the correct IP of the workstation. Open up the ~/.bashrc file on the robot. Since the SSH is command line only, you will need to use nano (or vim if you know how to use it). The command will look like:
nano ~/.bashrc
Edit the last line of this file and set the ROS_MASTER_URI to the correct IP of the workstation. Log out of the SSH session and log back in. Ensure that the ROS_MASTER_URI is set correctly this time.
- In the robot terminal, run the segway driver using the following command:
roslaunch segbot_run segway.launch
- Open up a terminal on the workstation and launch a keyboard teleop script:
rosrun bwi_person_controller bwi_person_controller
- Move the robot around until you are comfortable with it. You can use the GUI, or use the following keybindings when the GUI window is selected (i = forward, , = backward, j = left, l = right, k = stop)
- Troubleshooting: There is an unknown bug somewhere which on occasion causes the segway teleoperation to not work. Ctrl+c the robot terminal running the roslaunch script. If it takes a long time and eventually SIGKILLs the segway_rmp_node, then this error has happened. Just power down the segway base and power it back up again (You don't need to power down the laptop). Run the roslaunch script again and this time teleoperation should work.
- Be comfortable with repeating these steps as necessary. When you get your assignment graded finally, you'll have to repeat these steps.
Color Table Generation (2 points)
- In this step of the assignment, you will run blob detection through the cmvision node to detect the orange ball. You first need to tell the cmvision node what “orange” means, so you'll create the color lookup file first.
- Follow the teleoperation steps above first.
- Open up another robot terminal by SSHing into the robot from a different window. Run the camera driver:
ssh lab@128.83.158.41 roslaunch bwi_camera c310_node.launch
- In a workstation window, run the following command to construct the color table:
rosrun cmvision colorgui image:=image_raw
- The image update will be extremely sluggish, as 640×480 images are being transmitted uncompressed over a pretty slow wireless connection. If you move the robot using the teleoperation gui, you'll see that the images lag a good 5-10 seconds. For color table generation, this does not matter much.
- Place the ball so that it is somewhere in the middle of the image.
- Follow the instructions on the cmvision wiki page to record colors for orange. Create the colors.txt file in your home directory (i.e. ~/colors.txt).
- Since we want to run the cmvision code on the robot, copy this to the robot. Be careful with this step, as you don't want to overwrite somebody else's colors file. Use your own name as the filename here:
scp colors.txt lab@128.83.158.41:/home/lab/cmvision/<first-name>.txt
- You can now close the color gui tool. Open up a third robot terminal by SSHing to the robot. Run the blob generation tool:
rosparam set /cmvision/color_file ~/cmvision/<first-name>.txt rosparam set /cmvision/mean_shift_on false rosparam set /cmvision/spatial_radius_pix 0 rosparam set /cmvision/color_radius_pix 0 rosrun cmvision cmvision image:=image_raw
- Let's test if the workstation is getting the blobs. On the workstation, open up another terminal and ensure that the blobs are being published
rostopic echo /blobs
Following the ball (5 points)
- Change directories to the package you created when you were setting up the code.
- Add the necessary dependencies in your manifest.xml file as you write your code.
- Write a single node in this package (C++ or Python) that takes in the topic /blobs (cmvision/Blobs) and publishes the velocity on the topic /cmd_vel (geometry_msgs/Twist). The forward velocity is place in twist.linear.x, and the angular velocity in twist.angular.z.
- Your goal will always be to face the ball, and roughly stay the same distance to it. Do not exceed velocities of 0.5 m/s and 0.5 rad/s.
- A simple controller might suffer from oscillations instead of facing the ball directly due to latency. For extra credit, design a smooth controller (2 points).
Connecting the robot to the chargers
- Ask Piyush for help if you have not done this step before
- You need to do this before you leave the lab.
- Power off the Segway base and the laptop
- Turn off the power inverter
- Disconnect the power inverter from the battery
- Connect the battery to the battery charger while the battery charger is not plugged into the wall.
- Connect the laptop to the laptop charger. Plug the laptop charger into the wall
- Plug in the battery power charger into the wall. Select battery size as large (6A)
- Congratulate yourself on a good day's work and exit the lab before the robot blows up.