Top Banner
ROS - Session 1 ROS Workshop at the School of Engineering, UNAM Viktor Seib [email protected] Institute for Computational Visualistics University of Koblenz-Landau August 10th, 2015 V. Seib – ROS - Session 1 Slide 1
102
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript

ROS - Session 1ROS Workshop at theSchool of Engineering, UNAMViktor [email protected] Computational VisualisticsUniversity of Koblenz-LandauAugust 10th, 2015V. Seib ROS - Session 1 Slide 1About meViktor SeibDiploma in Computer Sciences inKoblenz (2010)since 2011:Research assistant inthe Active Vision Group, supervisedby Prof.Dr.-Inf. Dietrich PaulusResearch topics:Affordancedetection, 2D/3D object recognitionfor service robotsTeam Leader of teamhomer@UniKoblnez since 20121st place in RoboCup@Home 2015!V. Seib ROS - Session 1 Slide 2About Koblenzlocated at the conuence ofthe rivers Rhine and Moselabout 109,000 inhabitantsuniversity with 7,000students (1,500 incomputer sciences)KoblenzV. Seib ROS - Session 1 Slide 3AgendaV. Seib ROS - Session 1 Slide 4IntroductionROS Filesystem and CatkinNodesTopics and MessagesServicesParameter ServerSummaryV. Seib ROS - Session 1 Slide 5Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryIntroductionROS Filesystem and CatkinNodesTopics and MessagesServicesParameter ServerSummaryV. Seib ROS - Session 1 Slide 6Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryROS (Robot Operating System)ROS is an open-source middleware for robots.it provides implementation of commonly-used functionality,message-passing between processes, and package management.1all ROS core code is licensed BSD easy to integrate in your projectmaintained by the Open Source Robotics Foundation, supported byWillow Garagemany device drivers and algorithms are available1http://www.ros.org (where the following material is taken from)V. Seib ROS - Session 1 Slide 7Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryGoalsROS is a distributed framework of processes (akaNodes)enables executables to be individually designed andloosely coupled at runtimesupports code reuse in robotics research and developmentLanguage independence: Python and C++ (and others)Scaling:ROS is appropriate for large runtime systems andfor large development processesV. Seib ROS - Session 1 Slide 8Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryHighlightsEnables separate communities to exchange software andknowledge.Resources:Distributions:ROS Distributions are collections ofversioned packages that you can install (comparable toLinux distributions)Repositories:Different institutions can develop andrelease their own robot software componentsThe ROS Wiki:The ROS community Wiki is the mainforum for documenting information about ROS (wheremost of this information comes from!)Mailing Lists:ros-users mailing listBlog:http://planet.ros.org/V. Seib ROS - Session 1 Slide 9Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryHighlightsROS is a common platform with worldwide acceptance:14 of 17 teams in this years RoboCup@Home use ROSRoCKIn@Home competition assumes ROS as default middlewareROS website2lists instructions to install ROS on 74 different robotsCurrent releases:newest:Jade Turtle (supported till May 2017)long term support:Indigo Igloo (supported till April 2019) (used here)2http://wiki.ros.org/RobotsV. Seib ROS - Session 1 Slide 10Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryConceptsROS has two important levels of concepts:Filesystem level:ROS resources on diskComputation Graph level:peer-to-peer network of ROSprocesses during runtimeV. Seib ROS - Session 1 Slide 11Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryConcepts: Filesystem levelROS resources that you encounter on diskWorkspace: A catkin workspace contains your ROS packagesPackages: Main unit for organizing software in ROS, e.g. ROS runtimeprocesses (nodes), ROS-dependent libraries, datasets, congurationlesManifests:Package manifests (package.xml) provide metadataabout a package (e.g. dependencies, compiler ags).Message (msg) types:Message descriptions, dene the datastructures for messages sent in ROS.Service (srv) types:Service descriptions, dene the request andresponse data structures for services in ROS.Action (action) types:Action descriptions, dene advanced requestand response data structures for the actionlib in ROS.V. Seib ROS - Session 1 Slide 12Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryConcepts: Computation Graph LevelComputation Graph:Peer-to-peer network of ROS processesthat are processing data together.The basic computation graph components of ROS are:masterparameter servernodesmessagestopicsservicesbagsV. Seib ROS - Session 1 Slide 13Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryIntroductionROS Filesystem and CatkinNodesTopics and MessagesServicesParameter ServerSummaryV. Seib ROS - Session 1 Slide 14Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryROS TutorialROS:http://www.ros.org/wiki/ROS/TutorialsCatkin: http://www.ros.org/wiki/catkinAlso see: ROS Cheat SheetV. Seib ROS - Session 1 Slide 15Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryInstallationPreferred platform:Ubuntu (and other UNIX based OS)For installation seewww.ros.org/wiki/indigo/Installation/UbuntuExamples given for Ubuntu 14.04:Setup yoursources.list le (ROS server)$ sudo sh -c echo "deb http://packages.ros.org/ros/ubuntu$(lsb_release -sc) main" >/etc/apt/sources.list.d/ros-latest.listSet up your keys$ sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net--recv-key 0xB01FA116V. Seib ROS - Session 1 Slide 16Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummarySetupUpdate your package list and install ROS:$ sudo apt-get update$ sudo apt-get installros-indigo-desktop-fullInitializerosdep before using ROSrosdep is a tool to manage system dependencies$ sudo rosdep init$ rosdep updateV. Seib ROS - Session 1 Slide 17Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummarySetupEnvironment setup (add to/.bashrc):$ source /opt/ros/indigo/setup.bashsimply type:$ echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc$ source ~/.bashrcOptionally:select an editor (add to/.bashrc):$ export EDITOR=geditGetrosinstall (convenient tool to download manysource trees for ROS packages):$ sudo apt-get install python-rosinstallV. Seib ROS - Session 1 Slide 18Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryCatkin3catkin is the ofcial build system of ROS and thesuccessor to rosbuild (used until ROS fuerte)catkin extends CMake to manage dependencies betweenpackagescatkin adds support for automatic nd packageinfrastructure and building multiple projects at the sametimeTo start developing with ROS we rst need a catkinworkspace3seehttp://www.ros.org/wiki/catkinV. Seib ROS - Session 1 Slide 19Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryPrepare Catkin WorkspacePrerequisites:catkin installed and environment sourced:$ source /opt/ros/indigo/setup.shCreate a catkin workspace:$ mkdir -p ~/catkin_ws/src$ cd ~/catkin_ws/src$ catkin_init_workspaceV. Seib ROS - Session 1 Slide 20Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryPrepare Catkin WorkspaceWe have an empty workspace with aCMakeLists.txt linkBuild the workspace:$ cd ~/catkin_ws/$ catkin_makeSource the new setup:$ source devel/setup.bashfor convenience, add it to your .bashrc:$ echo "source ~/catkin_ws/devel/setup.bash">> ~/.bashrcalso add your workspace to the$ROS_PACKAGE_PATH:$ echo "export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/catkin_ws" >> ~/.bashrcV. Seib ROS - Session 1 Slide 21Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryBuilding Packages in a catkin WorkspaceWhen callingcatkin_makesource les, scripts or any other static les will remain inthe source spaceany generated les such as libraries, executables, orgenerated code will be placed in the devel spacein the devel space also setup.*sh les will be generatedyou should source them to include your workspace in theenvironmentAlso take a look athttp://www.ros.org/wiki/catkin/Tutorials/workspace_overlaying for advanced uses of a workspace.V. Seib ROS - Session 1 Slide 22Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryCatkin WorkspaceA typical catkin workspace looks like this:workspace_folder/ -- WORKSPACEsrc/ -- SOURCE SPACE# this is where your packages (source code) will bebuild/ -- BUILD SPACE# this will contain CMake and catkin cache files etc.devel/ -- DEVELOPMENT SPACE# this will contain generated files such as# libraries and executablesUnofcial rule of thumb:if you get strange errors that you can not resolve otherwise:delete the build space and rebuild your workspaceV. Seib ROS - Session 1 Slide 23Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryCreating a PackagePlease remember the lesystemconcepts:Workspace:A catkin workspace contains your ROSpackagesPackages:Main unit for organizing software in ROS, e.g.ROS runtime processes (nodes), ROS-dependent libraries,datasets, conguration lesManifests:Package manifests (package.xml) providemetadata about a package (e.g. dependencies, compilerags).V. Seib ROS - Session 1 Slide 24Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryCreating a PackageROS code is organized in packagesTo start developing with ROS we need a package withinour catkin workspaceThe simplest possible package might look like this:my_package/CMakeLists.txtpackage.xmlV. Seib ROS - Session 1 Slide 25Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryCreating a PackageRequirements for valid catkin packages:the package must contain a catkin compliant package.xmlle that provides meta information about the packagethe package must contain a CMakeLists.txt which usescatkinthere can be no more than one package in each folder (nonested packages, no multiple packages in the samedirectory)V. Seib ROS - Session 1 Slide 26Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryCreating a Packagecatkin_create_pkg: creates a new ROS packageUsage:catkin_create_pkg Dependencies to other packages:catkin_create_pkg [depend1][depend2] ...Files in a fresh package:package.xmlCMakeLists.txtV. Seib ROS - Session 1 Slide 27Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryCreating a ROS PackageTry it!change to folder:cd ~/catkin_ws/srcCreate package (all in one line):$ catkin_create_pkg beginner_tutorialsstd_msgs rospy roscppV. Seib ROS - Session 1 Slide 28Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryCustomizing your PackageCustomize the auto-generated le package.xml:description tag:change the description to anything you likethe rst sentence should be short and cover the scope ofthe packagemaintainer tags:lets others know who to contact about thepackagelicense tag:choose a license and ll it in hereV. Seib ROS - Session 1 Slide 29Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryCustomizing your PackageCustomize the auto-generated le package.xml:dependencies tags:dependencies of your packagedependencies are split into build_depend,buildtool_depend, run_depend, test_dependall listed dependencies when creating the package havebeen added as build_dependin this case we want all of them to be also available at runtime, we add:roscpprospystd_msgsV. Seib ROS - Session 1 Slide 30Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryCustomizing your PackageThe nal package.xml (comments removed):

