Skip to content

Commit

Permalink
single library
Browse files Browse the repository at this point in the history
  • Loading branch information
dakejahl committed Dec 25, 2024
1 parent 45014b4 commit 2286fa8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 42 deletions.
55 changes: 13 additions & 42 deletions src/modules/simulation/gz_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,65 +1,36 @@
cmake_minimum_required(VERSION 3.11.0 FATAL_ERROR)

find_package(gz-cmake3 REQUIRED)

project(OpticalFlowSystem)

gz_find_package(gz-plugin2 REQUIRED COMPONENTS register)
set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR})

gz_find_package(gz-sim8 REQUIRED)
set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR})

find_package(gz-sensors8 REQUIRED)
set(GZ_SENSORS_VER ${gz-sensors8_VERSION_MAJOR})

gz_find_package(gz-sensors8 REQUIRED)
gz_find_package(gz-transport12 REQUIRED)
find_package(OpenCV REQUIRED)

# add_subdirectory(sensors optical_flow)
find_package(Protobuf REQUIRED)

PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS optical_flow.proto)

add_library(optical_flow_plugin SHARED
${PROTO_SRCS}
${PROTO_HDRS}
OpticalFlow.cc
)

set(sensors
optical_flow_plugin
add_library(${PROJECT_NAME} SHARED
OpticalFlow.cc
OpticalFlowSystem.cc
${PROTO_SRCS}
${PROTO_HDRS}
)

foreach(sensor ${sensors})
target_link_libraries(${sensor}
target_link_libraries(${PROJECT_NAME}
PUBLIC gz-sensors8::gz-sensors8
PUBLIC gz-rendering8::gz-rendering8
PUBLIC gz-plugin2::gz-plugin2
PUBLIC gz-sim8::gz-sim8
PUBLIC gz-transport12::gz-transport12
PUBLIC ${OpenCV_LIBS}
PUBLIC ${PROTOBUF_LIBRARIES}
)

target_include_directories(${sensor}
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}
PUBLIC ${OpenCV_INCLUDE_DIRS}
)

endforeach()

add_library(${PROJECT_NAME} SHARED
OpticalFlowSystem.cc
)

# add_dependencies(${PROJECT_NAME} optical_flow)

target_link_libraries(${PROJECT_NAME}
PUBLIC ${sensors}
PRIVATE gz-plugin${GZ_PLUGIN_VER}::gz-plugin${GZ_PLUGIN_VER}
PRIVATE gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
PRIVATE gz-sensors${GZ_SENSORS_VER}::gz-sensors${GZ_SENSORS_VER}
PRIVATE ${OpenCV_LIBS}
)

target_include_directories(${PROJECT_NAME}
PUBLIC ${PROJECT_SOURCE_DIR}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}
PUBLIC ${OpenCV_INCLUDE_DIRS}
)
4 changes: 4 additions & 0 deletions src/modules/simulation/gz_plugin/OpticalFlow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ bool OpticalFlow::Load(const sdf::Sensor &_sdf)

void OpticalFlow::OnImage(const gz::msgs::Image &_msg)
{
// gzdbg << "OpticalFlow::OnImage" << std::endl;

cv::Mat frame;

if (_msg.pixel_format_type() == gz::msgs::PixelFormatType::RGB_INT8) {
Expand Down Expand Up @@ -96,6 +98,8 @@ void OpticalFlow::OnImage(const gz::msgs::Image &_msg)

bool OpticalFlow::Update(const std::chrono::steady_clock::duration &_now)
{
// gzdbg << "OpticalFlow::Update" << std::endl;

auto currentTime = std::chrono::steady_clock::now();
auto deltaTime = std::chrono::duration_cast<std::chrono::microseconds>(currentTime - this->lastUpdateTime);

Expand Down

0 comments on commit 2286fa8

Please sign in to comment.