Introduction To Robot Operating System (ROS) - GitHub Pages

Transcription

Introduction to RobotOperating System (ROS)Mayank MittalMay 22, 2018System Integration Using ROS FrameworkMayank Mittal

Outline What is ROS?ROS Communication Layer ROS Ecosystem ROS MasterROS NodesTopics, Services, ActionsROS PackagesCatkin build systemLibraries/Tools in ROS Point Cloud (PCL Library)Coordinate Transformation (Tf Library)System Integration Using ROS FrameworkMayank Mittal

CameraLaserscannerIMURobotMotor andEncoderHow to integrate sensors andactuators in your robotsoftware suite?AE640A:SystemIntegrationLecture 1:UsingSystemROSIntegrationFrameworkUsing ROS FrameworkGPSMayank Mittal

Intel NUCArduinoRobotRaspberry PiSystem Integration Using ROS FrameworkHow to interface the hardwareusing microprocessors andmicrocontrollers?ODROID XU4Mayank Mittal

What is ROS? A “meta” operating system for robotsA collection of packaging, softwarebuilding toolsAn architecture for distributedinterprocess/ inter-machinecommunication and configurationDevelopment tools for system runtimeand data analysisA language-independent architecture(c , python, lisp, java, and more)Slide Credit: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

What is ROS?Slide Credit: Marco Hutter, ETH ZurichSystem Integration Using ROS FrameworkMayank Mittal

What is ROS not? An actual operating systemA programming languageA programming environment / IDEA hard real-time architectureSlide Credit: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

What does ROS get you?All levels of developmentSlide Credit: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

ROS Communication Layer : ROS Core ROS Master Centralized Communication Server based on XML and RPC Negotiates the communication connections Registers and looks up names for ROS graph resources Parameter Server Stores persistent configuration parameters and other arbitrary data. rosout Network based stdout for human readable messages.Slide Credit: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

ROS Communication Layer : Graph Resources Nodes Processes distributed over the network. Serves as source and sink for the data sent over the network Parameters Persistent data such as configuration and initialization settings, i.e thedata stored on the parameter server. e.g camera configuration Topics Asynchronous many-to-many communication stream Services Synchronous one-to-many network based functionsSlide Credit: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

ROS Communication Protocols: Connecting Nodes ROS Topics ROS Services Asynchronous “stream-like” communicationStrongly-typed (ROS .msg spec)Can have one or more publishersCan have one or more subscribersSynchronous “function-call-like” communicationStrongly-typed (ROS .srv spec)Can have only one serverCan have one or more clientsActions Built on top of topicsLong running processesCancellationSlide Credit: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

Asynchronous Distributed CommunicationInterfaces with the camerahardware and reads the datatransmitted by the sensorUsed to display imagesImage Courtesy: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

Asynchronous Distributed Communicationadvertise(“images”)camera node is run. It starts advertising thedata it has receivedImage Courtesy: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

Asynchronous Distributed Communicationtopic:imagesmaster registers the topic with name imagesImage Courtesy: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

Asynchronous Distributed ewer node is run. It asks for data beingpublished in topic with name imagesImage Courtesy: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

Asynchronous Distributed ster ‘connects’ the viewer node to thecamera node.Image Courtesy: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

Asynchronous Distributed Communicationtopic:imagesimages(tcp)master ‘connects’ the viewer node to thecamera node.Image Courtesy: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

Asynchronous Distributed mera node sends the data to the viewernode using TCP/IP based protocolImage Courtesy: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

Asynchronous Distributed mera node sends the data to the viewernode using TCP/IP based protocolImage Courtesy: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

Asynchronous Distributed mera node sends the data to the viewernode using TCP/IP based protocolImage Courtesy: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

ROS MasterMaster Manages the communicationbetween nodesEvery node registers at startup withthe masterStart a master with roscoreMore info:http://wiki.ros.org/MasterSlide Credit: Marco Hutter, ETH ZurichSystem Integration Using ROS FrameworkMayank Mittal

