Robotics StackExchange | Archived questions

Kinetic enforces openCV3 throughout the system

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

Asked by Georacer on 2016-08-26 07:13:25 UTC

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.

Asked by daniel_dsouza on 2016-08-26 12:00:38 UTC

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

Asked by daniel_dsouza on 2016-08-26 12:02:00 UTC

@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)

Asked by Georacer on 2016-08-26 14:33:24 UTC

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

Asked by daniel_dsouza on 2016-08-30 10:21:02 UTC

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.

Asked by gvdhoorn on 2016-09-02 02:30:41 UTC

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?

Asked by Georacer on 2016-09-02 02:52:32 UTC

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.

Asked by gvdhoorn on 2016-09-02 03:09:49 UTC

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.

Asked by gvdhoorn on 2016-09-02 03:18:25 UTC

ROS should be installed in standard locations (ie: not under /opt)

That would actually only work if OpenCV2 and OpenCV3 could be installed side-by-side in the same environment (so not using virtualenv or similar tricks).

Asked by gvdhoorn on 2016-09-02 03:20:03 UTC

Fair enough. Thanks for your input!

Asked by Georacer on 2016-09-02 03:27:04 UTC

Answers