From 2e9090b2b6418deca7dae43b0513f6101749575e Mon Sep 17 00:00:00 2001 From: dominikn Date: Mon, 6 May 2024 17:02:19 +0000 Subject: [PATCH] work in progress --- .gitignore | 2 + compose.yaml | 11 ++++ snap/local/launcher.sh | 36 ++++++----- snap/local/oak-1-low-bandwidth.yaml | 96 +++++++++++++++++++++++++++++ snap/local/ros_setup.sh | 8 +-- snap/snapcraft.yaml | 54 ++++++++++------ 6 files changed, 168 insertions(+), 39 deletions(-) create mode 100644 .gitignore create mode 100644 compose.yaml create mode 100644 snap/local/oak-1-low-bandwidth.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4817425 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +squashfs-root/ +husarion-depthai* \ No newline at end of file diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..b5a953d --- /dev/null +++ b/compose.yaml @@ -0,0 +1,11 @@ +services: + luxonis: + image: husarion/depthai:humble-2.8.1-20240127 + volumes: + - /dev/bus/usb:/dev/bus/usb + - ./squashfs-root/usr/share/husarion-depthai/config/oak-1-low-bandwidth.yaml:/params.yaml + device_cgroup_rules: + - 'c 189:* rmw' + command: > + ros2 launch depthai_ros_driver camera.launch.py + params_file:=/params.yaml \ No newline at end of file diff --git a/snap/local/launcher.sh b/snap/local/launcher.sh index c81e5b7..686d46e 100755 --- a/snap/local/launcher.sh +++ b/snap/local/launcher.sh @@ -6,24 +6,26 @@ log() { logger -t "${SNAP_NAME}" "launcher: $message" } -# Iterate over the snap parameters and retrieve their value. -# If a value is set, it is forwarded to the launch file. -OPTIONS="namespace mecanum include-camera-mount camera-model lidar-model" -LAUNCH_OPTIONS="" +ros2 launch depthai_ros_driver camera.launch.py params_file:=$SNAP/usr/share/${SNAP_NAME}/config/oak-1-low-bandwidth.yaml -for OPTION in ${OPTIONS}; do - VALUE="$(snapctl get driver.${OPTION})" - if [ -n "${VALUE}" ]; then - LAUNCH_OPTIONS+="${OPTION}:=${VALUE} " - fi -done +# # Iterate over the snap parameters and retrieve their value. +# # If a value is set, it is forwarded to the launch file. +# OPTIONS="namespace mecanum include-camera-mount camera-model lidar-model" +# LAUNCH_OPTIONS="" -# Replace '-' with '_' -LAUNCH_OPTIONS=$(echo ${LAUNCH_OPTIONS} | tr - _) +# for OPTION in ${OPTIONS}; do +# VALUE="$(snapctl get driver.${OPTION})" +# if [ -n "${VALUE}" ]; then +# LAUNCH_OPTIONS+="${OPTION}:=${VALUE} " +# fi +# done -if [ "${LAUNCH_OPTIONS}" ]; then - # watch the log with: "journalctl -t rosbot-xl" - log "Running with options: ${LAUNCH_OPTIONS}" -fi +# # Replace '-' with '_' +# LAUNCH_OPTIONS=$(echo ${LAUNCH_OPTIONS} | tr - _) -ros2 launch rosbot_xl_bringup combined.launch.py ${LAUNCH_OPTIONS} +# if [ "${LAUNCH_OPTIONS}" ]; then +# # watch the log with: "journalctl -t rosbot-xl" +# log "Running with options: ${LAUNCH_OPTIONS}" +# fi + +# ros2 launch rosbot_xl_bringup combined.launch.py ${LAUNCH_OPTIONS} diff --git a/snap/local/oak-1-low-bandwidth.yaml b/snap/local/oak-1-low-bandwidth.yaml new file mode 100644 index 0000000..4a4c96f --- /dev/null +++ b/snap/local/oak-1-low-bandwidth.yaml @@ -0,0 +1,96 @@ +--- +/oak: + ros__parameters: + # qos_overrides: + # /oak/rgb/image_raw: + # publisher: + # reliability: best_effort + # /oak/rgb/image_raw/compressed: + # publisher: + # reliability: best_effort + camera: + i_calibration_dump: false + i_enable_imu: false + i_enable_ir: false + i_external_calibration_path: '' + i_floodlight_brightness: 0 + i_ip: '' + i_laser_dot_brightness: 800 + i_mx_id: '' + i_nn_type: none + i_pipeline_dump: false + i_pipeline_type: RGB + i_publish_tf_from_calibration: false + i_restart_on_diagnostics_error: false + i_usb_port_id: '' + i_usb_speed: SUPER_PLUS + diagnostic_updater: + period: 1.0 + imu: + i_acc_cov: 0.0 + i_acc_freq: 400 + i_batch_report_threshold: 5 + i_enable_rotation: false + i_get_base_device_timestamp: false + i_gyro_cov: 0.0 + i_gyro_freq: 400 + i_mag_cov: 0.0 + i_max_batch_reports: 10 + i_message_type: IMU + i_rot_cov: -1.0 + i_sync_method: LINEAR_INTERPOLATE_ACCEL + i_update_ros_base_time_on_ros_msg: false + rgb: + i_add_exposure_offset: false + i_board_socket_id: 0 + i_calibration_file: '' + i_disable_node: false + i_enable_feature_tracker: false + i_enable_lazy_publisher: false #true + i_enable_nn: false + i_enable_preview: false + i_exposure_offset: 0 + i_fps: 20.0 + i_fsync_continuous: false + i_fsync_trigger: false + i_get_base_device_timestamp: false + i_height: 432 #720 + i_interleaved: false + i_isp_den: 5 #3 #3 valid if i_output_isp: true + i_isp_num: 2 #2 valid if i_output_isp: true + i_keep_preview_aspect_ratio: true + i_low_bandwidth: true #false + i_low_bandwidth_quality: 20 + i_max_q_size: 30 + # i_width: 1280 #valid if i_output_isp: false + # i_height: 720 #valid if i_output_isp: false + # i_interleaved: false + # scaling 1920x1080 1:3 to 640x360 + # https://docs-beta.luxonis.com/develop/ros/depthai-ros-driver#Available%20sensors%20and%20their%20resolutions%3A + # IMX378, 1080P is 1920x1080, i_isp_den=3 and i_isp_num=2 will give 1280x720 (/16=) + i_output_isp: true + i_preview_height: 300 + i_preview_size: 300 + i_preview_width: 300 + i_publish_topic: true + i_resolution: 1080P + i_reverse_stereo_socket_order: false + i_sensor_img_orientation: AUTO + i_set_isp3a_fps: false + i_set_isp_scale: true + i_simulate_from_topic: false + i_simulated_topic_name: '' + i_update_ros_base_time_on_ros_msg: false + i_width: 768 #1280 + r_exposure: 20000 + r_focus: 1 + r_iso: 800 + r_set_man_exposure: false + r_set_man_focus: false + r_set_man_whitebalance: false + r_whitebalance: 3300 + ffmpeg_image_transport: + encoding: libx264 + preset: ultrafast + tune: zerolatency + use_sim_time: false diff --git a/snap/local/ros_setup.sh b/snap/local/ros_setup.sh index 9a41dc7..2e9c5fc 100755 --- a/snap/local/ros_setup.sh +++ b/snap/local/ros_setup.sh @@ -9,7 +9,7 @@ log() { FASTDDS_FILE=$(snapctl get fastdds-default-profiles-file) if [ ! -f "${SNAP_COMMON}/${FASTDDS_FILE}" ]; then - # eg. /var/snap/rosbot-xl/common/fastdds.xml + # eg. /var/snap/${SNAP_NAME}/common/fastdds.xml log "${SNAP_COMMON}/${FASTDDS_FILE} does not exist." fi @@ -19,16 +19,16 @@ if [ -n "${FASTDDS_FILE}" ] && [ -f "${SNAP_COMMON}/${FASTDDS_FILE}" ]; then log "$(cat $FASTRTPS_DEFAULT_PROFILES_FILE)" else TRANSPORT="$(snapctl get transport)" - # watch the log with: "journalctl -t rosbot-xl" + # watch the log with: "journalctl -t ${SNAP_NAME}" log "transport: ${TRANSPORT}" case "$TRANSPORT" in shm) - export FASTRTPS_DEFAULT_PROFILES_FILE=$SNAP/usr/share/rosbot-xl/config/shm-only.xml + export FASTRTPS_DEFAULT_PROFILES_FILE=$SNAP/usr/share/${SNAP_NAME}/config/shm-only.xml log "$(cat $FASTRTPS_DEFAULT_PROFILES_FILE)" ;; udp) - export FASTRTPS_DEFAULT_PROFILES_FILE=$SNAP/usr/share/rosbot-xl/config/udp-only.xml + export FASTRTPS_DEFAULT_PROFILES_FILE=$SNAP/usr/share/${SNAP_NAME}/config/udp-only.xml log "$(cat $FASTRTPS_DEFAULT_PROFILES_FILE)" ;; builtin) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 5a73989..f612dfe 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -49,15 +49,16 @@ apps: command: usr/bin/launcher.sh command-chain: [usr/bin/ros_setup.sh] daemon: simple - install-mode: enable - plugs: [network, network-bind, shm-plug] + install-mode: disable + plugs: [network, network-bind, shm-plug, raw-usb] slots: [shm-slot] extensions: [ros2-humble-ros-base] husarion-depthai: command: usr/bin/launcher.sh command-chain: [usr/bin/check_daemon_running.sh, usr/bin/ros_setup.sh] - plugs: [network, network-bind, shm-plug] + plugs: [network, network-bind, shm-plug, raw-usb, system-observe, hardware-observe, network-control, network-observe, camera, browser-support] + # block-devices, slots: [shm-slot] extensions: [ros2-humble-ros-base] @@ -67,24 +68,41 @@ apps: stop: command: usr/bin/stop_launcher.sh +layout: + /run/udev/data: + bind: $SNAP_DATA/run/udev/data + parts: husarion-depthai: - plugin: colcon - source: https://github.com/luxonis/depthai-ros.git - source-branch: v2.8.1-humble - build-packages: - - python3-catkin-pkg-modules - override-pull: | + plugin: nil + stage-packages: + - ros-humble-depthai-ros + # override-stage: | + override-prime: | craftctl default - # Set the snap version from the git tag - # The grade is set to 'stable' if the latest entry in the git history - # is the tag itself, otherwise set to devel - version="$(git describe --always --tags| sed -e 's/^v//;s/-/+git/;y/-/./')" - [ -n "$(echo $version | grep "+git")" ] && grade=devel || grade=stable - craftctl set version="$version" - craftctl set grade="$grade" + #version="$(dpkg -s ros-humble-depthai-ros-driver | grep Version | awk '{print $2}')" + #craftctl set version="$version" + craftctl set version="2.9.0-1jammy.20240415.141623" + craftctl set grade="stable" + + # husarion-depthai: + # plugin: colcon + # source: https://github.com/luxonis/depthai-ros.git + # source-branch: v2.8.1-humble + # build-packages: + # - python3-catkin-pkg-modules + # override-pull: | + # craftctl default + + # # Set the snap version from the git tag + # # The grade is set to 'stable' if the latest entry in the git history + # # is the tag itself, otherwise set to devel + # version="$(git describe --always --tags| sed -e 's/^v//;s/-/+git/;y/-/./')" + # [ -n "$(echo $version | grep "+git")" ] && grade=devel || grade=stable + # craftctl set version="$version" + # craftctl set grade="$grade" # build-packages: # - python3-vcstool @@ -113,5 +131,5 @@ parts: organize: '*.sh': usr/bin/ '*.py': usr/bin/ - '*.yaml': usr/share/rosbot-xl/config/ - '*.xml': usr/share/rosbot-xl/config/ + '*.yaml': usr/share/husarion-depthai/config/ + '*.xml': usr/share/husarion-depthai/config/