18-642 Project 1

Page last updated 9/2/2023 (changelog)

Learning objective: Get your software infrastructure up and running and gain initial understanding of how to use in in support of future projects. Additionally, visit various resources that you'll be accessing during the semester.

*** See Canvas for a video recitation that might be helpful to watch before diving in to this description ***

This project is meant to be an introduction to the ROS (Robot Operating System) interface. You are not expected to become a ROS expert at the end of the course, but you are expected to know how to navigate a ROS workstation and project file structure, build ROS projects, and use ROS messages. The subsequent projects in the course will be based on ROS. (We use ROS 1 for legacy reasons. If you're going on the job market be sure to look into ROS 2.)

If you hit a problem turn in what you can turn in and e-mail the course staff where you got stuck and what the problem was.  We'll sort it out as soon as we can (but it might take into the next week).  So long as you turn in a partial result -- for this project only -- you will NOT get late penalties while waiting to get help to have things set up. The primary purpose of this project is to sort out setup problems so you don't get stuck missing the deadline for Project 2 due to equipment problems. Nonetheless please start Project 1 as soon as you can so you don't get crunched for time on Project 2 if you run into a setup issue.

*** There are Hints at the end of this and most other assignments. READ THEM! ***


Lab Files:


Starting Hints/Helpful Links:

There are more detailed hints also at the bottom of this assignment. We suggest you skim them all before before starting in case you find them helpful.


Procedure:

Part 1: Getting started with ROS

  1. Download the 18-642 VirtualBox image. It runs Ubuntu 16.04 with ROS Kinetic and the ROS Tutorials package installed.
    1. Make a backup copy of this downloaded image (it's a .ova file) in case you need it later in the semester or you corrupt the file system somehow. (It's not going away, but it's a big file to download again.) We recommend you change the name of the .ova file to something like "Proj1_YourName.ova" so you can keep track if you end up with more than one of these.
    2. Install VirtualBox for free from its website (You can also use VMware, which is installed in some ECE machines. See the Canvas support pages for more information), .
    3. Import the VM into VirtualBox by navigating to File -> Import Appliance, navigating to the 18642-ros.ova file you downloaded, pressing next, and pressing import.
    4. "Start" and "show" the image. Give it some time to spin up to display a Linux desktop. (It should be logged in, but if you need an ID, try the username student and password 18642).
    5. Open a bash shell window (right click the black and white terminal icon on the left of the desktop; should be at the bottom of the icon column) and make sure it seems alive.
    6. To enable networking on the VM, Navigate to the Devices menu (at the top of the window), and under "Network," make sure "Connect Network Adapter" icon has a check mark (if you click it and disconnect, just click it again).
    7. The VM Changelog page includes some hints on optimizing the VM to get it to run faster. You should be able to run this lab without doing that, but check this out if you have speed problems.
    8. Note: If you do not wish to use the VM, you can run and install ROS natively following the ROS tutorials. Files you need to complete part 2 of the project are linked at the top of the page. We'll provide very limited support to get ROS running if you choose to go this route because there are just too many uncontrolled variables.
  2. We recommend, but do not require, that you complete ALL the ROS tutorials (Section 1.1 tutorials #1-11).
    1. If you are using the course VM image, ROS Kinetic and the ROS Tutorials packages are already installed, so skip the installation steps.
    2. If you skip ahead to the required tutorials and get confused, step back and start at the beginning of all tutorials.
  3. Follow the ROS Nodes tutorial starting from Step 2. If you get stuck re-read the tutorial instructions carefully, and check the hints section above in this lab writeup. Sometimes you've made a subtle typo that is hard to find, so please try at least twice before you ask for help.
  4. Follow all steps of the Ros Topics tutorial. RQT (beginning of step 2.1) is already installed for you.
    1. Note: This applies to step 6 below, but some students get stuck here before they see step 6: Before attempting `roscd beginner_tutorials`, first run `source ~/catkin_ws/devel/setup.bash`. This only needs to be done once. This file is generated by running 'catkin_make' under 'catkin_ws' according to the instructions.
    2. In Step 1.3, draw a picture with the turtle. Take a screenshot of your picture. Anything non-trivial (beyond one convex polygon) is acceptable. Call it turtlepic_[FAMILY NAME]_[Given Name]_[AndrewID].png.
    3. Notes:
      • You might need to un-check the "namespaces" box to make the picture look the same as in the tutorial. This should not matter substantively in terms of getting the tutorial completed.
      • Follow the instructions for "ROS Hydro" and not "ROS Groovy". You are using a ROS distro after Hydro, but the Hydro instructions should work.
  5. Read the ROS Services and params and Create Msg and Srv tutorials. The file modification steps have already been done for you, but this information is useful for understanding ROS.
  6. Follow the ROS Publisher and Subscriber Tutorial, steps 1 and 2. Build your code by typing catkin_make talker listener in the /home/student/catkin_ws directory.
  7. Follow the ROS tutorial to examine your publisher and subscriber.

Part 2: Write your own publisher

  1. Use what you learned in the above tutorials to write your own publisher for the turtle:
    1. The file /home/student/catkin_ws/src/proj1/src/turtle_publisher_18642.cpp has code for you to get started. The code can be built and run as-is. Read the comments thoroughly and be sure you can run it (Step 3 below) before editing the file.
    2. You must use the /turtle1/cmd_vel topic in your code.
    3. Your code shall draw a figure-eight using the turtlebot. A figure-eight consists of two full circles*, tangent to each other. It is drawn by commanding the turtle at constant, non-zero linear and angular velocities until one full circle is drawn, and then negating the angular velocity until another full circle is drawn.
  2. Build your package by typing catkin_make turtle_publisher_18642 in the /home/student/catkin_ws directory.
  3. Execute your code:
    1. In one terminal, type roscore.
    2. In a second terminal, type rosrun turtlesim turtlesim_node to bring up the turtlesim window.
    3. In a third terminal type rosrun proj1 turtle_publisher_18642 to execute your code.
  4. Write a function (i.e., a subscriber) to print the Turtle's pose (that means: x position, y position, linear velocity, angular velocity as a tuple) to the terminal. The code skeleton gives some hints. (Note: if the code skeleton says "extra credit" ignore that -- this is now required because we've found it helps students in later projects to do this.) Call this function every time you move the turtle. Getting this working might take some looking at code, some web research, etc. Getting more comfortable solving problems this way is one of the course objectives. Be sure to use /turtle1/pose
  5. Take a screenshot of your figure eight and at least a few lines of the printed out pose. This will be a single screenshot that shows two different windows: one a graphical window showing the approximate figure 8 track of your turtle, and one a text window displaying the last handful of pose printout lines. Call it fig8_[FAMILY NAME]_[Given name]_[AndrewID].png

*If you're worried that your turtle is only drawing an approximation of a perfect circle on the screen, we understand. For these purposes, a "circle" is defined as an entity drawn by commanding the turtle at a constant, nonzero linear and angular velocity. Polygons that approximate a circle are OK.


Handin checklist:

  1. Screenshot of your turtle picture from Part 1, step 3.a: turtlepic_[FAMILY NAME]_[Given Name]_[AndrewID].png.
  2. Screenshot of your figure eight and pose printout windows from Part 2, step 4: fig8_[FAMILY NAME]_[Given Name]_[AndrewID].png.
  3. Your turtle_publisher_18642.cpp file, renamed: turpub_[FAMILY NAME]_[Given Name]_[AndrewID].cpp.

** For this and future projects, all-caps, all-lower, and initial caps are all acceptable for all file names in this course regardless of rubric file name capitalization. Please don't use hacker-case or other painful capitalization schemes. Thanks.

Zip these three files and turn them in on Canvas as P01_[FAMILY NAME]_[Given Name]_[Andrew ID].zip (Your AndrewID can be in all lower-case for this and future projects. Any reasonable use of case is acceptable for this and all other hand-ins, including all lower case if you prefer.)
Improperly named files will be rejected by graders. Yes, we're serious. If you don't follow file name conventions it makes the life of the graders quite difficult.

The rubric for the project is found here. IMPORTANT: look at the rubric to make sure you've done everything you should do for this lab. We'll give you a rubric for every lab, and expect you to meet its requirements to get full marks.


Detailed Hints:

Note: in a previous year a student said for 1f "In a third terminal" step 2 command should be: cd ~/catkin_ws/ && source devel/setup.bash && rosrun ece642rtle ece642rtle_student" Please let us know if you encounter this issue so we can sort it out.

Changelog: