Kinetic enforces openCV3 throughout the system

asked 2016-08-26 07:13:25 -0600

Georacer gravatar image

Hello everyone,

I just installed ROS Kinetic on an Ubuntu 16.04 and I ran onto this problem.

Usually, I add

source /opt/ros/kinetic/setup.bash
source ~/catkin_ws/devel/setup.bash

onto my .bashrc file to have access to all ROS related commands on each new console.

However, today, I tried to launch a completely unrelated software (the MAVProxy GCS along with the ardupilot simulator) which kept crashing.

The reason was that setup.bash enforced the PYTHONPATH to look at the OpenCV3.1.0 installation, provided by Kinetic, but MAVProxy was using the (otherwise installed) OpenCV 2.4.9. It goes without saying, there isn't backwards compatibility.

Even though I managed to run MAVProxy properly by commenting out setup.bash from by .bashrc, so that OpenCV 2.4.9 takes over, I don't think this is proper behaviour.

Any thoughts or workarounds?

Thanks, George

edit retag flag offensive close merge delete

Comments

I am having a similar problem with catkin refusing to use my CUDA enabled version of OpenCV. Seeing as my CMakeLists.txt file compiles code fine without catkin_make, but uses the bundled ROS OpenCV with catkin_make, I assume that catkin is using a variable somewhere.

daniel_dsouza gravatar image daniel_dsouza  ( 2016-08-26 12:00:38 -0600 )edit

One workaround I am thinking of is writing my own CMake file to find open CV, and using that in my CMakesLists.txt

daniel_dsouza gravatar image daniel_dsouza  ( 2016-08-26 12:02:00 -0600 )edit

@daniel_dsouza Perhaps you could tell catkin which version you need, as is described here:http://wiki.ros.org/opencv3, with find_package(OpenCV 2)

Georacer gravatar image Georacer  ( 2016-08-26 14:33:24 -0600 )edit

The problem is that my code uses OpenCV 3.1.0, which same version bundled by ROS.

daniel_dsouza gravatar image daniel_dsouza  ( 2016-08-30 10:21:02 -0600 )edit

A bit pedantic maybe, but enforces is not correct: you chose to add the two source lines to your .bashrc, so all bash environments are updated so you can work with ROS. setup.bash only did what you asked, but by adding it to your .bashrc, it will do that in all your bash sessions.

gvdhoorn gravatar image gvdhoorn  ( 2016-09-02 02:30:41 -0600 )edit

Technically, this is correct. But I believe anyone who works with ROS regularly sources the setup.bash on their .bashrc. Having that script override the system's OpenCV version seems forcing. Is this even required to rosrun ROS Python scripts using OpenCV3?

Georacer gravatar image Georacer  ( 2016-09-02 02:52:32 -0600 )edit
1

I'd say I work regularly with ROS, and I don't have that line in my .bashrc. In fact, I'd say that anyone who has more than a single workspace will not have those lines.

As to whether it is required: yes. ROS python libs are not in standard locations, so PYTHONPATH needs to be updated.

gvdhoorn gravatar image gvdhoorn  ( 2016-09-02 03:09:49 -0600 )edit

Afaict, there are three possible 'solutions': ROS should be installed in standard locations (ie: not under /opt), OpenCV should not use the cv2 module name for OpenCV3 (avoid clash), or you need to make sure your PYTHONPATH does not contain the 'wrong' entries.

gvdhoorn gravatar image gvdhoorn  ( 2016-09-02 03:18:25 -0600 )edit