From ec8c72223e9465dfb8e30a2067684f8aef08c0c7 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 13:26:12 +0100 Subject: [PATCH 01/24] Test github actions --- .github/workflows/github-opengjk-examples.yml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/github-opengjk-examples.yml diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml new file mode 100644 index 0000000..cf10601 --- /dev/null +++ b/.github/workflows/github-opengjk-examples.yml @@ -0,0 +1,22 @@ +name: Run all demos +run-name: ${{ github.actor }} is running +on: [push] +jobs: + Run C example: + runs-on: mmontanari/devenv:buildenv-fedora + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - name: Check out repository code + uses: actions/checkout@v3 + - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - name: List files in the repository + run: | + ls ${{ github.workspace }} + - run: echo "🍏 This job's status is ${{ job.status }}." + - cmake -E make_directory build + - cmake -E chdir build cmake -DCMAKE_BUILD_TYPE=Release .. + - cmake --build build + - cmake -E chdir build/examples/c/ ./example_lib_opengjk_ce From a7d39e3ab4bd3bc23d1a4c4a77a3ab30bb3e426a Mon Sep 17 00:00:00 2001 From: Mattia Montanari <13785944+MattiaMontanari@users.noreply.github.com> Date: Tue, 14 Feb 2023 13:34:43 +0100 Subject: [PATCH 02/24] Add run: --- .github/workflows/github-opengjk-examples.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index cf10601..0eeb5ac 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -16,7 +16,7 @@ jobs: run: | ls ${{ github.workspace }} - run: echo "🍏 This job's status is ${{ job.status }}." - - cmake -E make_directory build - - cmake -E chdir build cmake -DCMAKE_BUILD_TYPE=Release .. - - cmake --build build - - cmake -E chdir build/examples/c/ ./example_lib_opengjk_ce + - run: cmake -E make_directory build + - run: cmake -E chdir build cmake -DCMAKE_BUILD_TYPE=Release .. + - run: cmake --build build + - run: cmake -E chdir build/examples/c/ ./example_lib_opengjk_ce From 0b857500fcf3fe5298c4b1233afceb71443bcd9e Mon Sep 17 00:00:00 2001 From: Mattia Montanari <13785944+MattiaMontanari@users.noreply.github.com> Date: Tue, 14 Feb 2023 13:35:40 +0100 Subject: [PATCH 03/24] fix jobname --- .github/workflows/github-opengjk-examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index 0eeb5ac..5b661ee 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -2,7 +2,7 @@ name: Run all demos run-name: ${{ github.actor }} is running on: [push] jobs: - Run C example: + Run_C_example: runs-on: mmontanari/devenv:buildenv-fedora steps: - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." From 32517b190b055b97fea50cb8b23de98f0f78e289 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 13:44:19 +0100 Subject: [PATCH 04/24] Edit container --- .github/workflows/github-opengjk-examples.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index 5b661ee..2d300d5 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -2,8 +2,9 @@ name: Run all demos run-name: ${{ github.actor }} is running on: [push] jobs: - Run_C_example: - runs-on: mmontanari/devenv:buildenv-fedora + Run C example: + runs-on: ubuntu-latest + container: mmontanari/devenv:buildenv-fedora steps: - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" From 64f46a4ef0d64fd99974a88948a9ab08eac283fa Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 13:46:38 +0100 Subject: [PATCH 05/24] up --- .github/workflows/github-opengjk-examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index 2d300d5..32ac570 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -2,7 +2,7 @@ name: Run all demos run-name: ${{ github.actor }} is running on: [push] jobs: - Run C example: + Run_C_example: runs-on: ubuntu-latest container: mmontanari/devenv:buildenv-fedora steps: From 48a95f60ebca972d33b8865661ee9fb3de2ef37b Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 13:49:36 +0100 Subject: [PATCH 06/24] postpone ls --- .github/workflows/github-opengjk-examples.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index 32ac570..2b65e8f 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -13,11 +13,11 @@ jobs: uses: actions/checkout@v3 - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ github.workspace }} - run: echo "🍏 This job's status is ${{ job.status }}." - run: cmake -E make_directory build - run: cmake -E chdir build cmake -DCMAKE_BUILD_TYPE=Release .. - run: cmake --build build - run: cmake -E chdir build/examples/c/ ./example_lib_opengjk_ce + - name: List files in the repository + run: | + ls ${{ github.workspace }} From d904dc14fb2b10dba9926771275749be7635e2ed Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 14:05:42 +0100 Subject: [PATCH 07/24] run GO example --- .github/workflows/github-opengjk-examples.yml | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index 2b65e8f..e83b3d5 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -6,18 +6,22 @@ jobs: runs-on: ubuntu-latest container: mmontanari/devenv:buildenv-fedora steps: - - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - name: Check out repository code uses: actions/checkout@v3 - - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - run: echo "🍏 This job's status is ${{ job.status }}." - run: cmake -E make_directory build - run: cmake -E chdir build cmake -DCMAKE_BUILD_TYPE=Release .. - run: cmake --build build - run: cmake -E chdir build/examples/c/ ./example_lib_opengjk_ce - - name: List files in the repository - run: | - ls ${{ github.workspace }} + + Run_GO_example: + runs-on: ubuntu-latest + container: mmontanari/devenv:buildenv-fedora + steps: + - uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.15 + - run: cd examples/go/openGJK + - run: go build + - run: go test -v From 0583bdabbb3e55c977d84cfc416b6232c1c62a95 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 14:10:51 +0100 Subject: [PATCH 08/24] try to go build in cd --- .github/workflows/github-opengjk-examples.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index e83b3d5..3e3026a 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -22,6 +22,5 @@ jobs: uses: actions/setup-go@v3 with: go-version: 1.15 - - run: cd examples/go/openGJK - - run: go build + - run: cd examples/go/openGJK && go build - run: go test -v From c57913dd112688ec270f6b3a7850365a94b77cbc Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 14:12:09 +0100 Subject: [PATCH 09/24] cd build and test --- .github/workflows/github-opengjk-examples.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index 3e3026a..d08acfb 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -22,5 +22,4 @@ jobs: uses: actions/setup-go@v3 with: go-version: 1.15 - - run: cd examples/go/openGJK && go build - - run: go test -v + - run: cd examples/go/openGJK && go build && go test -v From 4151e3aab06f1519670b5e60a024d97993f51cb4 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 14:14:22 +0100 Subject: [PATCH 10/24] break go --- examples/go/openGJK/connector_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/go/openGJK/connector_test.go b/examples/go/openGJK/connector_test.go index 2feaf96..e423880 100644 --- a/examples/go/openGJK/connector_test.go +++ b/examples/go/openGJK/connector_test.go @@ -27,7 +27,7 @@ func TestGJK(t *testing.T) { {5.0, 0.5, 0.0}, {5.0, -0.5, 0.0}, } - fassert(t, GJK(a, b), 0) + fassert(t, GJK(a, b), 1) fassert(t, GJK(b, c), 1) fassert(t, GJK(a, c), 2) } From b4de1e3a724b1c5656ec688fdeaf701d4514f922 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 14:14:37 +0100 Subject: [PATCH 11/24] undo breaking change --- examples/go/openGJK/connector_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/go/openGJK/connector_test.go b/examples/go/openGJK/connector_test.go index e423880..2feaf96 100644 --- a/examples/go/openGJK/connector_test.go +++ b/examples/go/openGJK/connector_test.go @@ -27,7 +27,7 @@ func TestGJK(t *testing.T) { {5.0, 0.5, 0.0}, {5.0, -0.5, 0.0}, } - fassert(t, GJK(a, b), 1) + fassert(t, GJK(a, b), 0) fassert(t, GJK(b, c), 1) fassert(t, GJK(a, c), 2) } From 9876960d08533b60286cb3834cf883d93ad7dc36 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 15:05:20 +0100 Subject: [PATCH 12/24] Add octave github action --- .github/workflows/github-opengjk-examples.yml | 8 +++ examples/matlab/main.m | 58 ++++++++++--------- examples/matlab/runme.m | 27 ++------- 3 files changed, 44 insertions(+), 49 deletions(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index d08acfb..6c6c591 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -23,3 +23,11 @@ jobs: with: go-version: 1.15 - run: cd examples/go/openGJK && go build && go test -v + + Run_Octave_example: + runs-on: ubuntu-latest + container: gnuoctave/octave:7.3.0 + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - run: cd examples/matlab/; run runme.m diff --git a/examples/matlab/main.m b/examples/matlab/main.m index 741e5b8..ab555a4 100644 --- a/examples/matlab/main.m +++ b/examples/matlab/main.m @@ -32,31 +32,33 @@ B = -A; dist = openGJK( A, B ); fprintf('The minimum distance between A and B is %.2f\n',dist); -% VISUALISE RESULTS -% .. create new figure -figure('units','centimeters', 'WindowStyle','normal', 'color','w',... - 'Position',[0 8.5 9 6],'defaultAxesColorOrder',parula,... - 'Renderer','opengl') -% .. adjust properties -axis equal tight off; hold all; -% .. display body A -DT = delaunayTriangulation(A'); -[K,~] = convexHull(DT); -trisurf(K,DT.Points(:,1),DT.Points(:,2),DT.Points(:,3),... - 'EdgeColor','none','FaceColor',[.4 1 .9 ],... - 'FaceLighting','flat' ) -% .. display body B -DT = delaunayTriangulation(B'); -[K,~] = convexHull(DT); -trisurf(K,DT.Points(:,1),DT.Points(:,2),DT.Points(:,3),... - 'EdgeColor','none','FaceColor',[.4 1 .8 ],... - 'FaceLighting','flat' ) -% .. represent the computed distance as a sphere -[x,y,z] = sphere(100); -surf(x.*dist/2,y.*dist/2,z.*dist/2,'facecolor',[.9 .9 .9],... - 'EdgeColor','none','FaceLighting','flat','SpecularColorReflectance',0,... - 'SpecularStrength',1,'SpecularExponent',10,'facealpha',.7) -% ... adjust point of view -view(42,21) -% ... add light -light('Position',[5 -10 20],'Style','local'); +% VISUALISE RESULTS ONLY IN MATLAB +if(exist('OCTAVE_VERSION', 'builtin') == 0) + % .. create new figure + figure('units','centimeters', 'WindowStyle','normal', 'color','w',... + 'Position',[0 8.5 9 6],'defaultAxesColorOrder',parula,... + 'Renderer','opengl') + % .. adjust properties + axis equal tight off; hold all; + % .. display body A + DT = delaunayTriangulation(A'); + [K,~] = convexHull(DT); + trisurf(K,DT.Points(:,1),DT.Points(:,2),DT.Points(:,3),... + 'EdgeColor','none','FaceColor',[.4 1 .9 ],... + 'FaceLighting','flat' ) + % .. display body B + DT = delaunayTriangulation(B'); + [K,~] = convexHull(DT); + trisurf(K,DT.Points(:,1),DT.Points(:,2),DT.Points(:,3),... + 'EdgeColor','none','FaceColor',[.4 1 .8 ],... + 'FaceLighting','flat' ) + % .. represent the computed distance as a sphere + [x,y,z] = sphere(100); + surf(x.*dist/2,y.*dist/2,z.*dist/2,'facecolor',[.9 .9 .9],... + 'EdgeColor','none','FaceLighting','flat','SpecularColorReflectance',0,... + 'SpecularStrength',1,'SpecularExponent',10,'facealpha',.7) + % ... adjust point of view + view(42,21) + % ... add light + light('Position',[5 -10 20],'Style','local'); +end \ No newline at end of file diff --git a/examples/matlab/runme.m b/examples/matlab/runme.m index bc1a1d1..0d7edf0 100644 --- a/examples/matlab/runme.m +++ b/examples/matlab/runme.m @@ -29,35 +29,20 @@ else optflug = '-O'; end % SELECT SILET COMPILATION MODE. -if 1 +if 1 silflag = '-silent'; else silflag = '-v'; end -% TRY COMPILING MEX FILE -fprintf('Compiling mex function... ') -try -mex(fullfile('..','..','openGJK.c'),... % Source of openGJK +% COMPILE MEX FILE +mex(fullfile('..','..','openGJK.c'),... '-largeArrayDims', ... % Support large arrays - optflug, ... % Compiler flag for debug/optimisation - fullfile('-I','..','..','include'),... % Folder to header files - '-outdir', pwd, ... % Ouput directory for writing mex function + optflug, ... + ['-I',fullfile('..','..','include')],... % Folder to header files '-output', 'openGJK',... % Name of ouput mex file '-DMATLAB_MEX_BUILD',... % Define variable for mex function in source files - silflag ) % Silent/verbose flag - - % File compiled without errors. Return path and name of mex file - fprintf('completed!\n') - fprintf('The following mex file has been generated:') - fprintf('\t%s\n',[pwd,filesep,'openGJK.',mexext]) -catch - % Build failed, refer to documentation - fprintf('\n\n ERROR DETECTED! Mex file cannot be compiled.\n') - fprintf('\tFor more information, see ') - fprintf('this documentation page.\n\n') - return -end + silflag ) % RUN EXAMPLE fprintf('Running example... ') From 108a62c7eca908bf0af64122ba7725d19d6be0f5 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 15:08:40 +0100 Subject: [PATCH 13/24] try debuggin --- .github/workflows/github-opengjk-examples.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index 6c6c591..c5bae3c 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -30,4 +30,7 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v3 + - run: pwd + - run: ls + - run: version - run: cd examples/matlab/; run runme.m From 7dae0befdf4dc0bdc5f1a986e215001e37c48a66 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 15:14:18 +0100 Subject: [PATCH 14/24] try running octave version --- .github/workflows/github-opengjk-examples.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index c5bae3c..e262b56 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -30,7 +30,6 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v3 - - run: pwd - run: ls - - run: version - - run: cd examples/matlab/; run runme.m + - run: octave --version + - run: cd examples/matlab/; octave runme.m From 92c81c3adaf715ce13eb576237b7f11cc001d193 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 15:18:11 +0100 Subject: [PATCH 15/24] Clean and break pipeline to test --- .github/workflows/github-opengjk-examples.yml | 2 -- examples/matlab/main.m | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index e262b56..51a5655 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -30,6 +30,4 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v3 - - run: ls - - run: octave --version - run: cd examples/matlab/; octave runme.m diff --git a/examples/matlab/main.m b/examples/matlab/main.m index ab555a4..d01445d 100644 --- a/examples/matlab/main.m +++ b/examples/matlab/main.m @@ -61,4 +61,6 @@ if(exist('OCTAVE_VERSION', 'builtin') == 0) view(42,21) % ... add light light('Position',[5 -10 20],'Style','local'); -end \ No newline at end of file +end + +error("DOnnnnnt do it again!") \ No newline at end of file From 7e2f6ccfb4f8f66d976c8422eb1caa40295ca47b Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 15:18:31 +0100 Subject: [PATCH 16/24] Undo breaking change --- examples/matlab/main.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/matlab/main.m b/examples/matlab/main.m index d01445d..ab555a4 100644 --- a/examples/matlab/main.m +++ b/examples/matlab/main.m @@ -61,6 +61,4 @@ if(exist('OCTAVE_VERSION', 'builtin') == 0) view(42,21) % ... add light light('Position',[5 -10 20],'Style','local'); -end - -error("DOnnnnnt do it again!") \ No newline at end of file +end \ No newline at end of file From cf0b32cd45c8713a66c9e55e25752a9d2dc96d47 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 15:49:09 +0100 Subject: [PATCH 17/24] Try Cython cI action --- .github/workflows/github-opengjk-examples.yml | 8 +++ examples/cython/pygjk_trial.py | 56 ++++++++----------- examples/cython/setup.py | 3 +- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index 51a5655..11f8bf5 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -31,3 +31,11 @@ jobs: - name: Check out repository code uses: actions/checkout@v3 - run: cd examples/matlab/; octave runme.m + + Run_CYthon_example: + runs-on: ubuntu-latest + container: mmontanari/devenv:buildenv-ubuntu + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - run: cd examples/cython/; python3 setup.py build_ext --inplace; python3 test.py diff --git a/examples/cython/pygjk_trial.py b/examples/cython/pygjk_trial.py index 3b68b7a..d0f05be 100644 --- a/examples/cython/pygjk_trial.py +++ b/examples/cython/pygjk_trial.py @@ -1,38 +1,30 @@ -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # -# ##### # # # # -# #### ##### ###### # # # # # # # # -# # # # # # ## # # # # # # -# # # # # ##### # # # # #### # ### # -# # # ##### # # # # # # # # # # # -# # # # # # ## # # # # # # # -# #### # ###### # # ##### ##### # # # -# # -# This file is part of openGJK. # -# # -# OpenGJK is free software: you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation, either version 3 of the License, or # -# any later version. # -# # -# OpenGJK is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See The # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with OpenGJK. If not, see . # -# # -# openGJK: open-source Gilbert-Johnson-Keerthi algorithm # -# Copyright (C) Mattia Montanari 2018 - 2020 # -# http://iel.eng.ox.ac.uk/?page_id=504 # -# # -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # +# _____ _ _ __ # +# / ____| | | |/ / # +# ___ _ __ ___ _ __ | | __ | | ' / # +# / _ \| '_ \ / _ \ '_ \| | |_ |_ | | < # +# | (_) | |_) | __/ | | | |__| | |__| | . \ # +# \___/| .__/ \___|_| |_|\_____|\____/|_|\_\ # +# | | # +# |_| # +# # +# Copyright 2022 Mattia Montanari, University of Oxford # +# # +# This program is free software: you can redistribute it and/or modify it under # +# the terms of the GNU General Public License as published by the Free Software # +# Foundation, either version 3 of the License. You should have received a copy # +# of the GNU General Public License along with this program. If not, visit # +# # +# https://www.gnu.org/licenses/ # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # +# FOR A PARTICULAR PURPOSE. See GNU General Public License for details. # import numpy as np import openGJK_cython as opengjk -a = np.array([[1.,1.,1.],[1.,1.,1.]]) -b = np.array([[11.,1.,1.],[1.,1.,1.]]) +a = np.array([[1.0,1.0,1.0],[1.0,1.0,1.0]]) +b = np.array([[-1.,-1.,-1.],[-1.,-1.,-1.]]) d = opengjk.pygjk(a,b) -print(d) \ No newline at end of file +print("Distance is:" , d) \ No newline at end of file diff --git a/examples/cython/setup.py b/examples/cython/setup.py index 5805e75..48f074e 100644 --- a/examples/cython/setup.py +++ b/examples/cython/setup.py @@ -34,8 +34,7 @@ from Cython.Build import cythonize exts = Extension( "openGJK_cython", sources = ["openGJK_cython.pyx"], - extra_compile_args=['-I../../include/','-fopenmp'], - extra_link_args=['-fopenmp'], + extra_compile_args=['-I../../include/'] ) setup( From 044fd566323dba9b27ebea2268df9f9dea9cbfc8 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 15:56:36 +0100 Subject: [PATCH 18/24] Fix and run tests for Cython --- .github/workflows/github-opengjk-examples.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index 11f8bf5..e2a41d3 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -32,10 +32,11 @@ jobs: uses: actions/checkout@v3 - run: cd examples/matlab/; octave runme.m - Run_CYthon_example: + Run_Cython_example: runs-on: ubuntu-latest container: mmontanari/devenv:buildenv-ubuntu steps: - name: Check out repository code uses: actions/checkout@v3 - - run: cd examples/cython/; python3 setup.py build_ext --inplace; python3 test.py + - run: cd examples/cython/ && python3 setup.py build_ext --inplace && python3 test.py + - run: cd examples/cython/ && pytest test.py From 1282d6a222be0a90f96b49093e2f6ffec496bce1 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 15:58:55 +0100 Subject: [PATCH 19/24] Clean cython and rename actions --- .github/workflows/github-opengjk-examples.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index e2a41d3..a6ced2d 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -2,7 +2,7 @@ name: Run all demos run-name: ${{ github.actor }} is running on: [push] jobs: - Run_C_example: + C: runs-on: ubuntu-latest container: mmontanari/devenv:buildenv-fedora steps: @@ -13,7 +13,7 @@ jobs: - run: cmake --build build - run: cmake -E chdir build/examples/c/ ./example_lib_opengjk_ce - Run_GO_example: + GO: runs-on: ubuntu-latest container: mmontanari/devenv:buildenv-fedora steps: @@ -24,7 +24,7 @@ jobs: go-version: 1.15 - run: cd examples/go/openGJK && go build && go test -v - Run_Octave_example: + Octave: runs-on: ubuntu-latest container: gnuoctave/octave:7.3.0 steps: @@ -32,11 +32,11 @@ jobs: uses: actions/checkout@v3 - run: cd examples/matlab/; octave runme.m - Run_Cython_example: + Cython: runs-on: ubuntu-latest container: mmontanari/devenv:buildenv-ubuntu steps: - name: Check out repository code uses: actions/checkout@v3 - - run: cd examples/cython/ && python3 setup.py build_ext --inplace && python3 test.py + - run: cd examples/cython/ && python3 setup.py build_ext --inplace && python3 pygjk_trial.py - run: cd examples/cython/ && pytest test.py From aa4d543e99f8eee63a4264f39ef3ad1ddf9d7611 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 17:16:19 +0100 Subject: [PATCH 20/24] Major changes: build static and dyn library. the first is for C example, the latter for CS example. The CS example is also ran in the action --- .github/workflows/github-opengjk-examples.yml | 29 +++++++++++++------ CMakeLists.txt | 29 ++++++++++++------- examples/c/CMakeLists.txt | 6 ++-- examples/cs/main.cs | 14 +++++---- 4 files changed, 50 insertions(+), 28 deletions(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index a6ced2d..d3bcc71 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -13,6 +13,26 @@ jobs: - run: cmake --build build - run: cmake -E chdir build/examples/c/ ./example_lib_opengjk_ce + Cython: + runs-on: ubuntu-latest + container: mmontanari/devenv:buildenv-ubuntu + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - run: cd examples/cython/ && python3 setup.py build_ext --inplace && python3 pygjk_trial.py + - run: cd examples/cython/ && pytest test.py + + CSharp: + runs-on: ubuntu-latest + container: mmontanari/devenv:mono:latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - run: apt-get update && apt-get install gcc cmake -y + - run: cmake -E make_directory build + - run: cmake -E chdir build cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_MONO=ON .. + - run: cd examples/cs/ && mcs -out:main.exe main.cs && mono main.exe + GO: runs-on: ubuntu-latest container: mmontanari/devenv:buildenv-fedora @@ -31,12 +51,3 @@ jobs: - name: Check out repository code uses: actions/checkout@v3 - run: cd examples/matlab/; octave runme.m - - Cython: - runs-on: ubuntu-latest - container: mmontanari/devenv:buildenv-ubuntu - steps: - - name: Check out repository code - uses: actions/checkout@v3 - - run: cd examples/cython/ && python3 setup.py build_ext --inplace && python3 pygjk_trial.py - - run: cd examples/cython/ && pytest test.py diff --git a/CMakeLists.txt b/CMakeLists.txt index b243977..8c5e8d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,15 +21,16 @@ # FOR A PARTICULAR PURPOSE. See GNU General Public License for details. # # User options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -option(BUILD_EXAMPLE "Build demo" ON) +option(BUILD_EXAMPLE "Build demo" ON ) +option(BUILD_MONO "Build C# example" OFF) # CMake setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cmake_minimum_required(VERSION 3.0) # You can downgrade to 2.8, but I don't maintain it anymore cmake_policy(SET CMP0048 NEW) cmake_policy(SET CMP0063 NEW) # Visibility of preset and hidden lines on shared libs -set( CMAKE_C_VISIBILITY_PRESET hidden) -set( CMAKE_VISIBILITY_INLINES_HIDDEN TRUE) +# set( CMAKE_C_VISIBILITY_PRESET hidden) +set( CMAKE_VISIBILITY_INLINES_HIDDEN FALSE) set( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Project setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @@ -58,26 +59,34 @@ elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC") endif() # Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -add_library( ${PROJECT_NAME} - STATIC + +if(BUILD_MONO) + add_compile_definitions(CS_MONO_BUILD) +endif(BUILD_MONO) + +add_library( obj_openGJK + OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/openGJK.c ${CMAKE_CURRENT_SOURCE_DIR}/include/openGJK/openGJK.h ) -target_include_directories( ${PROJECT_NAME} +target_include_directories( obj_openGJK PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR} ) -target_link_libraries(${PROJECT_NAME} PRIVATE m) +target_link_libraries(obj_openGJK PRIVATE m) -set_target_properties(${PROJECT_NAME} +set_target_properties(obj_openGJK PROPERTIES C_STANDARD 11 PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/openGJK/openGJK.h + POSITION_INDEPENDENT_CODE 1 ) +add_library(opengjk_ce SHARED $) + # Build demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . if(BUILD_EXAMPLE) add_subdirectory(examples/c) @@ -85,11 +94,11 @@ endif(BUILD_EXAMPLE) # Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . if (UNIX) - install(TARGETS ${PROJECT_NAME} PERMISSIONS WORLD_WRITE ) set(DESTDIR "/usr") - INSTALL(TARGETS ${PROJECT_NAME} + INSTALL(TARGETS opengjk_ce LIBRARY DESTINATION "${DESTDIR}/lib" PUBLIC_HEADER DESTINATION "${DESTDIR}/include" + PERMISSIONS WORLD_WRITE ) endif (UNIX) diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt index c599e74..10fac5a 100644 --- a/examples/c/CMakeLists.txt +++ b/examples/c/CMakeLists.txt @@ -25,12 +25,12 @@ project(example_lib_opengjk_ce VERSION 1.0.0 ) -add_executable(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/main.c) -target_link_libraries(${PROJECT_NAME} lib_opengjk_ce) +add_executable(example_lib_opengjk_ce ${CMAKE_CURRENT_SOURCE_DIR}/main.c) +target_link_libraries(example_lib_opengjk_ce obj_openGJK m) # Copy input files for this example after build add_custom_command( - TARGET ${PROJECT_NAME} POST_BUILD + TARGET example_lib_opengjk_ce POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/userP.dat ${CMAKE_CURRENT_BINARY_DIR}/userP.dat diff --git a/examples/cs/main.cs b/examples/cs/main.cs index 8be1370..5cb1023 100644 --- a/examples/cs/main.cs +++ b/examples/cs/main.cs @@ -34,10 +34,13 @@ using System.Runtime.InteropServices; public class Tester { - - [DllImport("libopenGJKlib", EntryPoint="csFunction", CallingConvention = CallingConvention.StdCall)] +#if UNIX + [DllImport("libopengjk_ce.so", EntryPoint="csFunction", CallingConvention = CallingConvention.StdCall)] +#else + [DllImport("libopengjk_ce", EntryPoint = "csFunction", CallingConvention = CallingConvention.StdCall)] +#endif - static extern double gjk(int na, double [,] ia, int nb, double [,] ib); + static extern double compute_minimum_distance(int na, double [,] ia, int nb, double [,] ib); public static void Main(string[] args) { @@ -51,13 +54,12 @@ public class Tester var inCoordsB = new double[3,9] { {-0.0 , -2.3 , -8.1 , -4.3 ,-2.5 , -7.1 , -1.0 , -3.3 , -6.0} , { -5.5 , -1.0 ,- 4.0 ,- 5.0 ,-1.0, -1.0, -1.5, -0.5 , -1.4} ,{ -0.0 , 2.0, -2.4, -2.2, -2.3 , -2.4 , -0.3 , -0.3 , -0.2} }; // Invoke GJK to compute distance - dist = gjk( nCoordsA, inCoordsA, nCoordsB, inCoordsB ); + dist = compute_minimum_distance( nCoordsA, inCoordsA, nCoordsB, inCoordsB ); // Output results var s = string.Format("{0:0.##}", dist); var message = string.Format("The distance between {0} is {1}","A and B",s); Console.WriteLine(message); - Console.WriteLine("Press any key to exit"); - Console.ReadLine(); + } } From 0c489734b70c37da2669b16fbe65dd8e1f333c1f Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 17:17:17 +0100 Subject: [PATCH 21/24] Typoe in container --- .github/workflows/github-opengjk-examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index d3bcc71..471e1fb 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -24,7 +24,7 @@ jobs: CSharp: runs-on: ubuntu-latest - container: mmontanari/devenv:mono:latest + container: mono:latest steps: - name: Check out repository code uses: actions/checkout@v3 From deba3c2d17dad1d849dc351c77aefe08a672a868 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 17:21:11 +0100 Subject: [PATCH 22/24] install opengjk --- .github/workflows/github-opengjk-examples.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index 471e1fb..9a75e83 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -31,6 +31,7 @@ jobs: - run: apt-get update && apt-get install gcc cmake -y - run: cmake -E make_directory build - run: cmake -E chdir build cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_MONO=ON .. + - run: cmake --install build - run: cd examples/cs/ && mcs -out:main.exe main.cs && mono main.exe GO: From e8d9b88f7fb26e5d8a572f9aae02069a5437ec1d Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 17:22:57 +0100 Subject: [PATCH 23/24] xplicit build.. --- .github/workflows/github-opengjk-examples.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index 9a75e83..9125476 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -31,6 +31,7 @@ jobs: - run: apt-get update && apt-get install gcc cmake -y - run: cmake -E make_directory build - run: cmake -E chdir build cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_MONO=ON .. + - run: cmake --build build - run: cmake --install build - run: cd examples/cs/ && mcs -out:main.exe main.cs && mono main.exe From b382c78d448ed3ef75e7aec65330011cb2b8c2fb Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 17:26:10 +0100 Subject: [PATCH 24/24] not great solution --- .github/workflows/github-opengjk-examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-opengjk-examples.yml b/.github/workflows/github-opengjk-examples.yml index 9125476..32336b5 100644 --- a/.github/workflows/github-opengjk-examples.yml +++ b/.github/workflows/github-opengjk-examples.yml @@ -32,7 +32,7 @@ jobs: - run: cmake -E make_directory build - run: cmake -E chdir build cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_MONO=ON .. - run: cmake --build build - - run: cmake --install build + - run: cmake -E chdir build make install - run: cd examples/cs/ && mcs -out:main.exe main.cs && mono main.exe GO: