Skip to content

Commit

Permalink
Noetic release (#323)
Browse files Browse the repository at this point in the history
* Python3 and Opencv4 changes - noetic

Signed-off-by: ahcorde <[email protected]>

* image_geometry cmake_minimum_required to 3.0.2

Signed-off-by: ahcorde <[email protected]>

* vision_opencv cmake_minimum_required to 3.0.2

Signed-off-by: ahcorde <[email protected]>

* opencv_test cmake_minimum_required to 3.0.2, fixed launch file and python3 issues

Signed-off-by: ahcorde <[email protected]>

* Removed static_casst

Signed-off-by: ahcorde <[email protected]>

* import setup from setuptools instead of distutils-core

Signed-off-by: ahcorde <[email protected]>

* Updated travis.yml and travis.sh

Signed-off-by: ahcorde <[email protected]>

* do_numpy_import change signature to void * and returns nullptr

Signed-off-by: ahcorde <[email protected]>

* Updated keys

Signed-off-by: ahcorde <[email protected]>

* updated python3-numpy key

Signed-off-by: ahcorde <[email protected]>
  • Loading branch information
ahcorde authored and mjcarroll committed Apr 6, 2020
1 parent 578af4d commit 9acfe21
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 312 deletions.
4 changes: 2 additions & 2 deletions .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ travis_time_start setup.before_install
#before_install:
# Define some config vars.
# Install ROS
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo sh -c 'echo "deb http://repositories.ros.org/ubuntu/testing $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
sudo apt-get update -qq || echo Ignore error on apt-get update
# Install ROS
sudo apt-get install -qq -y python-catkin-pkg python-catkin-tools python-rosdep python-wstool ros-$ROS_DISTRO-catkin
sudo apt-get install -qq -y python3-catkin-pkg python3-catkin-tools python3-rosdep python3-wstool ros-$ROS_DISTRO-catkin
source /opt/ros/$ROS_DISTRO/setup.bash
# Setup for rosdep
sudo rosdep init
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sudo: required
dist: trusty
language: generic
env:
- ROS_DISTRO=melodic
- ROS_DISTRO=noetic
# Install system dependencies, namely ROS.
before_install:
# Define some config vars.
Expand All @@ -11,7 +11,7 @@ before_install:
- export ROS_PARALLEL_JOBS='-j8 -l6'
script:
- echo "Testing branch $TRAVIS_BRANCH of $REPOSITORY_NAME"
- docker run --rm -i -v $CI_SOURCE_PATH:$CI_SOURCE_PATH -e "CI_SOURCE_PATH=$CI_SOURCE_PATH" -e "HOME=$HOME" -e "ROS_DISTRO=$ROS_DISTRO" -e "ROS_PARALLEL_JOBS=$ROS_PARALLEL_JOBS" -t ubuntu:bionic sh -c "cd $CI_SOURCE_PATH; ./.travis.sh"
- docker run --rm -i -v $CI_SOURCE_PATH:$CI_SOURCE_PATH -e "CI_SOURCE_PATH=$CI_SOURCE_PATH" -e "HOME=$HOME" -e "ROS_DISTRO=$ROS_DISTRO" -e "ROS_PARALLEL_JOBS=$ROS_PARALLEL_JOBS" -t ubuntu:focal sh -c "cd $CI_SOURCE_PATH; ./.travis.sh"
after_failure:
- find ${HOME}/.ros/test_results -type f -exec echo "== {} ==" \; -exec cat {} \;
- for file in ${HOME}/.ros/log/rostest-*; do echo "=== $file ==="; cat $file; done
10 changes: 3 additions & 7 deletions cv_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.0.2)
project(cv_bridge)

find_package(catkin REQUIRED COMPONENTS rosconsole sensor_msgs)

