Difference between revisions of "ROS Tutorials"

From Lofaro Lab Wiki
Jump to: navigation, search
(Creating a ROS Package)
 
(55 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Practicing writing a wiki page- all information below is incomplete until otherwise noted.
+
This tutorial assumes that you will be working in ROS-hydro on Ubuntu 12.04.
  
Aside to editor, to improve:
 
 
This tutorial assumes that you will be working in ROS-hydro on Ubuntu 12.04.
 
 
This wiki is based on the tutorials given [http://wiki.ros.org/ROS/Tutorials here].
 
This wiki is based on the tutorials given [http://wiki.ros.org/ROS/Tutorials here].
  
Line 9: Line 6:
  
 
Open the terminal. To complete each step, type in the following commands in the order shown.
 
Open the terminal. To complete each step, type in the following commands in the order shown.
 +
# [[Installing and configuring your ROS environment]]
 +
# [[Navigating the ROS Filesystem]]
 +
# [[Creating a ROS Package]]
 +
# [[Building a ROS Package]]
 +
# [[Understanding ROS Nodes]]
 +
# [[Understanding ROS Topics]]
 +
# [[Understanding ROS Services and Parameters]]
 +
# [[Using rqt_consol and roslaunch]]
 +
# [[Using rosed to Edit Files in ROS]]
 +
# [[Creating a ROS msg and srv]]
 +
# [[Writing a Simple Publisher and Subscriber (C++)]]
 +
# [[Writing a Simple Publisher and Subscriber (Python)]]
 +
# [[Examining the Simple Publisher and Subscriber]]
 +
# [[Writing a Simpler Service and Client (C++)]]
 +
# [[Writing a Simpler Service and Client (Python)]]
 +
# [[Examining the Simpler Service and Client]]
 +
# [[Recording and Playing Back Data]]
 +
# [[Getting Started with roswtf]]
 +
# [[Navigating the ROS wiki]]
 +
# [[Where Next?]]
  
==Installing and configuring your ROS environment==
+
=Intermediate Level=
  
We recommend ROS-hydro on Ubuntu 12.04, instructions given on this [http://wiki.ros.org/hydro/Installation/Ubuntu link]. The commands are given below. Complete all of these in the same Terminal during the same session.
+
Open the terminal. To complete each step, type in the following commands in the order shown.
 
+
# [[Creating a ROS Package by Hand]]
'''If not using Ubuntu 12.04 and installing hydro:''' please refer to instructions given [http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment here].
+
# [[Managing System Dependencies]]
 
+
# [[Roslaunch Tips for Large Projects]]
1) Setup sources list:
+
# [[Running ROS Across Multiple Machines]]
 
+
# [[Defining Custom Messages]]
    <nowiki>sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu precise main" > /etc/apt/sources.list.d/ros-latest.list'</nowiki>
+
 
+
You may be prompted for your super-user password. This should be your username password. Type it into the terminal and press ENTER.
+
 
+
2) Setup keys:
+
 
+
    <nowiki>wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -</nowiki>
+
 
+
3) Update Debian package:
+
 
+
    <nowiki>sudo apt-get update</nowiki>
+
 
+
4) Install Desktop-Full:
+
 
+
  <nowiki>sudo apt-get install ros-hydro-desktop-full</nowiki>
+
 
+
5) Initialize rosdep:
+
 
+
  <nowiki>sudo rosdep init</nowiki>
+
  <nowiki>rosdep update</nowiki>
+
 
+
6) Setup Enviornment:
+
 
+
  <nowiki>echo "source /opt/ros/hydro/setup.bash" >> ~/.bashrc</nowiki>
+
  <nowiki>source ~/.bashrc</nowiki>
+
 
+
7) Install rosinstall:
+
 
+
  <nowiki>sudo apt-get install python-rosinstall</nowiki>
+
 
+
==Navigating the ROS Filesystem==
+
 
+
First, if catkin is not already installed, we need to settle some dependencies and install catkin.
+
 
+
Settle dependencies:
+
 
+
  <nowiki>sudo apt-get install cmake python-catkin-pkg python-empty python-nose python-setuptools libgtest-dev build-essential</nowiki>
+
 
+
Install catkin:
+
 
+
  <nowiki>sudo apt-get install ros-hydro-catkin</nowiki>
+
 
+
Now we can focus on navigation. Here is a list of commands to navigate around the ROS files and folders.
+
 
+
*To find the path of a package: <nowiki>rospack find [package-name]</nowiki>
+
Example:
+
  <nowiki>rospack find roscpp</nowiki>
+
 
+
*To change directory: <nowiki>roscd [locationname[/subdir]]</nowiki>
+
Example:
+
  <nowiki>roscd roscpp</nowiki>
+
 
+
*To see your working (current) directory:
+
  <nowiki>pwd</nowiki>
+
 
+
*To see your ROS environment path:
+
  <nowiki>echo $ROS_PACKAGE_PATH</nowiki>
