Skip to content

Commit

Permalink
gz: add gstreamer plugin (#24475)
Browse files Browse the repository at this point in the history
  • Loading branch information
dakejahl authored Mar 9, 2025
1 parent bc0d257 commit 7c2aa72
Show file tree
Hide file tree
Showing 6 changed files with 722 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/modules/simulation/gz_bridge/server.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<render_engine>ogre2</render_engine>
</plugin>
<plugin entity_name="*" entity_type="world" filename="libOpticalFlowSystem.so" name="custom::OpticalFlowSystem"/>
<plugin entity_name="*" entity_type="world" filename="libGstCameraSystem.so" name="custom::GstCameraSystem"/>
<!-- <plugin entity_name="*" entity_type="world" filename="libTemplatePlugin.so" name="custom::TemplateSystem"/> -->
</plugins>
</server_config>
3 changes: 2 additions & 1 deletion src/modules/simulation/gz_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ if (gz-transport${GZ_TRANSPORT_VERSION}_FOUND)
# Add our plugins as subdirectories
add_subdirectory(optical_flow)
add_subdirectory(template_plugin)
add_subdirectory(gstreamer)

# Add an alias target for each plugin
add_custom_target(px4_gz_plugins ALL DEPENDS OpticalFlowSystem TemplatePlugin)
add_custom_target(px4_gz_plugins ALL DEPENDS OpticalFlowSystem TemplatePlugin GstCameraSystem)
endif()
69 changes: 69 additions & 0 deletions src/modules/simulation/gz_plugins/gstreamer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
############################################################################
#
# Copyright (c) 2025 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name PX4 nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################

project(GstCameraSystem)

# Find required packages
find_package(OpenCV REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
pkg_check_modules(GSTREAMER_APP REQUIRED gstreamer-app-1.0)

add_library(${PROJECT_NAME} SHARED
GstCameraSystem.cpp
)

target_link_libraries(${PROJECT_NAME}
PUBLIC px4_gz_msgs
PUBLIC gz-sensors${GZ_SENSORS_VERSION}::gz-sensors${GZ_SENSORS_VERSION}
PUBLIC gz-plugin${GZ_PLUGIN_VERSION}::gz-plugin${GZ_PLUGIN_VERSION}
PUBLIC gz-sim${GZ_SIM_VERSION}::gz-sim${GZ_SIM_VERSION}
PUBLIC gz-transport${GZ_TRANSPORT_VERSION}::gz-transport${GZ_TRANSPORT_VERSION}
PUBLIC ${OpenCV_LIBS}
PUBLIC ${GSTREAMER_LIBRARIES}
PUBLIC ${GSTREAMER_APP_LIBRARIES}
)

target_include_directories(${PROJECT_NAME}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}
PUBLIC px4_gz_msgs
PUBLIC ${OpenCV_INCLUDE_DIRS}
PUBLIC ${GSTREAMER_INCLUDE_DIRS}
PUBLIC ${GSTREAMER_APP_INCLUDE_DIRS}
)

target_compile_options(${PROJECT_NAME}
PRIVATE ${GSTREAMER_CFLAGS}
PRIVATE ${GSTREAMER_APP_CFLAGS}
)
Loading

0 comments on commit 7c2aa72

Please sign in to comment.