Presentation is loading. Please wait.

Presentation is loading. Please wait.

Robotic Perception and Action

Similar presentations


Presentation on theme: "Robotic Perception and Action"— Presentation transcript:

1 Robotic Perception and Action
ROS Framework

2 What is ROS? Writing a ROS Program References ROS Distribution
ROS Packages ROS Master and Nodes ROS Topics and Messages Writing a ROS Program ROS Workspace Environment ROS Dependencies ROS Package ROS Simple Program: Hello World! Catkin Executing Hello World! helloworld tree References Index

3 Robot Operating System (ROS) is:
Definition Robot Operating System (ROS) is: An open-source, meta OS for your robot It provides the services you would expect from an operating system, including: Hardware abstraction Low-level device control Implementation of commonly-used functionality Message-passing between processes Package management It provides tools and libraries for obtaining, building, writing, and running code across multiple computers Originally developed in 2007 at the Stanford Artificial Intelligence Laboratory and development continued at Willow Garage Since 2013 managed by OSRF (Open Source Robotics Foundation) What is ROS?

4 ROS is not: a programming language (only) a library
an integrated development environment (IDE) What is ROS?

5 A ROS distribution is a versioned set of ROS packages with the purpose to let developers work against a relatively stable codebase until they are ready to roll everything forward. In our case, for the UBUNTU (Trusty LTS) Virtual Machine we use the stable version of ROS INDIGO (IGLOO, 2014) ROS Distribution in Virtual Machine

6 Listing and locating packages > rospack list
All ROS software is organized into packages. A ROS package is a coherent collection of files, generally including both executables and supporting files, that serves a specific purpose. Listing and locating packages > rospack list Each package is defined by a manifest, which is a file called package.xml . This file defines some details about the package, including its name, version, maintainer, and dependencies. The directory containing package.xml is called the package directory. This directory stores most of the package’s files. ROS Packages

7 Retrieve information about a node with:
ROS Master: Manages the communication between nodes Every node registers at startup with the master Start a master with: > roscore ROS Nodes are: Single-purpose, executable program Compiled, executed, and managed Organized in packages Run a node with: > rosrun package_name node_name See active nodes with: > rosnode list Retrieve information about a node with: > rosnode info node_name Package ROS Master and Nodes

8 List active topics with:
Nodes communicate over topics Nodes can publish and/or subscribe to/from a topic Typically, 1 publisher and n subscribers Topic is a name for a stream of messages List active topics with: > rostopic list Subscribe and print the contents of a topic with: > rostopic echo /topic Show information about a topic with: > rostopic info /topic ROS messages are data structure: Defining the type of a topic Compromised of a nested structure of integers, floats, booleans, strings etc. Defined in *.msg files See the type of a topic: > rostopic type /topic Publish a message to a topic: > rostopic pub /topic type args ROS Topics and Messages

9 > mkdir -p ~/catkin_ws/src
If there is not, defines context for the current workspace by creating a folder with the following command: > mkdir -p ~/catkin_ws/src Inside the src workspace directory there will be the source code for packages. There exists a default workspace loaded with: > source /opt/ros/indigo/setup.bash NB: This command MUST BE called every time we start a terminal/shell in which we call a ROS launch or run command (also roscore) Check your workspace with: > echo $ROS_PACKAGE_PATH ROS Workspace Environment

10 ROS packages sometimes require external libraries and tools that must be provided by the operating system (system dependencies). In some cases these system dependencies are not installed by default. Example of dependencies can be: gazebo_msgs: provides message and service data structures for interacting with Gazebo from ROS geometry_msgs: provides messages for common geometric primitives such as points, vectors, and poses. roscpp: it is a C++ implementation of ROS rospy: it is a pure Python client library for ROS sensor_msgs: defines messages for commonly used sensors, including cameras and scanning laser rangefinders. std_msgs: Standard ROS Messages including common message types representing primitive data types and other basic message constructs urdf: contains a C++ parser for the Unified Robot Description Format (URDF), which is an XML format for representing a robot model ROS Dependencies

11 A package is created inside the ws directory with:
Go to src directory: > cd ~/catkin_ws/src A package is created inside the ws directory with: > catkin_create_pkg --rosdistro indigo helloworld roscpp Command ROS Version Package Name Dependencies (OPTIONAL) Inside the directory src automatically the command creates a package directory called helloworld with two files: package.xml: XML file containing all the build/run dependencies CMakeLists.txt: cmake file containing the name of dependencies used and the executable files linked to the target file names And two (optional) directories (because we defined the dependency roscpp and we want to work in cpp): include: put here (if needed and inside the name of package helloworld) all the headers .h files src: put here all the files .cpp ROS Package

12 ROS Simple Program: Hello World!
Go to the src directory and create with gedit a hello.cpp file and copy: /* This is a ROS version of the standard "hello world" program. */ #include <ros/ros.h> // This header defines the standard ROS classes. /* The header file ros/ros.h includes declarations of the standard ROS classes. You’ll want to include it in every ROS program that you write. */ int main (int argc, char **argv){ // Initialize the ROS system . ros::init(argc, argv, "hello"); /* The ros::init function initializes the ROS client library. Call this once at the beginning of your program. The last parameter is a string containing the default name of your node. */ ros::NodeHandle nh; //Establish this program as a ROS node. /* The ros::NodeHandle object is the main mechanism that program uses to interact with the ROS system. */ ROS_INFO_STREAM("Hello, ROS!"); // Send some output as a log message. /* The ROS_INFO_STREAM line generates an info message, sent to locations, including console screen. */ } ROS Simple Program: Hello World!

13 Open with gedit the CMakeLists
Open with gedit the CMakeLists.txt file and copy before the end of file: add_executable(hello src/hello.cpp) # hello is the name of exec, src/hello.cpp the path target_link_libraries(hello ${catkin_LIBRARIES}) In this way we have created the Node file hello related to the .cpp file hello.cpp. ROS Simple Program: Hello World!

14 To build your package we have to return to the root directory of our workspace:
> cd /home/student/catkin_ws or > cd ~/catkin_ws Build and create executable for all packages: > catkin_make If all is ok, it will create other 2 directories called build and devel: Now you update your environment: > source devel/setup.bash NB: catkin is the ROS build system to generate exec, libraries, and interfaces. Catkin

15 > rosrun helloworld hello Command Package Executable Node
When all of those build steps are complete, your new ROS program is ready to execute using rosrun just like any other ROS program. Open a terminal and launch the roscore command Open a second terminal and launch our example, the command is: > rosrun helloworld hello Command Package Executable Node If the package is not visible, try to restart the shell or run the command: > rospack find helloworld or rospack profile find helloworld If all is ok, it will produce as result: Executing Hello World!

16 helloworld tree

17 A Gentle Introduction to ROS (Jason M. O’Kane) Wiki ROS Tutorials
Wiki ROS Tutorials  Slides course (Roi Yehoshua) References


Download ppt "Robotic Perception and Action"

Similar presentations


Ads by Google