Page tree
Skip to end of metadata
Go to start of metadata

References and Prerequisites

  • Linux
    • Download full book The Linux Command Line
      • Read Chapter 11 - The Environment.  ROS makes use of environment variables, so good to have an understanding of what how they work.
      • Read Chapter 6 - Redirection.  A fundamental aspect of executing Linux commands.
  • ROS Tutorials
    • Work through the ROS Tutorials: Beginner Level 1-7
      • Your expected to work through (actually do the tutorials on your computer!) before doing the exercises below!
      • Important: ROS should be installed in the computers, including the your class laptops.  Please do not (re)-install ROS.  This can cause problems that will be time consuming to fix.  If you believe there are problems with your ROS install, see an instructor so that we can help you safely debug the problem.
      • Note - The tutorials have some variations depending on which distribution of ROS and build environment being used. 
        • Will are using the Kinetic Kame distribution, AKA kinetic.
        • We will be using the catkin build environment.  The rosbuild environment is on its way out.
      • Note: In the first tutorial, Configuring Your ROS Environment, you are asked to run the commands

        source /opt/ros/kinetic/setup.bash
        source ~/catkin_ws/devel/setup.bash

        The tutorial mentions adding these commands to your .bashrc file so that you don't have to issue these commands in each new shell/terminal.  Here is how to accomplish that:

        • Open the file with a text editor: gedit ~/.bashrc

        • Copy the two commands to the end of the file - it will look like so...

        • Save the file and exit

        • Now each time you open a new shell/terminal, these two commands will be executed on startup so that your ROS environment is configured correctly.

Git Repository 

This assignment will be submitted as a git repository on the server.  

  1. On the GitLab website, create a new repository named mrc_hw2 using the server's web interface.  Again, remember that Linux is case-sensitive and there should be no spaces!
  2. On your local machine, create catkin workspace (~/catkin_ws/src)...

    cd ~
    mkdir -p catkin_ws/src
  3. Make a local directory to hold a working copy of the mrc_hw2 repository...

    cd ~/catkin_ws/src
    mkdir mrc_hw2
  4. Then following the directions from the GitLab website to initialize your local repository, commit and push it to the server

Exercise 1: Make a ROS Package in Your Git Repository

In this exercise you will create a ROS package in your catkin workspace, following the tutorials (if you haven't completed these tutorials - see instructions at the top of the page!).  Execute these commands...

cd ~/catkin_ws/src
catkin_create_pkg mrc_hw2 std_msgs
  • What are the two files that are created by this command?

Add those two files to your git repository, commit the changes and push to the origin.  For example,

cd ~/catkin_ws/src/mrc_hw2
git add [FILE1]   # Replace [FILE1] with the file you are adding to the repository
git commit -a -m "Adding [FILE1] to the repository"
git push origin master

"Make" the package using the command catkin_make.  When issuing catkin_make you should be in the root of your catkin workspace, e.g.,

cd ~/catkin_ws
source ./devel/setup.bash

Use rospack to examine the dependencies of your mrc_hw2 package.  Report the list of dependencies (both first order and indirect).

Record your answers by creating a text file in your mrc_hw2 repository called ex1.txt.  This file should be at the path ~/catkin_ws/src/mrc_hw2/ex1.txt.  Add the ex1.txt file to the repository; commit and push.

Exercise 2: Using rospack 

Use the following to get help on the rospack command...

rospack help

We can get a list of all the installed packages like this...

rospack list

This should generate a lot of output - there are many packages installed!

We can use a pipeline to connect the output of our command to a program called 'grep' that will search through it...

rospack list | grep PATTERN

where PATTERN is what we are looking for?

What are the names of the installed package that include the word "smach"

Put your answer in a text file called ex2.txt withing your mrc_hw2 repository.  Add the file to the repos., commit and push.

Exercise 3: Driving a Turtle, One Letter

 As an extension to the ROS Tutorial Understanding ROS Topics, write a shell script to control (open-loop) a turtle. 

Make a new directory called scripts in your git repository.  Add a new file called in the scripts directory.  (The location of this file should be ~/catkin_ws/src/mrc_hw2/scripts/ This file is your shell script. If your file looks like this...

rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[4.0, 0.0, 0.0]' '[0.0, 0.0, 0.0]'
rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[5.0, 0.0, 0.0]' '[0.0, 0.0, -4.5]'

See the syntax of the geometry_msgs/Twist ROS messages.

then you can then execute the script (which just calls each commend sequentially) like this...

cd ~/catkin_ws/src/mrc_hw2/scripts   # Move into the directory that contains

If I have my turtle running I should see something like this...

Extend the script to control your turtle to draw the first letter of your name (either uppercase or lowercase).  

Submit your solution by making sure is part of your repository.  Commit and push.

Exercise 4: Turtle Services, Two Letters

This is an extension of the previous exercise.  You will need to have the turtlesim node running as described in ROS Tutorial 6 Understanding ROS Topics.

Read the documentation for the turtlesim_node program...
Note the services described in the documentation.

Within the scripts directory of your mrc_hw2 ROS package, add a new script called

This new script should draws the first two letters of your first name in two different colors. The location of this file should be ~/catkin_ws/src/mrc_hw2/scripts/
Hint - you will need to use services.

For my first name it might look something like this...

Note: There are many ways to complete this exercise.  The details are not terribly important (lower-case vs. uppercase, two-turtles vs. one-turtle, etc.); the point is to get some practice using ROS topics, services and parameters.

Submit your solution by committing and pushing your script.


To check that you have all the deliverables properly added to your repository it  is a good idea to check the repository on the web interface.

Assuming you didn't do the optional exercises, the structure of your repository should look like this...

  • No labels