This is a generic ROS package designed to test the functionality of LibTorch. https://pytorch.org/get-started/locally/
Tested Libtorch version:
Please download cxx11 ABI version, otherwise it may cause ROS library error.
Reference:
-
Move this package to the directory of your ROS workspace (e.g.,
catkin_ws/src/
).-
Create a workspace:
cd $HOME && mkdir -p catkin_ws/src
-
Clone the repo into the workspace:
cd $HOME/catkin_ws/src git clone https://github.com/KafuuChikai/test_torch.git
-
-
Change the Torch_DIR variable in the CMakeLists.txt file to point to your LibTorch installation directory.
# set package directories set(Torch_DIR {Your_libtorch_path})
-
Navigate to the
catkin_ws/
directory and then build:catkin_make
Possible make ERROR:
CMake Error at test_torch/CMakeLists.txt:1 (cmake_minimum_required):
CMake 3.18 or higher is required. You are running version 3.xx.x
Resolution: update Cmake:
-
Download from https://cmake.org/files/ and
tar -xvzf cmake-3.xx.tar.gz
-
Make and install
cd cmake-3.xx.tar.gz ./configure make sudo make install
To get started, open a terminal and start roscore
.
roscore
Then, in another terminal, run ROS node.
rosrun test_torch test_torch
- Tested Libtorch version:
https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.6.0%2Bcpu.zip
Do not use v2.2.x. Just download and there is no need to make.
- Tested CMake version:
cmake-3.18.5.tar.gz
Install is the same as Ubuntu!