ROS NodesMaster Single-purpose, executable programIndividually compiled, executed, andmanagedOrganized in packagesRegistrationNode 1RegistrationNode 2Run a node with rosrun package name node nameSee active nodes with rosnode listMore info:http://wiki.ros.org/rosnodeSlide Credit: Marco Hutter, ETH ZurichSystem Integration Using ROS FrameworkMayank Mittal

ROS TopicsMaster Nodes communicate over topics Nodes can publish or subscribe to a topicTypically, 1 publisher and n subscribersRegistrationRegistrationTopic is name for stream of messagesNode 1Node 2PublisherSubscriberSee active topics with rostopic listSubscribe and print the contents of a topic withPublishTopicSubscribe rostopic echo /topicMore info:http://wiki.ros.org/rostopicSlide Credit: Marco Hutter, ETH ZurichSystem Integration Using ROS FrameworkMayank Mittal

ROS MessagesMaster Data structure defining the type of a topic Comprised of a nested structure of integers,floats, strings etc. and arrays of objectsRegistrationRegistrationDefined in *.msg filesNode 1Node 2PublisherSubscriberSee the type of a topic rostopic type /topicPublish a message to a topic rostopic pub /topic type argsPublishint numdouble widthstring data etc.Message DefinitionSystem Integration Using ROS FrameworkTopicSubscribeMore info:http://wiki.ros.org/messagesSlide Credit: Marco Hutter, ETH ZurichMayank Mittal

ROS MessagesMore info:http://wiki.ros.org/std msgsSlide Credit: Marco Hutter, ETH ZurichSystem Integration Using ROS FrameworkMayank Mittal

ROS ServicesMaster Request/response communicationbetween nodes is realized with services RegistrationRegistrationThe service server advertises the serviceThe service client accesses this serviceSimilar in structure to messages, servicesare defined in *.srv filesNode 1Node 2Service ClientService ServerList available services with rosservice listRequestShow the type of a service rosservice type /service nameRequest--ResponseService DefinitionSystem Integration Using ROS FrameworkServiceNameResponseMore info:http://wiki.ros.org/messagesSlide Credit: Marco Hutter, ETH ZurichMayank Mittal

ROS ActionMaster Similar to service calls, but providepossibility to RegistrationRegistrationCancel the task (preempt)Receive feedback on the progressBest way to implement interfaces totime- extended, goal-orientedbehaviorsSimilar in structure to services, actionare defined in *.action filesInternally, actions are implementedwith a set of topicsNode 1Node 2Action ClientAction ServerGoalCancelActionGoal--Result--FeedbackAction DefinitionSystem Integration Using ROS FrameworkStatusResultFeedbackMore info:http://wiki.ros.org/messagesSlide Credit: Marco Hutter, ETH ZurichMayank Mittal

ROS ActionMore info:http://wiki.ros.org/messagesSlide Credit: Marco Hutter, ETH ZurichSystem Integration Using ROS FrameworkMayank Mittal

ROS Packages Separate message definitionpackages from other packages!ROS software is organized intopackages, which can contain sourcecode, launch files,configuration files,message definitions, data, anddocumentationA package that builds up on/requiresother packages (e.g. messagedefinitions), declares these asdependenciesTo create a new package, use: catkin create pkg package name {dependencies}More info:http://wiki.ros.org/PackagesSlide Credit: Marco Hutter, ETH ZurichSystem Integration Using ROS FrameworkMayank Mittal

How to organize code in a ROS ecosystem?ROS code is grouped at two different levels: Packages: A named collection of software that is built and treated as an atomic dependency in the ROSbuild system.Stacks: A named collection of packages for distribution.Slide Credit: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

How to organize code in a ROS ecosystem?“package”System Integration Using ROS Framework“stack”Mayank Mittal

catkin Build System catkin is the ROS build system to generate executables, libraries, andinterfacesThe catkin command line tools are pre-installed in the provided installation.Navigate to your catkin workspace with cd /catkin wsBuild a package with catkin make --package package nameWhenever you build a new package, update your environment source devel/setup.bashSlide Credit: Lorenz Mösenlechner, TU MunichSystem Integration Using ROS FrameworkMayank Mittal