if(NOT ANDROID)
find_package(PythonLibs)
if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3)
find_package(Boost REQUIRED python)
else()
find_package(Boost REQUIRED python3)
endif()
find_package(Boost REQUIRED python)
else()
find_package(Boost REQUIRED)
endif()
find_package(OpenCV 3 REQUIRED
find_package(OpenCV 4 REQUIRED
COMPONENTS
opencv_core
opencv_imgproc
Expand Down
10 changes: 5 additions & 5 deletions cv_bridge/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@

<build_depend>boost</build_depend>
<build_depend>libopencv-dev</build_depend>
<build_depend>python</build_depend>
<build_depend>python-opencv</build_depend>
<build_depend>python3</build_depend>
<build_depend>python3-opencv</build_depend>
<build_depend>rosconsole</build_depend>
<build_depend>sensor_msgs</build_depend>

<exec_depend>boost</exec_depend>
<exec_depend>libopencv-dev</exec_depend>
<exec_depend>python</exec_depend>
<exec_depend>python-opencv</exec_depend>
<exec_depend>python3</exec_depend>
<exec_depend>python3-opencv</exec_depend>
<exec_depend>rosconsole</exec_depend>
<build_export_depend>libopencv-dev</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>

<test_depend>rostest</test_depend>
<test_depend>python-numpy</test_depend>
<test_depend>python3-numpy</test_depend>

<doc_depend>dvipng</doc_depend>
</package>
8 changes: 6 additions & 2 deletions cv_bridge/python/cv_bridge/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,12 @@ def imgmsg_to_cv2(self, img_msg, desired_encoding = "passthrough"):
im = np.ndarray(shape=(img_msg.height, img_msg.width),
dtype=dtype, buffer=img_msg.data)
else:
im = np.ndarray(shape=(img_msg.height, img_msg.width, n_channels),
dtype=dtype, buffer=img_msg.data)
if(type(img_msg.data) == str):
im = np.ndarray(shape=(img_msg.height, img_msg.width, n_channels),
dtype=dtype, buffer=img_msg.data.encode())
else:
im = np.ndarray(shape=(img_msg.height, img_msg.width, n_channels),
dtype=dtype, buffer=img_msg.data)
# If the byt order is different between the message and the system.
if img_msg.is_bigendian == (sys.byteorder == 'little'):
im = im.byteswap().newbyteorder()
Expand Down
2 changes: 1 addition & 1 deletion cv_bridge/setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from distutils.core import setup
from setuptools import setup
from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup()
Expand Down
6 changes: 1 addition & 5 deletions cv_bridge/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ if (PYTHON_VERSION_MAJOR VERSION_EQUAL 3)
add_definitions(-DPYTHON3)
endif()

if (OpenCV_VERSION_MAJOR VERSION_EQUAL 3)
add_library(${PROJECT_NAME}_boost module.cpp module_opencv3.cpp)
else()
add_library(${PROJECT_NAME}_boost module.cpp module_opencv2.cpp)
endif()
add_library(${PROJECT_NAME}_boost module.cpp module_opencv4.cpp)
target_link_libraries(${PROJECT_NAME}_boost ${Boost_LIBRARIES}
${catkin_LIBRARIES}
${PYTHON_LIBRARIES}
Expand Down
10 changes: 2 additions & 8 deletions cv_bridge/src/module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,10 @@ int convert_to_CvMat2(const PyObject* o, cv::Mat& m);

PyObject* pyopencv_from(const cv::Mat& m);

#if PYTHON3
static int do_numpy_import( )
static void * do_numpy_import( )
{
import_array( );
return nullptr;

This comment has been minimized.

Copy link
@soeroesg

soeroesg Dec 8, 2020

this broke compatibility with Ubuntu 18.04/Python2

This comment has been minimized.

This comment has been minimized.

Copy link
@lepalom

lepalom Dec 8, 2020

see migration guide of Noetic. Specially:

ROS Noetic will target Python 3 exclusively. See this guide for instructions transitioning your ROS packages from Python 2 to Python 3.

}
#else
static void do_numpy_import( )
{
import_array( );
}
#endif

#endif
262 changes: 0 additions & 262 deletions cv_bridge/src/module_opencv2.cpp

This file was deleted.

Loading

0 comments on commit 9acfe21

Please sign in to comment.