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

Issue with changing the precedence order of ROS_PACKAGE_PATH

asked 2023-07-27 14:17:09 -0500

gts_63 gravatar image

updated 2023-07-27 14:34:27 -0500

My system: Ubuntu 20.04, ROS noetic.

My issue: I'm working with two packages that have ros1 packages with the same name ORB_SLAM3 which causes an issue with ROS_PACKAGE_PATH and thus with ROS finding the appropriate package to run. The packages I have installed are:

  1. https://github.com/VIS4ROB-lab/covins. This package uses ORB-SLAM3 as a frontend and can also run on ROS1. Per the instructions on the page, I have this project installed in ~/ws/covins_ws. Per the instructions on the section for ROS, I have sourced the file ~/ws/covins_ws/devel/setup.bash.
  2. The ORB_SLAM3 package https://github.com/UZ-SLAMLab/ORB_SLAM3, which originally is not a ROS package but offers an option to run on ROS as per section 7.

Where I run into an issue is when trying to build the ROS package for the second package above, specifically at the step ./build_ros.sh with the following error message:

[rosbuild] Building package ORB_SLAM3
[rosbuild] Error from directory check: /opt/ros/noetic/share/ros/core/rosbuild/bin/check_same_directories.py /home/glenn/ws/covins_ws/src/covins/orb_slam3/Examples/ROS/ORB_SLAM3 /home/glenn/ORB_SLAM3/Examples_old/ROS/ORB_SLAM3
1
Traceback (most recent call last):
  File "/opt/ros/noetic/share/ros/core/rosbuild/bin/check_same_directories.py", line 48, in <module>
    raise Exception
Exception
CMake Error at /opt/ros/noetic/share/ros/core/rosbuild/private.cmake:99 (message):
  [rosbuild] rospack found package "ORB_SLAM3" at
  "/home/glenn/ws/covins_ws/src/covins/orb_slam3/Examples/ROS/ORB_SLAM3", but
  the current directory is
  "/home/glenn/ORB_SLAM3/Examples_old/ROS/ORB_SLAM3".  You should
  double-check your ROS_PACKAGE_PATH to ensure that packages are found in the
  correct precedence order.
Call Stack (most recent call first):
  /opt/ros/noetic/share/ros/core/rosbuild/public.cmake:177 (_rosbuild_check_package_location)
  CMakeLists.txt:4 (rosbuild_init)

The error, as shown above, is because rospack find ORB_SLAM3 returns /home/glenn/ws/covins_ws/src/covins/orb_slam3/Examples/ROS/ORB_SLAM3 from package 1 above, even though I want it to find package 2.

My attempted solution:

Since I'm not currently using the first package, I choose not to source it (I used to have the line source ~/ws/covins_ws/devel/setup.bash in my .bashrc, but commented it out. ). The two lines I have in bashrc are to source my underlay and overlay (source /opt/ros/noetic/setup.bash, followed by source /home/glenn/catkin_ws/devel/setup.bash). Note, there are no ORB_SLAM3 packages in the catkin_ws folder. Per the instruction from ORB-SLAM3, I also add the specfied path to the ROS_PACKAGE_PATH environment variable with the command export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/glenn/ORB_SLAM3/Examples_old/ROS/ORB_SLAM3 at the end of my bashrc (side note: the github says ORB_SLAM3/Examples, but the path to build ROS is actually in the Examples_old. I also modified the build script build_ros.sh to account for this).

From here, when I type echo $ROS_PACKAGE_PATH, the output is:

/home/glenn/catkin_ws/src:/home/glenn/ws/covins_ws/src/catkin_simple:/home/glenn/ws/covins_ws/src/vision_opencv/cv_bridge:/home/glenn/ws/covins_ws/src/doxygen_catkin:/home/glenn/ws ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-07-29 07:31:43 -0500

Mike Scheutzow gravatar image

updated 2023-07-29 07:44:17 -0500

Your catkin workspace "remembers" the things you previously sourced. Making it "forget" requires these steps, in this order:

  • in your catkin_ws, delete the top-level devel and build directories
  • source /opt/ros/noetic/setup.bash # only this one!
  • run your catkin_make or catkin build command
  • if the build succeeded, source devel/setup.bash

People also call this "doing a clean build".

Note: in general it's unwise to modify your ROS_PACKAGE_PATH env variable in your ~/.bashrc file, but it is especially unwise when the path you are adding is already inside your catkin_ws directory.

edit flag offensive delete link more

Comments

Thank you. I noticed from the ROS wiki that ROS_PACKAGE_PATH doesn't need to be manually updated since catkin was introduced.

gts_63 gravatar image gts_63  ( 2023-07-30 16:30:28 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2023-07-27 14:17:09 -0500

Seen: 104 times

Last updated: Jul 29 '23