catkin Build SystemThe catkin workspace contains the following spacesThe source space containsthe source code. This iswhere you can clone,create, and edit sourcecode for the packages youwant to build.The build space is whereCMake is invoked to buildthe packages in the sourcespace. Cache informationand other intermediate filesare kept here.The development (devel)space is where built targetsare placed (prior to beinginstalled).Slide Credit: Marco Hutter, ETH ZurichSystem Integration Using ROS FrameworkMayank Mittal

ROS Launch launch is a tool for launching multiplenodes (as well as setting parameters)Are written in XML as *.launch filesIf not yet running, launch automaticallystarts a roscoreStart a launch file from a package with roslaunch package name file name.launchMore info:http://wiki.ros.org/roslaunchSlide Credit: Marco Hutter, ETH ZurichSystem Integration Using ROS FrameworkMayank Mittal

ROS Parameter Server Nodes use the parameter server tostore and retrieve parameters atruntimeBest used for static data such asconfiguration parametersParameters can be defined in launchfiles or separate YAML filesList all parameters with rosparam listMore info:http://wiki.ros.org/rosparamSystem Integration Using ROS FrameworkMayank Mittal

ROS GUI Toolsrqt : A QT based GUI developed for ROSrviz : Powerful tool for 3D Visualization(demo in next class)System Integration Using ROS FrameworkMore info:http://wiki.ros.org/rqtMayank Mittal

ROS Time Normally, ROS uses the PC’s systemclock as time source (wall time)For simulations or playback of loggeddata, it is convenient to work with asimulated time (pause, slow-downetc.)To work with a simulated clock: Set the /use sim time parameter To take advantage of the simulatedtime, you should always use theROS Time APIs: ros::Timeros::Time begin ros::Time::now();double secs begin.toSec(); ros::Durationros::Duration duration(0.5); // 0.5s rosparam set use sim time true Publish the time on the topic /clock from Gazebo (enabled by default) ROS bag (use option --clock)More info:http://wiki.ros.org/ClockSlide Credit: Marco Hutter, ETH ZurichSystem Integration Using ROS FrameworkMayank Mittal

ROS Bags A bag is a format for storingmessage dataBinary format with file extension *.bagSuited for logging and recordingdatasets for later visualization andanalysisRecord all topics in a bag rosbag record --allShow information about a bag rosbag info bag name.bagRecord given topics rosbag play [options] bag name.bag--rate factor--clockPublish rate factorPublish the clock time (setparam use sim time to true)--loopLoop playbackRecord given topics rosbag record topic 1 topic 2 topic 3More info:http://wiki.ros.org/ClockSlide Credit: Marco Hutter, ETH ZurichSystem Integration Using ROS FrameworkMayank Mittal

Libraries/Tools available with ROSImage Courtesy: Open Source Robotics FoundationSystem Integration Using ROS FrameworkMayank Mittal

Homework Install ROS Kinetic on your laptop (Ubuntu 16.04LTS) Instructions: http://wiki.ros.org/kinetic/Installation/Ubuntu Alternate Option: Download Shell Script (available here) Run on terminal: ./install ROS kineticAttempt tutorials on Robot Operating System (available online)System Integration Using ROS FrameworkMayank Mittal

References Slides from lectures on ‘Programming for Robotics’ by ETH ZurichA Gentle Introduction to ROS, Jason M. O'Kane. Oct 2013 (available online)Berger, E., Conley, K., Faust, J., Foote, T., Gerkey, B.P., Leibs, J., Ng, A.Y.,Quigley, M., & Wheeler, R. (2009). “ROS: an open-source Robot OperatingSystem”.System Integration Using ROS FrameworkMayank Mittal

Operating System (ROS) Mayank Mittal May 22, 2018 System Integration Using ROS Framework Mayank Mittal. . Synchronous one-to-many network based functions Mayank Mittal Slide Credit: Lorenz Mösenlechner, TU Munich . Open Source Robotics Foundation System Integration Using ROS Framework. Homework Mayank Mittal