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

After building ROS2 from source, how to add packages

asked 2021-09-06 07:31:09 -0500

Koen gravatar image

updated 2021-09-20 01:13:15 -0500

If you build ROS2 from source, how do you add other/new packages? Can you apt-install those or do they need to be built from source as well? If you have to build them from source. Do you add them to your personal workspace or the workspace where you build ROS?

I could find nowhere a clear answer on this.

edit: Clarification it's the core ROS2 that's built from source, not just a couple of packages.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2021-09-20 01:52:13 -0500

gvdhoorn gravatar image

updated 2021-09-21 02:44:29 -0500

Can you apt-install those or do they need to be built from source as well? This also applies if the core ROS2 is built from the source? (because reasons), Can you then still install extra packages with apt?

It's still possible, but I doubt it will make sense.

Any leaf package will depend on packages higher up in the dependency tree. Core packages are almost at the root.

If you've built ROS 2 from sources, you'll not have any of those core packages. apt cannot resolve dependencies by looking at your files (ie: your colcon_ws), it only knows what it has installed itself (by default).

Ergo: if you try to install a leaf(ish) package while having none of the core(ish) packages, apt will start installing everything needed to satisfy dependencies of your lead(ish) package.

This is not ROS 2 specific btw: the same situation exists in ROS 1 (and everywhere else you try to mix .debs with from-source builds).

PS: comparing to what @shonigmann wrote: a from-source built ROS 2 base install cannot function as an underlay for further apt installs (well, technically it's possibly by tricking apt, but I doubt you should do this if you're asking these kinds of questions).

edit flag offensive delete link more
1

answered 2021-09-07 13:37:14 -0500

shonigmann gravatar image

You are free to use whatever mix of source and debian installs you like, as long as you are meeting dependencies and sourcing the packages as appropriate. The caveat being that apt may try to install the debian versions of dependencies that you've already installed through your source build. To my knowledge, the only consequence is using a bit more disk space. You can "overlay" your source build of ROS2 to give it priority, so that your system knows to use the source version of, say, rclcpp instead of the one that was installed through apt.

In your case, deciding whether to use apt (debian) or source installation, you should ask yourself whether you will want to change the packages. If yes, then go with source so you can rebuild when you add modifications. If no, then install the debians directly - this will be faster and lighter weight.

If you do end up installing from source, it is generally advised to create a new workspace for the packages you want to work with that can "overlay" your core ROS2 installation. That way, your install and build directories are isolated and it is faster to rebuild if you happen to break something. You can have multiple over/underlays too, so it can even be worth having separate workspaces for "large" packages that can take a long time to build (e.g. MoveIt2, Nav2).

edit flag offensive delete link more

Comments

Okay, thank you. This also applies if the core ROS2 is built from the source? (because reasons), Can you then still install extra packages with apt?

Koen gravatar image Koen  ( 2021-09-20 01:11:58 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-09-06 07:30:51 -0500

Seen: 625 times

Last updated: Sep 21 '21