ros tutorial 2 · 3 ece5463 (sp18) rqt_graph •rqt_graph is a useful tool that provides a gui...

19
ECE 5463 Introduction to Robotics Spring 2018 ROS TUTORIAL 2 Guillermo Castillo (Wei Zhang) Department of Electrical and Computer Engineering Ohio State University 02/2018

Upload: others

Post on 30-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

ECE 5463 Introduction to RoboticsSpring 2018

ROS

TUTORIAL 2

Guillermo Castillo (Wei Zhang)

Department of Electrical and Computer Engineering

Ohio State University

02/2018

Page 2: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

2

ECE5463 (Sp18)

Tutorial 2 Outline• ROS Graph

• ROS Services and Parameters

• Turtlesim – service application (spawn a new turtle)

• Installing ROS Packages

• Using apt manager

• Cloning from repository

• Gazebo

• Introduction - Installation

• Testing – Kinematic and Dynamic Simulation

• Understanding Gazebo – ROS Filesystem

• URDF – XACRO files

Outline

Page 3: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

3

ECE5463 (Sp18)

rqt_graph

• rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS

computation graph. Namely, it creates a dynamic graph of what's going on

in the system (i.e. the ROS nodes that are currently running, as well as the

ROS topics that connect them)

• Its components are made generic so that other packages where you want to

achieve graph representation can depend upon it.

• Command:

rqt_graph

rosrun rqt_graph rqt_graph

Page 4: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

4

ECE5463 (Sp18)

rqt_graph – example

Turtlesim simulation

rqt_graph

$ roscore

$ rosrun turtlesim turtlesim_node

$ rosrun rqt_graph rqt_graph

$ rosrun turtlesim turtle_teleop_key

Page 5: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

5

ECE5463 (Sp18)

rqt_graph – example

Turtlesim application

rqt_graph Steps

$ rosrun turtlesim turtlesim_node __name:=A

$ rosrun turtlesim turtlesim_node __name:=B

$ rosrun turtlesim turtle_teleop_key __name:=C

$ rosrun turtlesim turtle_teleop_key __name:=D

Page 6: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

6

ECE5463 (Sp18)

Services

•ROS supports the concept of "remote procedure call" (in contrast to

local function call), in the form of ROS services. With ROS services,

calling a function in another node is as easy as calling local functions.

• One time actions. Use services when your program can't continue

until it receives the result from the service.

Services and Parameters

rosservice list print information about active services

rosservice call call the service with the provided args

rosservice type print service type

$ rosservice list

$ rosservice type [service] | rossrv show

$ rosservice [service] [args]

Page 7: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

7

ECE5463 (Sp18)

Parameters

• rosparam allows you to store and manipulate data on the ROS

Parameter Server. The Parameter Server can store integers, floats,

boolean, dictionaries, and lists.

Services and Parameters

rosparam list list parameter names

rosparam set set parameter

rosparam get get parameter

rosparam delete delete parameter

$ rosparam list

$ rosparam set [param_name]

$ rosparam get [param_name]

Page 8: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

8

ECE5463 (Sp18)

Application on Turtlesim

Spawn a new turtle:

Services and Parameters

$ rosservice list

$ rosservice type /spawn | rossrv show

$ rosservice call /spawn 2 7 0.2 "turtle_tutorial"

Page 9: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

9

ECE5463 (Sp18)

Recall: What is a package?

• All the files that a specific ROS program contains; all its cpp files, python

files, configuration files, compilation files, launch files, and parameters files.

• Generally all those files in the package are organized with the following

structure:

launch folder: Contains launch files

src folder: Source files (cpp, python)

CMakeLists.txt: List of cmake rules for compilation

package.xml: Package information and dependencies

ROS Packages

Not always

Page 10: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

10

ECE5463 (Sp18) ROS Packages

Installing ROS package

Using Ubuntu s package manager

• The apt-get command is a powerful command-line tool, which works with

Ubuntu's Advanced Packaging Tool (APT) performing such functions as

downloading and installation of new software packages, updating, etc.

• This method is used for installing released ROS packages (packages verified

by ROS developers) and install the package’s necessary dependencies.

• Command:

•Example

sudo apt-get install ros-<ros_distro>-<package-name>

sudo apt-get install ros-kinetic-urdf

Page 11: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

11

ECE5463 (Sp18) ROS Packages

Installing ROS package

Installing from source code

• If the package is not released, you will need to install it from source code. Find

out where the code is hosted (mostly github), and install the package in the

src folder from your workspace directory (~/catkin_ws/src)

https://github.com/ros/urdf, https://github.com/ROBOTIS-GIT/turtlebot3

• Command:

• Example:

$ cd ~/catkin_ws/src

$ git clone -b kinetic-devel https://github.com/ros/urdf.git

$ git clone https://github.com/ROBOTIS-GIT/turtlebot3

$ cd ~/catkin_ws

$ catkin_make

git clone <address> / git clone -b <branch> <address>

Page 12: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

12

ECE5463 (Sp18) ROS Packages

Installing ROS package

Installing from source code

• Problem: You have to take care of the dependencies by yourself.

• Whenever you see "Could not find a configuration file for package

<package_name>" it means this package is missing and is needed for

compiling your code.

• Possible solution: Use rosdep command, which will automatically try to find

all the dependencies of your package and install them.

IMPORTANT NOTE

•Sometimes the <package-name> or <address> arguments correspond to

a directory which contains more than one package.

Page 13: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

13

ECE5463 (Sp18)

Gazebo simulator

• Goal: Best possible substitute for physical robot

• Architecture

• Advantages

• Design and testing of robot’s components and control

• Software testing and verification (controllers)

• Save time and money

• Installation : Built-in along with the ROS desktop-full.

Gazebo

Page 14: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

14

ECE5463 (Sp18)

Testing Gazebo

• Gazebo runs two executables: Gazebo server (simulation process)

and Gazebo client (Gazebo GUI)

• Add a square block and a sphere using the upper tool bar

• Right click on the sphere

• Select Apply Force/Torque

• Choose a value for the torque and force and select apply.

• Observe kinematics and dynamics simulation

Gazebo

gazebo

Page 15: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

15

ECE5463 (Sp18) Gazebo

Understanding ROS-Gazebo Filesystem

Robot modelling

.urdf, .xacro,

.gazebo files

Controllers

.yaml files

Simulation

Environment

.world files

Notice that each one of this folders is a different package and

usually they are located inside the robot’s name folder. Packages’

names are recommended but not mandatory.

Page 16: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

16

ECE5463 (Sp18)

World

Gazebo

Page 17: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

17

ECE5463 (Sp18)

URDF - XACRO files (XML)The Universal Robotic Description Format (URDF) is an XML file format

used in ROS to describe all elements of a robot.

To use a URDF file in Gazebo, some additional simulation-specific tags

must be added to work properly with Gazebo.

URDF

• Specify the kinematic and dynamic properties

• Tags: link, joint, transmission

• Order in the file does not matter

XACRO

• XML Macro Language used for URDF simplification

• Reduce redundancy and increase modularity

• Use parametrization (Use parameters for lengths and links and math

for origin and inertia calculation)

Gazebo

Page 18: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

18

ECE5463 (Sp18)

Link and joint representation

Gazebo

Page 19: ROS TUTORIAL 2 · 3 ECE5463 (Sp18) rqt_graph •rqt_graph is a useful tool that provides a GUI plugin for visualizing the ROS computation graph. Namely, it creates a dynamic graph

19

ECE5463 (Sp18)

Thanks for your

attention