ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Basic understanding of how ROS works

asked 2014-08-25 09:06:33 -0500

Metalzero2 gravatar image

Hello all.

I just did all the basic tutorials. I am still trying to understand a basic concept of ROS:

1)What exactly is the relation of nodes and packages?

2) I want to create a program and I want to use some of the packages that ROS has, do I need to make a package or can I make a node with out a packages so I can run the code correctly? For starters I want to be able to use OpenCV + PCL + Kinect + OpenNI, later I want to use even more packages for other nodes. But I can't understand if I need to make a package or only a node.

3) I was also was trying to import the tutorial package (beginner_tutorials) to an IDE (Qt Creator) but I don't know if I need to build the program before I try to inport it. Also do I add the CMakeList under src or the one in the package?

I am using the catkin way on Ubuntu 14.04 with ROS indigo. I am (as you can see) really noob/new so please give if possible any details.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
4

answered 2014-08-25 09:41:53 -0500

updated 2014-08-25 09:43:30 -0500

All nodes must exist within a package. A node is basically just an executable that when called with rosrun or through roslaunch will begin running. A package is typically a collection of things like nodes, configuration files, launch files, etc.

So if you want to write a node that uses OpenCV, PCL, etc., you should create a package that properly lists those packages/libraries your node depends on in the package.xml file. The CMakeLists.txt file in your package tells catkin_make how to build all of the messages, services, nodes, etc. that belong to the package.

I recommend working through the beginner level tutorials on the ROS tutorial page. They should give you a much better feeling of how the pieces of ROS fit together. Also note that none of these tutorials require an IDE. Once you get through them, then maybe worry about getting packages incorporated into Qt Creator.

edit flag offensive delete link more

Comments

Thanks for your help. I did the tutorial a second time and that helped. The thing is that in the tutorial it never says really clearly what you told me and I was not sure.

As for the IDE, if I want to change my code all I need is to just build the package again so the new executable are created?

Metalzero2 gravatar image Metalzero2  ( 2014-08-26 10:52:14 -0500 )edit
4

answered 2014-08-25 09:55:27 -0500

1) A package is the tool used in ROS to organize the code in your workspace. It can contain several .cpp header files launchfiles, etc. On the other hand, the node is just a program you can execute. Because of that, you can create a package which contain any number of nodes. Typically, the nodes of a package are related among them or share code files.

2) You have to make a package and inside the package yo save your code. Later, when making a CMakeLists.txt you can specify which files to include when making your nodes. So imagine that a node is a program running in ROS system whereas the package is the container of the files needed to build a node (or more) in your PC.

3) You can add the package to Qt before building it. It can be built from Qt also. The CMakeLists.txt you have to add is the one that is inside the package. Be careful and follow the rules of Qt IDE to be able to build the package correctly:

3.1) To open a ROS package code as a project, use "Open File or Project" and select the CMakeLists.txt of your ROS package. Take care to select the "[package_name]/build" directory as the build directory, which is the ROS default. On the next screen click 'Run Cmake' and then Finish. This may not show all the folders such as launch and include in the project tree. If you want to choose the files manually, goto File->New File or Project->Import Project->Import Existing Project and selected to choose all files/folders included in the project.

3.2) You have to change the Exec line in file /usr/share/applications/qt.creator.desktop to look like the next one

[Desktop Entry]
Exec=bash -i -c qtcreator %F
Icon=QtProject-qtcreator
...

If you don't understand something please ask me.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2014-08-25 09:06:33 -0500

Seen: 1,582 times

Last updated: Aug 25 '14