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

Local package path is not prioritized over installed package path

asked 2019-01-08 02:05:18 -0500

vandanamandlik gravatar image

updated 2019-01-08 07:31:28 -0500

jayess gravatar image

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 ?

edit retag flag offensive close merge delete

Comments

Rufus gravatar image Rufus  ( 2021-04-08 07:59:52 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2019-01-08 03:59:01 -0500

Reamees gravatar image

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.

edit flag offensive delete link more

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?

vandanamandlik gravatar image vandanamandlik  ( 2019-01-09 04:17:18 -0500 )edit

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.

Reamees gravatar image Reamees  ( 2019-01-09 04:31:40 -0500 )edit
0

answered 2019-09-10 20:16:40 -0500

ALTinners gravatar image

updated 2019-09-10 20:19:42 -0500

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.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-01-08 02:05:18 -0500

Seen: 880 times

Last updated: Sep 10 '19