+
 
+
*To move to the folder ROS stores its logs:
+
  <nowiki>roscd log</nowiki>
+
 
+
*To see contents of a particular package: <nowiki>rosls [locationname[/subdir]]</nowiki>
+
Example:
+
  <nowiki>rosls roscpp_tutorials</nowiki>
+
 
+
*TAB completion is also supported.
+
 
+
==Creating a ROS Package==
+
A workspace is created, then a ROS package within the workspace.
+
 
+
'''Creating a Workspace for Catkin'''
+
 
+
1) We create a src file in the catkin_ws folder, move into it, and create a workspace called catkin_init_workspace:
+
  <nowiki>mkdir -p ~/catkin_ws/src</nowiki>
+
  <nowiki>cd ~/catkin_ws/src</nowiki>
+
  <nowiki>catkin_init_workspace</nowiki>
+
2) Then we build the workspace:
+
  <nowiki>cd ~/catkin_ws/</nowiki>
+
  <nowiki>catkin_make</nowiki>
+
3) And create the setup.*sh file:
+
  <nowiki>source devel/setup.bash</nowiki>
+
 
+
'''Creating a ROS Package'''
+
 
+
4) Make sure you are in the src folder you had created earlier:
+
  <nowiki>cd ~/catkin_ws/src</nowiki>
+
 
+
5) Now we create a new ROS package:  <nowiki>catkin_create_pkg <package_name> [depend1] [depend2] [depend3]</nowiki>
+
  <nowiki>catkin_create_pkg beginner_tutorials std_msgs rospy roscpp</nowiki>
+
This will create a beginner_tutorials folder which contains a package.xml and a CMakeLists.txt
+
5a) The package.xml contains the names of the dependenices. These can be checked by looking at the folder or typing:
+
  <nowiki>rospack depends1 beginner_tutorials</nowiki>
+
5b) To see all dependencies for the package and dependencies given in the xml:
+
  <nowiki>rospack depends beginner_tutorials</nowiki>
+
The xml file has a description, maintainer tag, license tag, and dependency list:
+
  <nowiki>1 <?xml version="1.0"?>
+
  2 <package>
+
  3  <name>beginner_tutorials</name>
+
  4  <version>0.1.0</version>
+
  5  <description>The beginner_tutorials package</description>
+
  6
+
  7  <maintainer email="you@yourdomain.tld">Your Name</maintainer>
+
  8  <license>BSD</license>
+
  9  <url type="website">http://wiki.ros.org/beginner_tutorials</url>
+
  10  <author email="you@yourdomain.tld">Jane Doe</author>
+
  11
+
  12  <buildtool_depend>catkin</buildtool_depend>
+
  13
+
  14  <build_depend>roscpp</build_depend>
+
  15  <build_depend>rospy</build_depend>
+
  16  <build_depend>std_msgs</build_depend>
+
  17
+
  18  <run_depend>roscpp</run_depend>
+
  19  <run_depend>rospy</run_depend>
+
  20  <run_depend>std_msgs</run_depend>
+
  21
+
  22 </package></nowiki>
+
 
+
==Building a ROS Package==
+
  
==Understanding ROS Nodes==
 
  
==Understanding ROS Topics==
+
=Advanced=
 +
* [[Setting up RGBDSLAM with ROS in Gazebo]]
 +
* [[Setting up RGBDSLAM with ROS in the real world]]
 +
* [[Raspberry_Pi_and_Arducopter_connections_through_ROS]]
 +
* [[Ros_on_Raspberry_pi]]

Latest revision as of 17:23, 30 October 2014

This tutorial assumes that you will be working in ROS-hydro on Ubuntu 12.04.

This wiki is based on the tutorials given here.

Beginner Level

Open the terminal. To complete each step, type in the following commands in the order shown.

  1. Installing and configuring your ROS environment
  2. Navigating the ROS Filesystem
  3. Creating a ROS Package
  4. Building a ROS Package
  5. Understanding ROS Nodes
  6. Understanding ROS Topics
  7. Understanding ROS Services and Parameters
  8. Using rqt_consol and roslaunch
  9. Using rosed to Edit Files in ROS
  10. Creating a ROS msg and srv
  11. Writing a Simple Publisher and Subscriber (C++)
  12. Writing a Simple Publisher and Subscriber (Python)
  13. Examining the Simple Publisher and Subscriber
  14. Writing a Simpler Service and Client (C++)
  15. Writing a Simpler Service and Client (Python)
  16. Examining the Simpler Service and Client
  17. Recording and Playing Back Data
  18. Getting Started with roswtf
  19. Navigating the ROS wiki
  20. Where Next?

Intermediate Level

Open the terminal. To complete each step, type in the following commands in the order shown.

  1. Creating a ROS Package by Hand
  2. Managing System Dependencies
  3. Roslaunch Tips for Large Projects
  4. Running ROS Across Multiple Machines
  5. Defining Custom Messages


Advanced