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

Add prototype version #1

Merged
merged 5 commits into from
Nov 3, 2023
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
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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"
23 changes: 23 additions & 0 deletions .github/workflows/ci-format.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
python-version: '3.10'
- name: Install system hooks
run: sudo apt install -qq clang-format-14 cppcheck
- uses: pre-commit/[email protected]
with:
extra_args: --all-files --hook-stage manual
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
use-ros2-testing: true
- uses: ros-tooling/[email protected]
with:
target-ros2-distro: humble
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
log/
install/
147 changes: 147 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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)$
57 changes: 38 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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
$<BUILD_INTERFACE:${fd_sdk_binaries_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${MOSEK_HEADERDIR}>
$<INSTALL_INTERFACE:include>
)

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
#----------
Expand All @@ -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()
37 changes: 34 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,40 @@ Vendor package to use the solver MOSEK in ROS2 applications.

## Installation

## Get a license
1) Install the package

```bash
cd <ros_ws>/src
git clone <this_repos>
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
...
<depend>mosek_vendor_ros2</depend>
...
```

The file `mosek.lic` you will obtain has to be copied to your personnal home folder in `~/mosek/mosek.lic`.
> `CMakeLists.txt` :
```cmake
...
find_package(mosek_vendor_ros2)
...
ament_target_dependencies(<the_target> <type> mosek_vendor_ros2)
...
```
> `xxx.cpp` :
```cpp
#include <mosek_vendor_ros2/fusion.h>