beginner_tutorials0.1.0The beginner_tutorials packageYour NameBSDhttp://wiki.ros.org/beginner_tutorialsJane Doecatkinroscpprospystd_msgsroscpprospystd_msgs

V. Seib ROS - Session 1 Slide 31Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryBuilding Packages in a catkin Workspacecatkin_make is a command line tool which adds someconvenience to the standard CMake workowusage in a catkin workspace:$ catkin_make [make_targets] [-DCMAKE_VARIABLES=...]V. Seib ROS - Session 1 Slide 32Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryBuilding Packages in a catkin Workspacecatkin_make is equivalent to the following in a CMakeproject:$ mkdir build$ cd build$ cmake ..$ makethis needs to be done for each CMake projectV. Seib ROS - Session 1 Slide 33Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryBuilding Packages in a catkin Workspacein contrast catkin projects can be built together in workspacesbuilding zero to many catkin packages in a workspace follows this workow:# In a catkin workspace$ catkin_makecatkin_make will build any catkin projects found in the src folderFor more advanced uses ofcatkin_make see:http://www.ros.org/wiki/catkin/commands/catkin_makeV. Seib ROS - Session 1 Slide 34Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryBuilding Packages in a catkin WorkspaceTypical workow in a catkin package:$ cd ~/catkin_ws/src/beginner_tutorials/srcAdd/Edit source les$ cd ~/catkin_ws/src/beginner_tutorialsUpdate CMakeFiles.txt to reect any changes to your sources$ cd ~/catkin_ws$ catkin_makeV. Seib ROS - Session 1 Slide 35Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryNavigating the ROS FilesystemFor ROS there is lots of code spread across many packagestools for easier le system navigation providedwill only search/nd (sub)directories of yourROS_PACKAGE_PATH environment variableView yourROS_PACKAGE_PATH:$ echo $ROS_PACKAGE_PATHV. Seib ROS - Session 1 Slide 36Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryNavigating the ROS FilesystemNote:For catkin, the most important environment variable is theCMAKE_PREFIX_PATHhelps CMake nd other CMake projectsCatkin packages are a special case of a CMake project,hence the need for this variableWhen a catkin setup le is sourced, this variable getsappended with the corresponding package pathIn a sense, theCMAKE_PREFIX_PATH essentially has thesame role asROS_PACKAGE_PATHV. Seib ROS - Session 1 Slide 37Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryNavigating the ROS FilesystemFilesystem Tools:rospack:A tool to inspect packagestryrospack help to see more optionsrospack list:List all packagesrospack find:Get information about packagestry$ rospack find roscppV. Seib ROS - Session 1 Slide 38Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryNavigating the ROS FilesystemFilesystem Tools:roscd allows you to change directory directly to a packageroscd roscpproscd roscpp/msgROS commands provide Tab-completitionroscd roscpp_tut TAB keyroscd tur TAB keyV. Seib ROS - Session 1 Slide 39Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryInspecting the new ROS PackageMake sure new directories are found:$ rospack profiletry it out: rospack find beginner_tutorialstry it out: roscd beginner_tutorialsV. Seib ROS - Session 1 Slide 40Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryROS Package Dependencieswithcatkin_create_pkg a few package dependencieswere providedthese rst-order dependencies can be reviewed with therospack toolrospack depends1 [package] shows the rst-orderdependencies of the packageTry it!$ rospack depends1 beginner_tutorialsstd_msgsrospyroscppV. Seib ROS - Session 1 Slide 41Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryROS Package Dependenciesthese dependencies for a package are stored in thepackage.xml lein many cases, a dependency will also have its owndependenciesrospack can recursively determine all nesteddependencies$ rospack depends beginner_tutorialsnd out which packages depend on another package:$ rospack depends-on beginner_tutorialsthe output of this command should be emptyV. Seib ROS - Session 1 Slide 42Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryROS Package DependenciesWhat to do if system dependencies are missing?rosdep:Resolve system dependenciesInstall the systemdependencies:$ rosdep install turtlesimV. Seib ROS - Session 1 Slide 43Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummarySummary tools and catkincatkin_init_workspace = creates a catkin workspacecatkin_make = makes (compiles) a catkin workspacecatkin_create_pkg = creates a new catkin packagerospack = ros+pack(age) :provides information related toROS packagesroscd = ros+cd :changes directory to a ROS package orstackrosdep = ros+dep(endencies) :resolve and install ROSdependenciesV. Seib ROS - Session 1 Slide 44Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryIntroductionROS Filesystem and CatkinNodesTopics and MessagesServicesParameter ServerSummaryV. Seib ROS - Session 1 Slide 45Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryUnderstandingROS NodesQuick Overview of Graph Conceptsnodes:A node is an executable that uses ROS tocommunicate with other nodes.roscore:Master + rosout + parameter serverrosout:ROS equivalent of stdout/stderrV. Seib ROS - Session 1 Slide 46Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server SummaryNodesA node really isnt much more than an executable lewithin a ROS package.Nodes can publish or subscribe to a Topic and can provideor use a Service.ROS nodes use a ROS client library to communicate withother nodes.ROS client libraries allow nodes written in differentprogramming languages to communicate:rospy = python client libraryroscpp = c++ client libraryV. Seib ROS - Session 1 Slide 47Introduction ROS Filesystem and Catkin Nodes Topics and Messages Services Parameter Server Summaryroscoreroscore:Starts the ROS system.$ roscore... logging to /home/vseib/.ros/log/d5f3df62-39bf-11e5-9918-f0def1fd396c/roslaunch-vseib-tp-2360Checking log directory for disk usage. This may take awhile.Press Ctrl-C to interruptDone checking log file disk usage. Usage is