Sie sind auf Seite 1von 9

Departamento de Ingeniería

de Sistemas y Automática

Workspace
Robotic Operating System (ROS)
CATKIN
Official build system of ROS based on Cmake and
Python scripts. It creates a workspace in which a
number of packages can be built.

It is in charge of generating executables from source


code, manage dependences, organize and make
packages accessible.
Departamento de Ingeniería
de Sistemas y Automática

Grado en Ingeniería Electrónica, Robótica y Mecatrónica


Robótica y Automatización 2
Create CATKIN workspace
$ mkdir –p ~/catkin_ws/src Create the /src directory
$ cd ~/catkin_ws/src
$ catkin_init_workspace Initialize it and creates a CMakeLists file

$ cd ~/catkin_ws
Build it. Result: a workspace empty and ready to
$ catkin_make
work with.
$ ls
Departamento de Ingeniería
de Sistemas y Automática

$ echo "source ~/catkin_ws/devel/setup.bash" >>


~/.bashrc
$ source ~/.bashrc Add system variables to bashrc

Grado en Ingeniería Electrónica, Robótica y Mecatrónica


Robótica y Automatización 3
CATKIN workspace structure
[viki@notrix ../source/ros/catkin_ws]$ tree -L 3
.
├── build
│   ···
├── devel
│   ···
└──src
   ├── package 1
   │   ├── include
   │   ├── src
   │   ├── ···
   │   ├── CMakeLists.txt
   │   └── package.xml
Departamento de Ingeniería

   ├── package 2
de Sistemas y Automática

   │   ├── include


   │   ├── src
   │   ├── ···
   │   ├── CATKIN_IGNORE
   │   └── README.md
   ├── ···
   └── package n
      ├── include
      ├── src
      ├── ···
      ├── CMakeLists.txt
      └── package.xml
4
Creating a new package

catkin_create_pkg command
$ catkin_create_pkg <package_name> [depend 1] … [depend n]

Example of creating a package called test with


standard dependencies:
$ cd ~/catkin_ws/src
Departamento de Ingeniería

$ catkin_create_pkg test std_msgs roscpp


de Sistemas y Automática

Grado en Ingeniería Electrónica, Robótica y Mecatrónica


Robótica y Automatización 5
Building (compiling) package
$ cd ~/catkin_ws Actually we build all the
$ catkin_make packages included in the
workspace
Departamento de Ingeniería
de Sistemas y Automática

The package is
ready but
empty!!

Grado en Ingeniería Electrónica, Robótica y Mecatrónica


Robótica y Automatización 6
Implementing a ROS node
Let’s implement our first node in C++.

Modify the CMakeList.txt at /src/test/ to


include a reference to a .cpp file we are going to
implement. This tells the ROS system we want to
have a new executable.

At the end of CMakeList.txt add the following:


Departamento de Ingeniería
de Sistemas y Automática

Grado en Ingeniería Electrónica, Robótica y Mecatrónica


Robótica y Automatización 7
Implementing a ROS node

And rebuild the package:


$ cd ~/catkin_ws
$ catkin_make
Departamento de Ingeniería
de Sistemas y Automática

You will get an error since


the file direction.cpp is
not created yet!

Grado en Ingeniería Electrónica, Robótica y Mecatrónica


Robótica y Automatización 8
Departamento de Ingeniería
de Sistemas y Automática

Workspace
Robotic Operating System (ROS)

Das könnte Ihnen auch gefallen