Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor GStreamerProxy to be a composable node #2

Merged
merged 11 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ AlignAfterOpenBracket: AlwaysBreak
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 2
DerivePointerAlignment: false
AllowAllParametersOfDeclarationOnNextLine: false
PointerAlignment: Middle
PackConstructorInitializers: Never
BinPackArguments: false
BinPackParameters: false

# Configure brace wrapping cases
BreakBeforeBraces: Custom
Expand Down
3 changes: 1 addition & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

---
Checks: >
-*,
Expand All @@ -13,8 +14,6 @@ Checks: >
-google-readability-namespace-comments,
-google-runtime-references,
-misc-non-private-member-variables-in-classes,
-modernize-return-braced-init-list,
-modernize-use-trailing-return-type,
-readability-braces-around-statements,
-readability-identifier-length,
-readability-magic-numbers,
Expand Down
22 changes: 15 additions & 7 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,26 @@ RUN apt-get -q update \
RUN apt-get -q update \
&& apt-get -q -y upgrade \
&& apt-get -q install --no-install-recommends -y \
gir1.2-gstreamer-1.0\
gstreamer1.0-libav \
gstreamer1.0-plugins-bad \
gir1.2-gstreamer-1.0 \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-bad1.0-dev \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-tools \
gstreamer1.0-x \
gstreamer1.0-alsa \
gstreamer1.0-gl \
gstreamer1.0-gtk3 \
gstreamer1.0-qt5 \
gstreamer1.0-pulseaudio \
libcairo2-dev \
libgif-dev \
libjpeg-dev \
python3-gi \
python3-pip\
python3-pip \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -82,8 +90,8 @@ RUN sudo apt-get -q update \
&& sudo rm -rf /var/lib/apt/lists/*

RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
&& colcon build \
&& echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \
# && colcon build \
# && echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \
&& echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc

WORKDIR $USER_WORKSPACE
Expand Down
22 changes: 11 additions & 11 deletions .devcontainer/nouveau/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
"target": "desktop"
},
"runArgs": [
"--network=host",
"--cap-add=SYS_PTRACE",
"--security-opt=seccomp:unconfined",
"--security-opt=apparmor:unconfined",
"--volume=/dev:/dev",
"--privileged",
"--volume=/run/user/1000:/run/user/1000"
"--network=host",
"--cap-add=SYS_PTRACE",
"--security-opt=seccomp:unconfined",
"--security-opt=apparmor:unconfined",
"--volume=/tmp/.X11-unix:/tmp/.X11-unix",
"--ipc=host"
],
"containerEnv": {
"DISPLAY": "${localEnv:DISPLAY}",
"WAYLAND_DISPLAY": "${localEnv:WAYLAND_DISPLAY}",
"XDG_RUNTIME_DIR": "${localEnv:XDG_RUNTIME_DIR}",
"PULSE_SERVER": "${localEnv:PULSE_SERVER}"
"DISPLAY": "${localEnv:DISPLAY}",
"WAYLAND_DISPLAY": "${localEnv:WAYLAND_DISPLAY}",
"XDG_RUNTIME_DIR": "${localEnv:XDG_RUNTIME_DIR}",
"PULSE_SERVER": "${localEnv:PULSE_SERVER}",
"LIBGL_ALWAYS_SOFTWARE": "1"
},
"customizations": {
"vscode": {
Expand Down
32 changes: 0 additions & 32 deletions .github/workflows/ci.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
with:
python-version: "3.12"

- name: Install clang-format-18
run: sudo apt-get install clang-format-18

- name: Run pre-commit
uses: pre-commit/[email protected]
id: precommit
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ log

# virtualenv
.venv

__pycache__/
16 changes: 12 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@ repos:
hooks:
- id: codespell

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.8
hooks:
- id: clang-format
types_or: [c++, c]

- repo: https://github.com/BlankSpruce/gersemi
rev: 0.13.5
hooks:
- id: gersemi

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -20,9 +31,6 @@ repos:
- id: check-yaml
- id: check-xml
- id: check-merge-conflict
- id: check-symlinks
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
Expand Down
2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"includePath": [
"${workspaceFolder}/**",
"/opt/ros/rolling/include/**",
"/usr/include/gz/**"
"/usr/include/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,18 @@ messages. After building `barlus_gstreamer_proxy`, the node can be launched
using

```bash
ros2 launch barlus_gstreamer_proxy gstreamer_proxy.launch.yaml
ros2 launch barlus_gstreamer_proxy gstreamer_proxy.launch.py
```

The frames will be published to the topic `/barlus/image_raw`. The camera
intrinsics are available on the topic `/barlus/camera_info`.

## Camera calibration

The camera intrinsics can be retrieved using the [camera_calibration](https://docs.ros.org/en/rolling/p/camera_calibration/index.html)
node. For example, to calibrate the camera using an 8x6 chessboard, run the
following:

```bash
ros2 run camera_calibration cameracalibrator --size 8x6 --square 0.108 image:=/barlus/image_mono camera:=/barlus --no-service-check
```
73 changes: 73 additions & 0 deletions barlus_gstreamer_proxy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
cmake_minimum_required(VERSION 3.24)
project(barlus_gstreamer_proxy)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

include(GNUInstallDirs)

set(THIS_PACKAGE_INCLUDE_DEPENDS
rclcpp
geometry_msgs
rclcpp_components
cv_bridge
camera_info_manager
image_transport
)

foreach(pkg IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
find_package(${pkg} REQUIRED)
endforeach()

find_package(ament_cmake REQUIRED)
find_package(generate_parameter_library REQUIRED)

find_package(PkgConfig REQUIRED)
pkg_search_module(gstreamer REQUIRED IMPORTED_TARGET gstreamer-1.0)
pkg_search_module(gstreamer-app REQUIRED IMPORTED_TARGET gstreamer-app-1.0)

generate_parameter_library(gstreamer_proxy_parameters
src/gstreamer_proxy_parameters.yaml
)

add_library(gstreamer_proxy_library SHARED)

target_sources(
gstreamer_proxy_library
PRIVATE src/gstreamer_proxy.cpp
PUBLIC
FILE_SET HEADERS
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/barlus_gstreamer_proxy/gstreamer_proxy.hpp
)
target_link_libraries(
gstreamer_proxy_library
PRIVATE gstreamer_proxy_parameters
PUBLIC PkgConfig::gstreamer
PUBLIC PkgConfig::gstreamer-app
)
ament_target_dependencies(gstreamer_proxy_library PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
target_compile_features(gstreamer_proxy_library PUBLIC cxx_std_20)

rclcpp_components_register_node(gstreamer_proxy_library
PLUGIN "barlus::GStreamerProxy"
EXECUTABLE gstreamer_proxy
)

install(
TARGETS gstreamer_proxy_library gstreamer_proxy_parameters
EXPORT export_gstreamer_proxy_library
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
FILE_SET HEADERS
)

install(DIRECTORY config launch DESTINATION share/barlus_gstreamer_proxy)

ament_export_targets(export_gstreamer_proxy_library HAS_LIBRARY_TARGET)
ament_export_dependencies($THIS_PACKAGE_INCLUDE_DEPENDS)

ament_package()
Empty file.
Loading