From 9876960d08533b60286cb3834cf883d93ad7dc36 Mon Sep 17 00:00:00 2001 From: Mattia Montanari Date: Tue, 14 Feb 2023 15:05:20 +0100 Subject: [PATCH] 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... ')