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

Catkin workspaces, packages “built from scratch”, builds vs source-files, interoperability in builds.

asked 2017-01-12 15:00:51 -0500

TBnor gravatar image

Hello,

I picked up ROS around Christmas, and I’m struggling with some core concepts here. I’ve read all tutorials, multiple times, so please don’t just reference me to one of those…

When I follow a tutorial I will most likely end up with ng a workspace, add a package or even “create one”*; before making the catkin workspace.

Now I can roscore, rosrun and listnodes at my heart’s desire. Everything work’s and I’m having a good time. Then, I see I can extend on the previous, and in a matter of minutes I am no longer having a good time.

Now I am making new workspaces, adding packages, deleting packages, by hand and by commandline, really messing everything up big time.

I’ve attempted to define the core of my problems (Please forgive my noobishness, I’ve barely used cmake before and I wrote my first code in 2015) :

When first initializing and making some package or set of packages: 1) What is the correct way of adding/removing packages from a workspace? 2) Should always dependencies be listed to create a package (catkin_create_pkg package_name_pkg rospy rviz etc); before adding the “src” content of the package? 3) Is there any real catch (for a newb) to overlay the workspace with echo ~/source --- bashrc ?

When the initial workspace is up and running: 1) Can I just add, i.e a launch file, without doing anything more/building something?
2) If I did something wrong, maybe write xviz instead of rviz, how can I fix this? Do I have to re-initialize the whole package?

When I want to extend the made workspace with an additional package (my main issue): 1) When downloading a package from the web, do you always have to make it with catkin before it can be used? 1.1)If not, how can I tell if I can just use the script after placing it in the folder, versus when I have to remake/update something? 2) Is there a difference between how packages work? Like; could I download the built package at one site, while another site provided me with the source-files that had to be built?

In general, is it recommended to add more new packages, or to edit the one(s) one already has in place? (Not talking large-scale teamwork, but for i.e one dedicated and experienced individual creating something).

Bonus Q: 1)) When multiple device are supposed to interact – they would all need the same catkin workspace? Would every device compile it’s own in full?

Sorry I have a hard time to really express what I am struggling with. I would deeply appreciate any kind of general (basic) discussion around all related topics, so please don’t try to be short 

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2017-01-13 13:07:02 -0500

Hi! Right I'll see what I can do, there's a lot of questions. But I do remember feeling exactly the same as yourself when I started working with ROS a couple of years ago, it can take a while to realise where everything should be and how bits of a project can be split up!

As you've noticed the built in ROS nodes which are already built live under /opt/ros/<ros_version>/bin this path is already setup so you can call these commands from anywhere.

When it comes to adding or removing packages as you've seen you can use catkin_create_pkg and define dependencies here. If you need to add or remove dependencies as you're developing a package you'll need to edit the package's CMakeLists.txt and package.xml files. These can look fairly daunting at first, but don't take too long to get used to and there are lots of questions you can search on here to help you along.

When it comes to deleting packages, you can simply remove the package's directory from the <your_workspace>/src/ folder. Assuming none of the other packages in your workspace depend on the deleted package everything should build fine after that.

Launch files are simply XML files that a read and executed by roslaunch they are not build in the same was as a c++ node will be for example. You can create and edit these and execute them using roslaunch without needed to rebuild your workspace.

When it comes to adding other peoples packages to your workspace, I've always had to build them after adding the source into my workspace. However there are a few parts of my ros system that I've used apt-get to download and install automatically, when this is available it's much simply and all the setup is taken care of by the debian package manager. However in these cases I these packages are not part of the workspace they are part of the larger ROS system on your computer. If they have custom message types or services you'll need to add them into a package in your workspace and build them, this will create the header files necessary to use them in your own c++ nodes.

In short most of the packages I've needed to download and work with I've added to my workspace in a directory such as <my_workspace>/src/<new_downloaded_package> then as long as you have all the dependencies of that new package installed it should build fine the next time you run catkin_make.

When it comes to creating new packages or editing existing ones, it's really down to how you design your system. The concept of a package is that it should be a set of nodes and functionality that stands by itself. For example where I work several different people perform different experiments and work on the same robot, so we've got one package that deals ... (more)

edit flag offensive delete link more

Comments

Thanks, this was spot on :)

See you around, I guess.

TB

TBnor gravatar image TBnor  ( 2017-01-14 23:45:07 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2017-01-12 14:56:51 -0500

Seen: 602 times

Last updated: Jan 13 '17