18-642 Project 1
Released for Fall 2024(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:
- Download and install VirtualBox from the
VirtualBox software
download site. If you're running a non-Windows machine you probably need
VMware instead; see the Canvas page on VM Hints and Alternatives. VirtualBox is
not designed to run properly on a Mac.
- Here is the
Lab1
Virtualbox image (Updated 8/19/18 4:00pm.
changelog).
Caution -- this is a big file (~3300
MB). Mind your download bandwidth quota if you are off campus! (We
recommend you DIS-connect from CMU VPN to make this transfer to avoid quota
issues. It is a publicly available Internet file.)
- Here are standalone project files if you want to edit them outside of the
virtual machine image:
proj1.zip
for Part 2. (This file already loaded onto the VM, so downloading is optional.)
Updated 8/19/18 4:00pm.
Starting Hints/Helpful Links:
- See the Recitation video and slides on Canvas
- If your personal computer has problems, try some of the CMU computing
resources (see the Canvas page on this).
- Look for the Project 1 hand-in assignment on Canvas. That's where you hand
in the project materials.
- Please follow the handin naming convention: every hand-in filename (before
the file extension) must end in [FAMILY NAME]_[Given Name]_[AndrewID].
(For all assignments we prefer Family Name in all caps as in homework slides,
but any reasonable use of case including all lower case is acceptable.)
- If any of the topics below are new to you, find some tutorials you like and
get up to speed on the following (as grad students you should be able to figure
this stuff out if you haven't already):
- Access the ROS tutorials here: ROS Tutorials. (You'll run through
a couple as part of this project, but there are others you might find helpful
as well.)
- There are hints on using ROS at the end of this lab; if you get stuck check
those as well. Most students are likely to need at least one of these hints in
the first two or three labs, so remember these and come back to these later if
you need them.
- If you are not proficient at using command line tools and scripting or
other software development processes, we suggest you watch lectures 1-8 of the
MIT "Missing Semester" class:
https://missing.csail.mit.edu/
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
- Download the 18-642
VirtualBox
image. It runs Ubuntu 16.04 with ROS Kinetic and the ROS Tutorials package
installed.
- 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.
- 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), .
- 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.
- "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).
- 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.
- 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).
- 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.
- 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.
- We recommend, but do not require, that you complete ALL the
ROS
tutorials (Section 1.1 tutorials #1-11).
- If you are using the course VM image, ROS Kinetic and the ROS Tutorials
packages are already installed, so skip the installation steps.
- If you skip ahead to the required tutorials and get confused, step back
and start at the beginning of all tutorials.
- 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.
- Follow all steps of the
Ros Topics
tutorial. RQT (beginning of step 2.1) is already installed for you.
- 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.
- 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.
- 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.
- 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.
- 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.
- Note: Tutorial 1.0: When the instructions say to call `roscd
beginner_tutorials`, instead run `cd ~/catkin_ws/src/beginner_tutorials` to
avoid a "no package available" error.
- Note: Tutorial 3.0: The modifications to CMAkeLists.txt are already
included in the VM.
- Follow the ROS tutorial to
examine
your publisher and subscriber.
Part 2: Write your own publisher
- Use what you learned in the above tutorials to write your own publisher
for the turtle:
- 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.
- You must use the /turtle1/cmd_vel topic in your code.
- 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.
- Build your package by typing catkin_make turtle_publisher_18642
in the /home/student/catkin_ws directory.
- Execute your code:
- In one terminal, type roscore.
- In a second terminal, type rosrun turtlesim turtlesim_node to
bring up the turtlesim window.
- In a third terminal type rosrun proj1 turtle_publisher_18642 to
execute your code.
- 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
- 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:
- Screenshot of your turtle picture from Part 1, step 3.a:
turtlepic_[FAMILY NAME]_[Given Name]_[AndrewID].png.
- Screenshot of your figure eight and pose printout windows from Part 2,
step 4: fig8_[FAMILY NAME]_[Given Name]_[AndrewID].png.
- 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:
- If you have a problem, check the list before and then try a simple web
search with keywords regarding your problem. Especially if you get an error
message! This is widely deployed technology and the answer to your question is
likely there. Please do a search before asking course staff (who will then most
likely do exactly the same thing, except it will take longer than if you do it
yourself).
- Look at the VM Hints, Alternatives, ECE Facilities page on Canvas for hints
specific to different operating environments.
- These labs were tested with VirtualBox Version 6.1.10. Some students have
better luck with VMWare compared to VirtualBox. It is OK to use either one.
(VMWare requires a license, but CMU has a site license.)
- Check out the "shared folders" option available in both
VirtualBox and VMware, which should permit you to use normal desktop tools to
edit files outside the virtual machine. (A quick web search will point to
how-to info.)
- If you have trouble getting ROS set up, use remote login to one of the ECE
educational machines (or visit a cluster in person if you're able). Complete
the homework on those machines, then come to office hours to ask a TA about
help getting things set up on your machine.
- Pay attention when the tutorial says to open another window; you'll need
multiple windows open to complete the tutorials. You might also have to close
windows with the mouse to proceed (especially the mouse display window). Recall
that that "control-C" is a way to shut down the running task inside a
window.
- Regarding the extra credit mention inside turtle_publisher_18642.cpp file
and point 2.4 in project handout -- please have a look at the project rubric
under the hand-in checklist section on the project page. It mentions that
printing POSE is mandatory and carries normal credit. Always look at the
rubric if you are in doubt as to what is required. The rubric is in
fact what the TAs will be using to grade your hand-in.
- Some students have reported a problem with the publisher/subscriber
tutorial. This was resolved by logging out of the VM image and then logging
back in.
- If ROS isn't finding some packages, try source
~/catkin_ws/devel/setup.bash.
- Be sure to start the roscore command before using rosrun.
- Be sure to run catkin_make in the /home/student/catkin_ws
directory.
- Some students have had problems with full screen mode overflowing their
monitor. Try checking View ->Auto-resize Guest Display
- If you get an error regarding "Vt-x/AMD-V hardware acceleration is not
available" see this posting:
https://stackoverflow.com/questions/45409664/vt-x-amd-v-hardware-acceleration-is-not-available-on-your-system
- Some of you might be running into make errors while even after getting the
build done correctly the first time. If yes, delete the 'build/' and 'devel/'
directories from the 'catkin_ws/' directory and run make (listener or
turtle_publisher_18642) twice. This should help you in building
the code.
- Be sure to check out using "shared folders." Often it
is easier to use your native desktop tools for editing files and then just use
the virtual machine for compile and run.
- The ECE servers have been changing how they deal with URLs. If you have
trouble accessing web resources try the following. Let us know if something
weird happens and we'll look into it, but hopefully these hints will get you up
and running.
- Try manually changing the URL host to both "www.ece.cmu.edu" and
"www.archive.ece.cmu.edu" in the browser URL field if you get a
"not found" or similar error.
- Try accessing via CMU VPN. With that VPN
try "General Use" first, but if that doesn't work try the"Full
VPN" option. We recommend that you do NOT use VPN when downloading the 3
GB .ova file to avoid problems with your Andrew bandwidth quota.
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.