Introduction

A common work-flow for this course will be to log into a lab machine, clone a repository from Github, make your changes, then push those changes before logging out. This activity will walk you through that process, along with the steps of creating a ROS package.

Creating a Workspace

If you haven't yet, run the script ros_config_account.sh.

In addition to setting up your .bashrc file, this script makes sure that ~/catkin_ws is properly configured as a catkin workspace.

Creating a Github Repository

Congratulations! You have a git repository on Github.

Creating and Building The Package

If all went well ~/catkin_ws/src/wander should now be a mostly-empty git repository. The next step is to convert this empty folder to a properly configured ROS package.

  1. First, change directories into your workspace src folder:

    $ cd ~/catkin_ws/src/
  2. Now create the package:

    catkin_create_pkg wander std_msgs rospy
  3. If you look inside your wander folder, you should now see at least two new files: CMakeLists.txt, package.xml. Update package.xml with the correct maintainer and author information.

    The following illustrates a typical layout for a Python-based ROS package:

    wander/
        README.md                    <-- Description for Github page
        package.xml                  <-- Package information
        CMakeLists.txt               <-- Build configuration
        src/                         <-- Importable Python modules go here.
            wander/                  <-- Python package for exportable modules.
                __init__.py          <-- This file turns the folder into a package.
                useful_module.py
        rviz/                        <-- rviz configuration files.
            wander.rviz
        launch/                      <-- Launch files
            wander.launch
        msg/                         <-- Message files
        scripts/                     <-- Scripts that create Python ROS nodes. 
            wander.py
            announce.py
        srv/                         <-- Service files
  4. Create a scripts directory and place your forward.py, bumper.py inside. If you finished wander.py, include that as well, otherwise add wander_non_oo.py and wander_oo_states.py from the Canvas solutions directory. Make sure that the files are executable. Build your newly created package by changing into your workspace directory and typing:

    catkin_make

    Once this command completes, there should be devel and build directories alongside the existing src directory. Type the following commands into the terminal:

    source devel/setup.bash
    rospack profile

    The first command will configure your environment so that the ROS system is aware of your newly created package. The second command isn't strictly necessary. It forces an immediate update of the ROS's package list. Without this command it may take a couple of minutes before ROS "notices" that your new package exists.

    You should now be able to interact with your package using ROS command line tools:

    rosrun wander wander.py

Congratulations! You now have a fully-functional, properly built, ROS package.

Saving Your Work

Once you are satisfied with your package, commit your work, and push it back to stu by completing the following steps:

Sharing

Once you have completed the steps above, log out of the laptop and let your partner(s) log in using their own account. The partner should follow the Github assignment link to join the project group. He or she should then clone the repository and confirm that everything is working as expected. When cloning the repository you'll neet to make sure that the resulting folder name corresponds to the package name.

If you clone the package like this:

git clone GIT_URL

The folder will have the same name as the package.

If you clone it like this:

git clone GIT_URL wander

all should be well.

Submitting

There is nothing to submit for this lab. I'll check your work through Github.

If You Have Extra Time

Modify your wander.py solution (or one of mine) so that the wandering is random. Rather than turning for some fixed period of time, turn by some randomly determined angle. Push your changes to the Github repository.