Robotics StackExchange | Archived questions

Local package path is not prioritized over installed package path

I have build one package locally in separate workspace and using that package path (install/setup.bash) to build my package. But when I try to build my package it doesn't take locally build package path but it takes path of installed package because same package is there in crystal setup.

Does any one know how to solve this issue ?


Update

cd my_package_ws
source /opt/ros/crystal/setup.bash
source /opt/ros/locally_build_package/install/setup.bash
colcon build

As you said package used is depends on the order in which they appear in your environment variable. In my build steps, environment variable "/opt/ros/crystal/setup.bash" path appears first so colcon build finds package from installed packages.

Do you know how can I forcefully tell 'colcon build' to avoid using installed path ?

Asked by vandanamandlik on 2019-01-08 03:05:18 UTC

Comments

Answers

In Kinetic, which package is used depends on the order in which they appear in your environment variable ROS_PACKAGE_PATH=. Which ever package is found first will be used. You can check the variable with printenv | grep ROS. If your built workspace does not appear in the ROS_PACKAGE_PATH try sourcing your workspace again and launching it. Sourcing by default with kinetic would be something like source ~/catkin_ws/devel/setup.bash.

Asked by Reamees on 2019-01-08 04:59:01 UTC

Comments

I also tried by giving locally_build_package path first and then /opt/ros/crystal/setup.bash path but still env command shows crystal path first and "colcon build" gives priority to installed package. Do you know how can I forcefully tell "colcon build" to use locally build package?

Asked by vandanamandlik on 2019-01-09 05:17:18 UTC

Well one thing you could try is to manually set the variable so your built package would appear first. export ROS_PACKAGE_PATH=/path_to/your_ws/your_package:${ROS_PACKAGE_PATH} should work I guess. If this works you can add it to .bashrc although this is deffinately not how to properly solve this.

Asked by Reamees on 2019-01-09 05:31:40 UTC

From what I've found on my machines - this actually needs more definition than what it appears to. ROS_PACKAGE_PATH is not the only factor in play.

When a package is installed and ends up in /opt/ros/{distro}/include it becomes available for includeing via the CMake directive include_directories( ${catkin_INCLUDE_DIRS})

Say you've installed ros-{distro}-excellent-package but also have excellent_package in your workspace. You will need:

  • ROS_PACKAGE_PATH defined with your workspace appearing first (ie: /home/altinners/workspace_ws/src:/opt/ros/{distro}/share)
  • Your include_directories directives set up so that your local packages appear first ie: include_directories( include ${excellent_package_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS} ) - this prioritises the local include files over the system installed ones

This is not really necessary if you don't ever need to reference header files - but in most cases where I think anyone would need to have local packages outside of the main /opt folder you'd want to reference the headers.

Asked by ALTinners on 2019-09-10 20:16:40 UTC

Comments