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

Prepare for ROS Index #45

Merged
merged 7 commits into from
Jan 29, 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
26 changes: 0 additions & 26 deletions .github/workflows/industrial_ci.yaml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/ros_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: ROS2 Build

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
ros2_build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: psdk_ros2
- uses: ros-tooling/[email protected]
with:
required-ros-distributions: humble
- uses: ros-tooling/[email protected]
with:
package-name: psdk_interfaces psdk_wrapper
target-ros2-distro: humble
skip-tests: true
8 changes: 3 additions & 5 deletions debian/create_debians.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null


apt update
apt install -y --no-install-recommends python3-pip python3-bloom python3-catkin-pkg dpkg-dev debhelper dh-python libopus-dev ffmpeg libavcodec-dev libavformat-dev libavfilter-dev libusb-1.0-0-dev
ln -snf /usr/lib/x86_64-linux-gnu/libopus.a /usr/local/lib
apt install -y --no-install-recommends python3-pip python3-bloom python3-catkin-pkg dpkg-dev debhelper dh-python
pip3 install rosdep
rosdep init
mv psdk_ros2/debian/50-my-packages.list /etc/ros/rosdep/sources.list.d
mv psdk_ros2/debian/rosdep.yaml /
cp psdk_ros2/debian/50-my-packages.list /etc/ros/rosdep/sources.list.d
cp psdk_ros2/debian/rosdep.yaml /

# store the current dir
CUR_DIR=$(pwd)
Expand Down
16 changes: 9 additions & 7 deletions docs/documentation/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ To use the psdk_ros2 wrapper you will need to create a new workspace in which yo
```bash
mkdir -p ~/psdk_ros2_ws/src
cd ~/psdk_ros2_ws/src
# Clone the psdk_ros2 wrapper and the Payload-SDK
# Clone the psdk_ros2 wrapper
git clone https://github.com/umdlife/psdk_ros2.git
git clone https://github.com/dji-sdk/Payload-SDK.git

# Checkout the proper version of the Payload-SDK (currently the wrapper is compatible with the latest release v3.5)
cd Payload-SDK
git checkout release/v3.5

# Before building, check the Dependencies section and make sure you have everything installed
# You can also run rosdep to automatically install the dependencies
rosdep update
rosdep keys --from-paths . --ignore-src --rosdistro humble | \
xargs rosdep resolve --rosdistro humble | \
awk '/#apt/{getline; print}' > ./rosdep_requirements.txt
sudo apt install -y --no-install-recommends $(cat ./rosdep_requirements.txt)

# Build the code
cd ~/psdk_ros2_ws
colcon build --packages-skip entry # Skip the build corresponding to DJI PSDK sample code
colcon build

# Launch the node
ros2 launch psdk_wrapper wrapper.launch.py
Expand Down
35 changes: 27 additions & 8 deletions psdk_wrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.14)
project(psdk_wrapper)

SET(BUILD_SHARED_LIBS ON)
Expand Down Expand Up @@ -31,10 +31,29 @@ find_package(tf2_ros REQUIRED)
find_package(psdk_interfaces REQUIRED)
find_package(std_srvs REQUIRED)

# FetchContent module
include(FetchContent)

# Declare the content to fetch
FetchContent_Declare(
Payload_SDK
GIT_REPOSITORY https://github.com/dji-sdk/Payload-SDK.git
GIT_TAG 3.5
)

FetchContent_GetProperties(Payload_SDK)
if(NOT Payload_SDK_POPULATED)
FetchContent_Populate(Payload_SDK)
message(STATUS "Payload_SDK_SOURCE_DIR: ${payload_sdk_SOURCE_DIR}")
endif()

# Set the path to the fetched content
set(PSDK_PATH ${payload_sdk_SOURCE_DIR})

message(STATUS "PSDK_PATH: ${PSDK_PATH}")

# Add path to FindFFMPEG.cmake and FindLIBUSB.cmake files
set(PSDK_PATH ${PROJECT_SOURCE_DIR}/../../Payload-SDK)
set(CMAKE_MODULE_PATH
${PSDK_PATH}/samples/sample_c++/platform/linux/common/3rdparty)
set(CMAKE_MODULE_PATH ${PSDK_PATH}/samples/sample_c++/platform/linux/common/3rdparty)

find_package(FFMPEG REQUIRED)
find_package(LIBUSB REQUIRED)
Expand Down Expand Up @@ -75,9 +94,9 @@ if (FFMPEG_FOUND)
OUTPUT_VARIABLE ffmpeg_version_psdk_libput
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REGEX MATCH "version.*Copyright" ffmpeg_version_line ${ffmpeg_version_psdk_libput})
string(REGEX MATCH " .* " ffmpeg_version ${ffmpeg_version_line})
string(REGEX MATCH "^ 5.*$" ffmpeg_major_version ${ffmpeg_version})
string(REGEX MATCH "version.*Copyright" ffmpeg_version_line "${ffmpeg_version_psdk_libput}")
string(REGEX MATCH " .* " ffmpeg_version "${ffmpeg_version_line}")
string(REGEX MATCH "^ 5.*$" ffmpeg_major_version "${ffmpeg_version}")

if (HEAD${ffmpeg_major_version} STREQUAL "HEAD")
message(STATUS " - Version: ${ffmpeg_version}")
Expand Down Expand Up @@ -108,7 +127,7 @@ include_directories(${FFMPEG_INCLUDE_DIR})
include_directories(${DJI_OSAL_PATH})
include_directories(${DJI_HAL_PATH})
include_directories(${DJI_STREAMING_PATH})
include_directories(${PROJECT_SOURCE_DIR}/../../Payload-SDK/psdk_lib/include)
include_directories(${PSDK_PATH}/psdk_lib/include)
include_directories(include)
include_directories(src/3rdparty)

Expand Down
2 changes: 1 addition & 1 deletion psdk_wrapper/include/psdk_wrapper/psdk_wrapper_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#define CONTROL_DATA_TOPICS_MAX_FREQ 50

#define GOOD_GPS_SIGNAL_LEVEL 5
#define MAX_NUMBER_OF_RETRIES 3
#define MAX_NUMBER_OF_RETRIES 5

namespace psdk_ros2
{
Expand Down
3 changes: 3 additions & 0 deletions psdk_wrapper/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<depend>ffmpeg-dev</depend>
<depend>libusb-1.0-dev</depend>
<depend>libopus-dev</depend>
<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>
<depend>tf2</depend>
Expand Down
10 changes: 7 additions & 3 deletions psdk_wrapper/src/psdk_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ PSDKWrapper::on_configure(const rclcpp_lifecycle::State &state)
{
return CallbackReturn::FAILURE;
}
initialize_ros_elements();

return CallbackReturn::SUCCESS;
}
Expand All @@ -89,17 +88,22 @@ PSDKWrapper::on_activate(const rclcpp_lifecycle::State &state)

if (!init(&user_info))
{
rclcpp::shutdown();
return CallbackReturn::FAILURE;
}

activate_ros_elements();

if (!init_telemetry() || !init_flight_control() || !init_camera_manager() ||
!init_gimbal_manager() || !init_liveview())
{
rclcpp::shutdown();
return CallbackReturn::FAILURE;
}

// Initialize and activate ROS elements only after the DJI modules are
// initialized
initialize_ros_elements();
activate_ros_elements();

if (params_.publish_transforms)
{
publish_static_transforms();
Expand Down
Loading