diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..05a48fc --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" + # Workflow files stored in the + # default location of `.github/workflows` + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/ci-format.yml b/.github/workflows/ci-format.yml new file mode 100644 index 0000000..d01e542 --- /dev/null +++ b/.github/workflows/ci-format.yml @@ -0,0 +1,23 @@ +# This is a format job. Pre-commit has a first-party GitHub action, so we use +# that: https://github.com/pre-commit/action + +name: Format + +on: + workflow_dispatch: + pull_request: + +jobs: + pre-commit: + name: Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4.7.1 + with: + python-version: '3.10' + - name: Install system hooks + run: sudo apt install -qq clang-format-14 cppcheck + - uses: pre-commit/action@v3.0.0 + with: + extra_args: --all-files --hook-stage manual diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d30e20f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,20 @@ +name: CI (humble) +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + container: + image: ubuntu:jammy + steps: + - uses: actions/checkout@v4 + - uses: ros-tooling/setup-ros@v0.7 + with: + use-ros2-testing: true + - uses: ros-tooling/action-ros-ci@v0.3 + with: + target-ros2-distro: humble diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d18e8c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build/ +log/ +install/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..fa85833 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,147 @@ +# To use: +# pip install pre-commit +# pre-commit run -a +# +# (to run on all files) +# pre-commit run --all-files +# +# Or: +# +# pre-commit install # (runs every time you commit in git) +# +# To update this file: +# +# pre-commit autoupdate +# +# See https://github.com/pre-commit/pre-commit + +repos: + # Standard hooks + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-added-large-files + - id: check-ast + - id: check-case-conflict + - id: check-docstring-first + - id: check-merge-conflict + - id: check-symlinks + - id: check-xml + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace + exclude_types: [rst] + - id: fix-byte-order-marker + + # Python hooks + - repo: https://github.com/asottile/pyupgrade + rev: v3.3.1 + hooks: + - id: pyupgrade + args: [--py36-plus] + + # PyDocStyle + - repo: https://github.com/PyCQA/pydocstyle + rev: 6.3.0 + hooks: + - id: pydocstyle + args: ["--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404"] + + - repo: https://github.com/pycqa/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + args: ["--extend-ignore=E501"] + + # Uncrustify + - repo: local + hooks: + - id: ament_uncrustify + name: ament_uncrustify + description: Uncrustify. + stages: [commit] + entry: ament_uncrustify + language: system + files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$ + args: ["--reformat"] + + # CPP hooks + - repo: local + hooks: + - id: clang-format + name: clang-format + description: Format files with ClangFormat. + entry: clang-format-14 + language: system + files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$ + args: ['-fallback-style=none', '-i'] + + # - repo: local + # hooks: + # - id: ament_cppcheck + # name: ament_cppcheck + # description: Static code analysis of C/C++ files. + # stages: [commit] + # entry: ament_cppcheck + # language: system + # files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$ + + # Maybe use https://github.com/cpplint/cpplint instead + - repo: local + hooks: + - id: ament_cpplint + name: ament_cpplint + description: Static code analysis of C/C++ files. + stages: [commit] + entry: ament_cpplint + language: system + files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$ + args: ["--linelength=100", "--filter=-whitespace/newline"] + + # Cmake hooks + - repo: local + hooks: + - id: ament_lint_cmake + name: ament_lint_cmake + description: Check format of CMakeLists.txt files. + stages: [commit] + entry: ament_lint_cmake + language: system + files: CMakeLists\.txt$ + + # Copyright + - repo: local + hooks: + - id: ament_copyright + name: ament_copyright + description: Check if copyright notice is available in all files. + stages: [commit] + entry: ament_copyright + language: system + + # Docs - RestructuredText hooks + - repo: https://github.com/PyCQA/doc8 + rev: v1.1.1 + hooks: + - id: doc8 + args: ['--max-line-length=100', '--ignore=D001'] + exclude: CHANGELOG\.rst$ + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.10.0 + hooks: + - id: rst-backticks + exclude: CHANGELOG\.rst$ + - id: rst-directive-colons + - id: rst-inline-touching-normal + + # Spellcheck in comments and docs + # skipping of *.svg files is not working... + - repo: https://github.com/codespell-project/codespell + rev: v2.2.2 + hooks: + - id: codespell + args: ['--write-changes'] + exclude: CHANGELOG\.rst|\.(svg|pyc)$ diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b6a159..29e45d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,9 +23,6 @@ if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD_REQUIRED ON) endif() -find_package(PkgConfig REQUIRED) -pkg_check_modules(libusb REQUIRED libusb-1.0) - find_package(ament_cmake REQUIRED) include(FetchContent) include(ExternalProject) @@ -34,7 +31,8 @@ include(ExternalProject) #--------------------------------- fetchcontent_declare( mosek_binaries - URL https://download.mosek.com/stable/${MOSEK_VERSION}/mosektoolslinuxaarch64.tar.bz2 + URL https://download.mosek.com/stable/${MOSEK_VERSION}/mosektoolslinux64x86.tar.bz2 + INSTALL_COMMAND "" ) fetchcontent_makeavailable(mosek_binaries) @@ -46,7 +44,7 @@ list(GET VERSION_MOSEK_LIST 1 VERSION_MOSEK_MINOR) set( MOSEK_SRC_LINUX - ${mosek_binaries_SOURCE_DIR}/${VERSION_MOSEK_MAJOR}.${VERSION_MOSEK_MINOR}/tools/platform/linuxaarch64/ + ${mosek_binaries_SOURCE_DIR}/${VERSION_MOSEK_MAJOR}.${VERSION_MOSEK_MINOR}/tools/platform/linux64x86/ ) set(MOSEK_HEADERDIR ${MOSEK_SRC_LINUX}/h) @@ -57,29 +55,27 @@ set(MOSEK_LIBDIR ${MOSEK_SRC_LINUX}/bin) # Build the C++ API (Fusion) #------------------------------- -#[==[ -find_program(MAKE_EXECUTABLE NAMES make REQUIRED) -SET(CMAKE_EXE_LINKER_FLAGS - "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath -Wl,${MOSEK_LIBDIR}") - -set(CMAKE_INSTALL_RPATH ${MOSEK_LIBDIR}) -set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -execute_process(COMMAND make install -j -C ${MOSEK_SRCDIR}) +set(CMAKE_VERBOSE_MAKEFILE ON) +execute_process( + WORKING_DIRECTORY ${MOSEK_SRCDIR} + COMMAND make install +) # Setup vendor library #---------------------- + add_library(${PROJECT_NAME} INTERFACE) target_include_directories(${PROJECT_NAME} INTERFACE - $ + $ $ ) + target_link_libraries( - ${PROJECT_NAME} INTERFACE - ${CMAKE_INSTALL_PREFIX}/lib/libdhd.so.${VERSION_SDK_MAJOR} - ${CMAKE_INSTALL_PREFIX}/lib/libdrd.so.${VERSION_SDK_MAJOR} - ${libusb-1.0_LIBRARIES} + ${PROJECT_NAME} + INTERFACE + ${CMAKE_INSTALL_PREFIX}/lib/libmosek64.so.${VERSION_MOSEK_MAJOR}.${VERSION_MOSEK_MINOR} + ${CMAKE_INSTALL_PREFIX}/lib/libfusion64.so.${VERSION_MOSEK_MAJOR}.${VERSION_MOSEK_MINOR} ) -#]==] # Testing #---------- @@ -95,4 +91,27 @@ endif() # Install #---------- +install( + DIRECTORY ${MOSEK_HEADERDIR}/ + DESTINATION ./include/${PROJECT_NAME} +) + +install( + FILES ${MOSEK_LIBDIR}/libmosek64.so.${VERSION_MOSEK_MAJOR}.${VERSION_MOSEK_MINOR} + DESTINATION lib +) +install( + FILES ${MOSEK_LIBDIR}/libfusion64.so.${VERSION_MOSEK_MAJOR}.${VERSION_MOSEK_MINOR} + DESTINATION lib +) +install( + TARGETS ${PROJECT_NAME} + EXPORT export_${PROJECT_NAME} + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin +) + +ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET) + ament_package() diff --git a/README.md b/README.md index 460cf2b..fa17e1b 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,40 @@ Vendor package to use the solver MOSEK in ROS2 applications. ## Installation -## Get a license +1) Install the package + +```bash +cd /src +git clone +cd .. +colcon build +``` + +2) Get a license Note that a license is mandatory to run MOSEK. -See the [website](https://docs.mosek.com/10.1/licensing/quickstart.html#i-don-t-have-a-license-file-yet) for the detailled procedure. +See the [website](https://docs.mosek.com/10.1/licensing/quickstart.html#i-don-t-have-a-license-file-yet) for the detailed procedure. + +The file `mosek.lic` you will obtain has to be copied to your personal home folder in `~/mosek/mosek.lic`. + + +## Usage example + +> `package.xml` : +```xml +... +mosek_vendor_ros2 +... +``` -The file `mosek.lic` you will obtain has to be copied to your personnal home folder in `~/mosek/mosek.lic`. \ No newline at end of file +> `CMakeLists.txt` : +```cmake +... +find_package(mosek_vendor_ros2) +... +ament_target_dependencies( mosek_vendor_ros2) +... +``` +> `xxx.cpp` : +```cpp +#include