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.
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.
Copy the URL for the assignment invitation from the course Piazza page. Paste the URL into your browswer window and follow the link.
Follow the instructions to select a team name for this assignment. You should see a page with some text like the following:
Your assignment has been created here: https://github.com/JMU-CS354/packaging-lab-354SampleStudent
Click on the link to access the Github page for your repository.
Complete the following steps in order to create an empty git
repository. Don't just copy and paste the instructions below!
Make sure you understand the meaning of each step. (GIT_URL
should be replaced with the URL for your Github project. It
should look something like:
https://github.com/JMU-CS354/packaging-lab-354SampleStudent.git
)
$ cd ~/catkin_ws/src
$ mkdir wander
$ cd wander
$ git init
$ echo "# Packaging Lab" >> README.md
$ git add README.md
$ git commit -m "first commit"
$ git remote add origin GIT_URL
$ git push -u origin master
Congratulations! You have a git repository on Github.
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.
First, change directories into your workspace src
folder:
$ cd ~/catkin_ws/src/
Now create the package:
catkin_create_pkg wander std_msgs rospy
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
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.
Once you are satisfied with your package, commit your work, and push it back to stu by completing the following steps:
Change into your package folder and type:
git add *
to add all of your newly created files to the repository.
Commit your changes by typing:
git commit -m 'Added wander code.'
Every time you commit your code you MUST provide a reasonably informative commit message.
Push your changes
git push
Your changes are not safe until you complete this step! Once you have completed the previous step, test that everything is OK by accessing your repository through the Github web interface. You should be able to see the files you've pushed.
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.
There is nothing to submit for this lab. I'll check your work through Github.
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.