Skip to content

Tutorial: ROS

Minh-Khang Vu edited this page Nov 21, 2019 · 6 revisions

Introduction to ROS

ROS stands for Robot Operating System, and is a communications protocol for disparate pieces of code to talk to one another using a standardized format for messages. In the Human Interactions Robotics Lab, we use ROS to tell the robots where to move their various joints. We can also tell the robots to run a certain series of moves through a different message type.

Installing ROS

To start installing ROS (Kinetic distro), go to Installing and Configuring Your ROS Environment:

  • Install ROS (UR5 currently runs on Ubuntu 16.04 and ROS Kinetic)
  • Manage your Environment
  • Create a ROS Workspace (catkin workspace, rosbuilds are an older implementation).

Beginner Tutorials

To start learning about the basics of ROS, go to ROS Tutorials and do the following tutorials:

If you find language that you don't understand, you can do the tutorials in sequential order as found on the ROS Tutorials page, but these are the most important ones. Also, if you want to unlock more of the immense potential of ROS, feel free to keep reading! As always, if you have questions, check the troubleshooting page, then ask someone! Don't struggle in silence.

Creating a ROS package in Python

Follow this tutorial to create a ROS package: http://wiki.ros.org/ROS/Tutorials/CreatingPackage

To make the package work with Python, first, uncomment this line by removing the # in CMakeLists.txt

catkin_python_setup()

Next, create a setup.py file to make your python modules in the include/pkg_your_handle folder available to other packages in the workspace. By default, this is not created by the catkin_create_pkg script. So let’s create one using nano:

$ cd catkin_ws/src/<package_name>
$ nano setup.py

Copy and paste the following to the setup.py file (to paste into a terminal, use Ctrl+Shift+V)

## ! DO NOT MANUALLY INVOKE THIS setup.py, USE CATKIN INSTEAD
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

# fetch values from package.xml
# replace <package_name> with your package name!
setup_args = generate_distutils_setup (
  packages=['<package_name>'],
  package_dir={'': 'include'},
)
setup(**setup_args)

The packages = [...], is set to a list of names (string) of the folders inside the include folder. The convention is to set the folder name the same as the package name. Here it's the include/<package_name> folder. This configures the <package_name>/include/<package_name> folder as a python module available to the whole workspace. You should put ROS­ independent and/or reusable code module (for this, and other modules) in the include/<package_name> folder.

Reference: http://duckietown.mit.edu/media/pdfs/1rpRisFoCYUm0XT78j-nAYidlh-cDtLCdEbIaBCnx9ew.pdf

Tips

To enable ROS debug message output to the terminal window:
http://wiki.ros.org/rosconsole#Configuration