From 12ee159aebb854850273fc3a6003aa326ab34feb Mon Sep 17 00:00:00 2001 From: Sean Kelly Date: Fri, 10 Aug 2018 11:49:15 -0400 Subject: [PATCH 1/6] Prevent cpack from including gtest artifacts --- modules/camera/test/CMakeLists.txt | 2 +- modules/framegrabber/test/CMakeLists.txt | 2 +- modules/image/test/CMakeLists.txt | 2 +- modules/oem/test/CMakeLists.txt | 2 +- modules/pcicclient/test/CMakeLists.txt | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/camera/test/CMakeLists.txt b/modules/camera/test/CMakeLists.txt index 4cf369e..3ec9fb8 100644 --- a/modules/camera/test/CMakeLists.txt +++ b/modules/camera/test/CMakeLists.txt @@ -1,6 +1,6 @@ set(GTEST_CMAKE_DIR "/usr/src/gtest") enable_testing() -add_subdirectory(${GTEST_CMAKE_DIR} gtest_bin) +add_subdirectory(${GTEST_CMAKE_DIR} gtest_bin EXCLUDE_FROM_ALL) file(GLOB CAMERA_TEST_SOURCES *.cpp) add_executable(o3d3xx-camera-tests ${CAMERA_TEST_SOURCES}) if(BUILD_SHARED_LIBS) diff --git a/modules/framegrabber/test/CMakeLists.txt b/modules/framegrabber/test/CMakeLists.txt index 74e47db..70ed6d2 100644 --- a/modules/framegrabber/test/CMakeLists.txt +++ b/modules/framegrabber/test/CMakeLists.txt @@ -1,6 +1,6 @@ set(GTEST_CMAKE_DIR "/usr/src/gtest") enable_testing() -add_subdirectory(${GTEST_CMAKE_DIR} gtest_bin) +add_subdirectory(${GTEST_CMAKE_DIR} gtest_bin EXCLUDE_FROM_ALL) file(GLOB FRAMEGRABBER_TEST_SOURCES *.cpp) add_executable(o3d3xx-framegrabber-tests ${FRAMEGRABBER_TEST_SOURCES}) diff --git a/modules/image/test/CMakeLists.txt b/modules/image/test/CMakeLists.txt index ae2f807..67d043b 100644 --- a/modules/image/test/CMakeLists.txt +++ b/modules/image/test/CMakeLists.txt @@ -2,7 +2,7 @@ find_library(LIB_boost_system NAMES boost_system) set(GTEST_CMAKE_DIR "/usr/src/gtest") enable_testing() -add_subdirectory(${GTEST_CMAKE_DIR} gtest_bin) +add_subdirectory(${GTEST_CMAKE_DIR} gtest_bin EXCLUDE_FROM_ALL) file(GLOB IMAGE_TEST_SOURCES *.cpp) add_executable(o3d3xx-image-tests ${IMAGE_TEST_SOURCES}) diff --git a/modules/oem/test/CMakeLists.txt b/modules/oem/test/CMakeLists.txt index 181a8f9..9eea9c6 100644 --- a/modules/oem/test/CMakeLists.txt +++ b/modules/oem/test/CMakeLists.txt @@ -2,7 +2,7 @@ set(GTEST_CMAKE_DIR "${SYSROOT_CONTRIB}/usr/src/gtest") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${SYSROOT_CONTRIB}/usr/include") enable_testing() -add_subdirectory(${GTEST_CMAKE_DIR} gtest_bin) +add_subdirectory(${GTEST_CMAKE_DIR} gtest_bin EXCLUDE_FROM_ALL) file(GLOB TEST_SOURCES *.cpp) add_executable(o3d3xx-oem-tests ${TEST_SOURCES}) target_link_libraries(o3d3xx-oem-tests diff --git a/modules/pcicclient/test/CMakeLists.txt b/modules/pcicclient/test/CMakeLists.txt index 101c0a8..f6e7d2a 100644 --- a/modules/pcicclient/test/CMakeLists.txt +++ b/modules/pcicclient/test/CMakeLists.txt @@ -1,6 +1,6 @@ set(GTEST_CMAKE_DIR "/usr/src/gtest") enable_testing() -add_subdirectory(${GTEST_CMAKE_DIR} gtest_bin) +add_subdirectory(${GTEST_CMAKE_DIR} gtest_bin EXCLUDE_FROM_ALL) file(GLOB PCICCLIENT_TEST_SOURCES *.cpp) add_executable(o3d3xx-pcicclient-tests ${PCICCLIENT_TEST_SOURCES}) From b8f5f789e093afd928005c7d96b2cb537aac078e Mon Sep 17 00:00:00 2001 From: Sean Kelly Date: Fri, 10 Aug 2018 12:19:03 -0400 Subject: [PATCH 2/6] Fixing packaging to allow newer versions of PCL --- modules/image/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/image/CMakeLists.txt b/modules/image/CMakeLists.txt index d02f754..aeb0fa4 100644 --- a/modules/image/CMakeLists.txt +++ b/modules/image/CMakeLists.txt @@ -240,7 +240,7 @@ if(BUILD_EXE_VIEWER) set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libvtk6-dev, - libpcl1.7, + libpcl-dev, libopencv-highgui-dev, libopencv-contrib-dev") else() From ac6ca0988e910034ab7a8dcd251d3e5ec48844ed Mon Sep 17 00:00:00 2001 From: Sean Kelly Date: Fri, 10 Aug 2018 12:24:26 -0400 Subject: [PATCH 3/6] Meta-info for 0.7.7 release --- ChangeLog.md | 4 ++++ README.md | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index dda445f..e776de3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,7 @@ +## Changes between libo3d3xx 0.7.6 and 0.7.7 + +* Updated cmake/packaging scripts to support the Ubuntu 18.04 toolchain + ## Changes between libo3d3xx 0.7.5 and 0.7.6 * Makes unit tests pass for the 1.23.1522 firmware (json dumps still do not diff --git a/README.md b/README.md index c033a4e..0bbdd14 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,12 @@ Software Compatibility Matrix O3D303 Ethernet/IP assembly size configuration and PCIC schema auto update + + 0.7.7 + 1.23.1522 + O3D303 + Support for building with Ubuntu 18.04 toolchain + Features @@ -257,6 +263,7 @@ validated: * g++ 4.8.x on Ubuntu Linux 14.04 LTS * g++ 5.3.x on Ubuntu Linux 16.04 LTS +* g++ 7.3.x on Ubuntu Linux 18.04 LTS Installation (from source) -------------------------- From 7b1beb8678566a11387cd2f6c181798c0cfc4eb4 Mon Sep 17 00:00:00 2001 From: Sean Kelly Date: Wed, 17 Jul 2019 15:29:44 -0400 Subject: [PATCH 4/6] Updated for cross-compiling on 18.04 and O3D3XX FW 1.25.4073 --- ChangeLog.md | 3 +++ README.md | 2 +- cmake/modules/o3d3xx_version.cmake | 2 +- modules/camera/CMakeLists.txt | 4 +++- modules/camera/test/o3d3xx-camera-tests.cpp | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index e776de3..5cbc727 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,9 @@ ## Changes between libo3d3xx 0.7.6 and 0.7.7 * Updated cmake/packaging scripts to support the Ubuntu 18.04 toolchain +* Disabled FindXMLRPC CMake module when cross compiling. This fixes a build + failure when cross compiling for the O3D303 with CMake 3.10.2 on Ubuntu + 18.04) ## Changes between libo3d3xx 0.7.5 and 0.7.6 diff --git a/README.md b/README.md index 0bbdd14..c6d388a 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,7 @@ Software Compatibility Matrix 0.7.7 - 1.23.1522 + 1.25.4073 O3D303 Support for building with Ubuntu 18.04 toolchain diff --git a/cmake/modules/o3d3xx_version.cmake b/cmake/modules/o3d3xx_version.cmake index d472858..d6fd5ea 100644 --- a/cmake/modules/o3d3xx_version.cmake +++ b/cmake/modules/o3d3xx_version.cmake @@ -4,6 +4,6 @@ ################################################ set(O3D3XX_VERSION_MAJOR 0) set(O3D3XX_VERSION_MINOR 7) -set(O3D3XX_VERSION_PATCH 6) +set(O3D3XX_VERSION_PATCH 7) set(O3D3XX_VERSION_STRING "${O3D3XX_VERSION_MAJOR}.${O3D3XX_VERSION_MINOR}.${O3D3XX_VERSION_PATCH}") diff --git a/modules/camera/CMakeLists.txt b/modules/camera/CMakeLists.txt index 6c67eb4..f167292 100644 --- a/modules/camera/CMakeLists.txt +++ b/modules/camera/CMakeLists.txt @@ -84,7 +84,9 @@ get_ubuntu_version(${UBUNTU_VERSION}) ################################################ ## Bring in dependent projects ################################################ -find_package(XMLRPC REQUIRED c++ client) +if (NOT CMAKE_CROSSCOMPILING) + find_package(XMLRPC REQUIRED c++ client) +endif() find_package(Boost REQUIRED COMPONENTS program_options system) ################################################ diff --git a/modules/camera/test/o3d3xx-camera-tests.cpp b/modules/camera/test/o3d3xx-camera-tests.cpp index da53c70..145aa33 100644 --- a/modules/camera/test/o3d3xx-camera-tests.cpp +++ b/modules/camera/test/o3d3xx-camera-tests.cpp @@ -179,7 +179,7 @@ TEST(Camera_Tests, GetDeviceConfig) // std::cout << kv.first << "=" << kv.second << std::endl; // } - EXPECT_EQ(params.size(), 38); + EXPECT_EQ(params.size(), 40); EXPECT_EQ(params.at("Name"), dev->Name()); EXPECT_EQ(params.at("Description"), dev->Description()); From 20e4516c65ebbff574ec085bc2f916b6db846d57 Mon Sep 17 00:00:00 2001 From: Sean Kelly Date: Mon, 21 Oct 2019 10:28:45 -0400 Subject: [PATCH 5/6] Handle spurious wakeups in WaitForFrame This is a backport from https://github.com/ifm/ifm3d/pull/180/commits/8d2c18abb1a565e73404d6c0b30a8a0457e6f26a FrameGrabber utilizes a condition variable to synchronize on frame availability. Condition variables are subject to spurious wakes and thus some predicate must be provided to ensure the thread actually unblocked for the correct reason. In practice spurious wakes are extremely rare, but they do happen. There happens to be a bug in the Visual C++ 2017 implementation of std::condition_variable which causes timeouts of small values to end up looking like spurious wakes. That's how this issue was discovered. Nonetheless, a spurious wake can and does occur on all platforms, and can cause the FrameGrabber to serve empty buffers or previous frames. This change implements usage of the condition "did the pointer to data in the front buffer change?", indicating the pointer swap did indeed occur. There is a race in this implementation: If the thread calling WaitForFrame executes the read of the pointer after it has been swapped but before the CV is signaled, the caller will miss the current frame. This race should be extremely rare (unless polling WaitForFrame in a tight loop with small timeout, but this is discouraged for general performance reasons). The solution to avoid this race would be to signal the CV under lock, but this simply guarantees the race will be lost by WaitForFrame, missing the current frame. This also potentially introduces a performance issue as the signaled thread will immediately block on the mutex held by the signaler. In summary, the consequences of losing the race are minimal and given the rarity, not worth handling further. Closes #122 --- .../libo3d3xx_framegrabber/frame_grabber.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/framegrabber/src/libo3d3xx_framegrabber/frame_grabber.cpp b/modules/framegrabber/src/libo3d3xx_framegrabber/frame_grabber.cpp index 4b83d03..daab4da 100644 --- a/modules/framegrabber/src/libo3d3xx_framegrabber/frame_grabber.cpp +++ b/modules/framegrabber/src/libo3d3xx_framegrabber/frame_grabber.cpp @@ -180,15 +180,26 @@ o3d3xx::FrameGrabber::WaitForFrame(o3d3xx::ByteBuffer* buff, try { + // Store the current pointer backing the front buffer - this will be the + // condition checked by the condition_variable predicate (pointer should + // have changed) below + std::uint8_t* initial_buff_ptr = this->front_buffer_.data(); + auto predicate = + [this, initial_buff_ptr]() + { + return this->front_buffer_.data() != initial_buff_ptr; + }; + if (timeout_millis <= 0) { - this->front_buffer_cv_.wait(lock); + this->front_buffer_cv_.wait(lock, predicate); } else { - if (this->front_buffer_cv_.wait_for( - lock, std::chrono::milliseconds(timeout_millis)) == - std::cv_status::timeout) + if (!this->front_buffer_cv_.wait_for( + lock, + std::chrono::milliseconds(timeout_millis), + predicate)) { LOG(WARNING) << "Timeout waiting for image buffer from camera"; return false; From 784a16c0630c84f1137b1f1ade7b85d0dbda0165 Mon Sep 17 00:00:00 2001 From: Sean Kelly Date: Mon, 21 Oct 2019 10:31:04 -0400 Subject: [PATCH 6/6] Updated meta-info --- ChangeLog.md | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 5cbc727..c5623ea 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,6 +4,7 @@ * Disabled FindXMLRPC CMake module when cross compiling. This fixes a build failure when cross compiling for the O3D303 with CMake 3.10.2 on Ubuntu 18.04) +* Backported PR#180 from ifm3d to handle spurious wakeups in WaitForFrame ## Changes between libo3d3xx 0.7.5 and 0.7.6 diff --git a/README.md b/README.md index c6d388a..ed07880 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,7 @@ Software Compatibility Matrix 0.7.7 1.25.4073 O3D303 - Support for building with Ubuntu 18.04 toolchain + Support for building with Ubuntu 18.04 toolchain, bugfixes