diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 0ba5751e..aee06101 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -51,14 +51,20 @@ jobs: run: | touch ./opencv-install/COLCON_IGNORE + - name: Download and extract LibTorch + run: | + wget https://download.pytorch.org/libtorch/cu111/libtorch-shared-with-deps-1.8.1%2Bcu111.zip + unzip -o libtorch-shared-with-deps-1.8.1+cu111.zip -d libtorch + - name: Source setup and build then test using colcon shell: bash env: LD_LIBRARY_PATH: /usr/local/lib/ + Torch_DIR: ${{ github.workspace }}/libtorch/libtorch/share/cmake/Torch run: | source /opt/ros/foxy/setup.bash source /usr/share/gazebo/setup.sh - colcon build --cmake-args -DCMAKE_CXX_STANDARD=14 + colcon build --cmake-args -DCMAKE_CXX_STANDARD=14 -DTorch_DIR=$Torch_DIR source ./install/setup.bash colcon test colcon test-result --verbose diff --git a/src/triton_object_recognition/CMakeLists.txt b/src/triton_object_recognition/CMakeLists.txt index bfaad342..364f6287 100644 --- a/src/triton_object_recognition/CMakeLists.txt +++ b/src/triton_object_recognition/CMakeLists.txt @@ -25,9 +25,15 @@ find_package(cv_bridge REQUIRED) find_package(sensor_msgs REQUIRED) find_package(image_transport REQUIRED) find_package(OpenCV 4.5.3 REQUIRED) -find_package(Boost REQUIRED COMPONENTS filesystem) -find_package(Torch REQUIRED) +find_package(Boost REQUIRED COMPONENTS filesystem) +# Use Torch_DIR environment variable if set +if(DEFINED ENV{Torch_DIR}) + set(Torch_DIR $ENV{Torch_DIR}) +else() + set(Torch_DIR "/default/path/to/libtorch/share/cmake/Torch") +endif() +find_package(Torch REQUIRED) include_directories(include ${catkin_INCLUDE_DIRS}) include_directories(${OpenCV_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) @@ -39,7 +45,6 @@ add_library(triton_object_recognition SHARED target_link_libraries(triton_object_recognition ${OpenCV_LIBRARIES} ${Boost_LIBRARIES}) target_link_libraries(your_executable_name "${TORCH_LIBRARIES}") - rclcpp_components_register_nodes(triton_object_recognition "triton_object_recognition::ObjectRecognizer" )