Merge pull request #40 from MattiaMontanari/add_github_action
Add github actions to run examplesfixes-turtlebasket
commit
f9b1f94d52
|
@ -0,0 +1,55 @@
|
||||||
|
name: Run all demos
|
||||||
|
run-name: ${{ github.actor }} is running
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
C:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: mmontanari/devenv:buildenv-fedora
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- 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
|
||||||
|
|
||||||
|
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: 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: cmake --build build
|
||||||
|
- run: cmake -E chdir build make install
|
||||||
|
- run: cd examples/cs/ && mcs -out:main.exe main.cs && mono main.exe
|
||||||
|
|
||||||
|
GO:
|
||||||
|
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 && go build && go test -v
|
||||||
|
|
||||||
|
Octave:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: gnuoctave/octave:7.3.0
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- run: cd examples/matlab/; octave runme.m
|
|
@ -21,15 +21,16 @@
|
||||||
# FOR A PARTICULAR PURPOSE. See GNU General Public License for details. #
|
# FOR A PARTICULAR PURPOSE. See GNU General Public License for details. #
|
||||||
|
|
||||||
# User options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
# User options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||||
option(BUILD_EXAMPLE "Build demo" ON)
|
option(BUILD_EXAMPLE "Build demo" ON )
|
||||||
|
option(BUILD_MONO "Build C# example" OFF)
|
||||||
|
|
||||||
# CMake setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
# CMake setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||||
cmake_minimum_required(VERSION 3.0) # You can downgrade to 2.8, but I don't maintain it anymore
|
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 CMP0048 NEW)
|
||||||
cmake_policy(SET CMP0063 NEW) # Visibility of preset and hidden lines on shared libs
|
cmake_policy(SET CMP0063 NEW) # Visibility of preset and hidden lines on shared libs
|
||||||
|
|
||||||
set( CMAKE_C_VISIBILITY_PRESET hidden)
|
# set( CMAKE_C_VISIBILITY_PRESET hidden)
|
||||||
set( CMAKE_VISIBILITY_INLINES_HIDDEN TRUE)
|
set( CMAKE_VISIBILITY_INLINES_HIDDEN FALSE)
|
||||||
set( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
set( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||||
|
|
||||||
# Project setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
# Project setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||||
|
@ -58,26 +59,34 @@ elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
# 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}/openGJK.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include/openGJK/openGJK.h
|
${CMAKE_CURRENT_SOURCE_DIR}/include/openGJK/openGJK.h
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories( ${PROJECT_NAME}
|
target_include_directories( obj_openGJK
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${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
|
PROPERTIES
|
||||||
C_STANDARD 11
|
C_STANDARD 11
|
||||||
PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/openGJK/openGJK.h
|
PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/openGJK/openGJK.h
|
||||||
|
POSITION_INDEPENDENT_CODE 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_library(opengjk_ce SHARED $<TARGET_OBJECTS:obj_openGJK>)
|
||||||
|
|
||||||
# Build demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
# Build demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||||
if(BUILD_EXAMPLE)
|
if(BUILD_EXAMPLE)
|
||||||
add_subdirectory(examples/c)
|
add_subdirectory(examples/c)
|
||||||
|
@ -85,11 +94,11 @@ endif(BUILD_EXAMPLE)
|
||||||
|
|
||||||
# Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
# Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
install(TARGETS ${PROJECT_NAME} PERMISSIONS WORLD_WRITE )
|
|
||||||
set(DESTDIR "/usr")
|
set(DESTDIR "/usr")
|
||||||
INSTALL(TARGETS ${PROJECT_NAME}
|
INSTALL(TARGETS opengjk_ce
|
||||||
LIBRARY DESTINATION "${DESTDIR}/lib"
|
LIBRARY DESTINATION "${DESTDIR}/lib"
|
||||||
PUBLIC_HEADER DESTINATION "${DESTDIR}/include"
|
PUBLIC_HEADER DESTINATION "${DESTDIR}/include"
|
||||||
|
PERMISSIONS WORLD_WRITE
|
||||||
)
|
)
|
||||||
endif (UNIX)
|
endif (UNIX)
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,12 @@ project(example_lib_opengjk_ce
|
||||||
VERSION 1.0.0
|
VERSION 1.0.0
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/main.c)
|
add_executable(example_lib_opengjk_ce ${CMAKE_CURRENT_SOURCE_DIR}/main.c)
|
||||||
target_link_libraries(${PROJECT_NAME} lib_opengjk_ce)
|
target_link_libraries(example_lib_opengjk_ce obj_openGJK m)
|
||||||
|
|
||||||
# Copy input files for this example after build
|
# Copy input files for this example after build
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET ${PROJECT_NAME} POST_BUILD
|
TARGET example_lib_opengjk_ce POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy
|
COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/userP.dat
|
${CMAKE_CURRENT_SOURCE_DIR}/userP.dat
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/userP.dat
|
${CMAKE_CURRENT_BINARY_DIR}/userP.dat
|
||||||
|
|
|
@ -34,10 +34,13 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
public class Tester
|
public class Tester
|
||||||
{
|
{
|
||||||
|
#if UNIX
|
||||||
[DllImport("libopenGJKlib", EntryPoint="csFunction", CallingConvention = CallingConvention.StdCall)]
|
[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)
|
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} };
|
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
|
// Invoke GJK to compute distance
|
||||||
dist = gjk( nCoordsA, inCoordsA, nCoordsB, inCoordsB );
|
dist = compute_minimum_distance( nCoordsA, inCoordsA, nCoordsB, inCoordsB );
|
||||||
|
|
||||||
// Output results
|
// Output results
|
||||||
var s = string.Format("{0:0.##}", dist);
|
var s = string.Format("{0:0.##}", dist);
|
||||||
var message = string.Format("The distance between {0} is {1}","A and B",s);
|
var message = string.Format("The distance between {0} is {1}","A and B",s);
|
||||||
Console.WriteLine(message);
|
Console.WriteLine(message);
|
||||||
Console.WriteLine("Press any key to exit");
|
|
||||||
Console.ReadLine();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,30 @@
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
# _____ _ _ __ #
|
||||||
# ##### # # # #
|
# / ____| | | |/ / #
|
||||||
# #### ##### ###### # # # # # # # #
|
# ___ _ __ ___ _ __ | | __ | | ' / #
|
||||||
# # # # # # ## # # # # # #
|
# / _ \| '_ \ / _ \ '_ \| | |_ |_ | | < #
|
||||||
# # # # # ##### # # # # #### # ### #
|
# | (_) | |_) | __/ | | | |__| | |__| | . \ #
|
||||||
# # # ##### # # # # # # # # # # #
|
# \___/| .__/ \___|_| |_|\_____|\____/|_|\_\ #
|
||||||
# # # # # # ## # # # # # # #
|
# | | #
|
||||||
# #### # ###### # # ##### ##### # # #
|
# |_| #
|
||||||
# #
|
# #
|
||||||
# This file is part of openGJK. #
|
# Copyright 2022 Mattia Montanari, University of Oxford #
|
||||||
# #
|
# #
|
||||||
# OpenGJK is free software: you can redistribute it and/or modify #
|
# This program is free software: you can redistribute it and/or modify it under #
|
||||||
# it under the terms of the GNU General Public License as published by #
|
# the terms of the GNU General Public License as published by the Free Software #
|
||||||
# the Free Software Foundation, either version 3 of the License, or #
|
# Foundation, either version 3 of the License. You should have received a copy #
|
||||||
# any later version. #
|
# of the GNU General Public License along with this program. If not, visit #
|
||||||
# #
|
# #
|
||||||
# OpenGJK is distributed in the hope that it will be useful, #
|
# https://www.gnu.org/licenses/ #
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
# #
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See The #
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||||
# GNU General Public License for more details. #
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
|
||||||
# #
|
# FOR A PARTICULAR PURPOSE. See GNU General Public License for details. #
|
||||||
# You should have received a copy of the GNU General Public License #
|
|
||||||
# along with OpenGJK. If not, see <https://www.gnu.org/licenses/>. #
|
|
||||||
# #
|
|
||||||
# openGJK: open-source Gilbert-Johnson-Keerthi algorithm #
|
|
||||||
# Copyright (C) Mattia Montanari 2018 - 2020 #
|
|
||||||
# http://iel.eng.ox.ac.uk/?page_id=504 #
|
|
||||||
# #
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import openGJK_cython as opengjk
|
import openGJK_cython as opengjk
|
||||||
|
|
||||||
a = np.array([[1.,1.,1.],[1.,1.,1.]])
|
a = np.array([[1.0,1.0,1.0],[1.0,1.0,1.0]])
|
||||||
b = np.array([[11.,1.,1.],[1.,1.,1.]])
|
b = np.array([[-1.,-1.,-1.],[-1.,-1.,-1.]])
|
||||||
d = opengjk.pygjk(a,b)
|
d = opengjk.pygjk(a,b)
|
||||||
|
|
||||||
print(d)
|
print("Distance is:" , d)
|
|
@ -34,8 +34,7 @@ from Cython.Build import cythonize
|
||||||
exts = Extension(
|
exts = Extension(
|
||||||
"openGJK_cython",
|
"openGJK_cython",
|
||||||
sources = ["openGJK_cython.pyx"],
|
sources = ["openGJK_cython.pyx"],
|
||||||
extra_compile_args=['-I../../include/','-fopenmp'],
|
extra_compile_args=['-I../../include/']
|
||||||
extra_link_args=['-fopenmp'],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|
|
@ -32,31 +32,33 @@ B = -A;
|
||||||
dist = openGJK( A, B );
|
dist = openGJK( A, B );
|
||||||
fprintf('The minimum distance between A and B is %.2f\n',dist);
|
fprintf('The minimum distance between A and B is %.2f\n',dist);
|
||||||
|
|
||||||
% VISUALISE RESULTS
|
% VISUALISE RESULTS ONLY IN MATLAB
|
||||||
% .. create new figure
|
if(exist('OCTAVE_VERSION', 'builtin') == 0)
|
||||||
figure('units','centimeters', 'WindowStyle','normal', 'color','w',...
|
% .. create new figure
|
||||||
'Position',[0 8.5 9 6],'defaultAxesColorOrder',parula,...
|
figure('units','centimeters', 'WindowStyle','normal', 'color','w',...
|
||||||
'Renderer','opengl')
|
'Position',[0 8.5 9 6],'defaultAxesColorOrder',parula,...
|
||||||
% .. adjust properties
|
'Renderer','opengl')
|
||||||
axis equal tight off; hold all;
|
% .. adjust properties
|
||||||
% .. display body A
|
axis equal tight off; hold all;
|
||||||
DT = delaunayTriangulation(A');
|
% .. display body A
|
||||||
[K,~] = convexHull(DT);
|
DT = delaunayTriangulation(A');
|
||||||
trisurf(K,DT.Points(:,1),DT.Points(:,2),DT.Points(:,3),...
|
[K,~] = convexHull(DT);
|
||||||
'EdgeColor','none','FaceColor',[.4 1 .9 ],...
|
trisurf(K,DT.Points(:,1),DT.Points(:,2),DT.Points(:,3),...
|
||||||
'FaceLighting','flat' )
|
'EdgeColor','none','FaceColor',[.4 1 .9 ],...
|
||||||
% .. display body B
|
'FaceLighting','flat' )
|
||||||
DT = delaunayTriangulation(B');
|
% .. display body B
|
||||||
[K,~] = convexHull(DT);
|
DT = delaunayTriangulation(B');
|
||||||
trisurf(K,DT.Points(:,1),DT.Points(:,2),DT.Points(:,3),...
|
[K,~] = convexHull(DT);
|
||||||
'EdgeColor','none','FaceColor',[.4 1 .8 ],...
|
trisurf(K,DT.Points(:,1),DT.Points(:,2),DT.Points(:,3),...
|
||||||
'FaceLighting','flat' )
|
'EdgeColor','none','FaceColor',[.4 1 .8 ],...
|
||||||
% .. represent the computed distance as a sphere
|
'FaceLighting','flat' )
|
||||||
[x,y,z] = sphere(100);
|
% .. represent the computed distance as a sphere
|
||||||
surf(x.*dist/2,y.*dist/2,z.*dist/2,'facecolor',[.9 .9 .9],...
|
[x,y,z] = sphere(100);
|
||||||
'EdgeColor','none','FaceLighting','flat','SpecularColorReflectance',0,...
|
surf(x.*dist/2,y.*dist/2,z.*dist/2,'facecolor',[.9 .9 .9],...
|
||||||
'SpecularStrength',1,'SpecularExponent',10,'facealpha',.7)
|
'EdgeColor','none','FaceLighting','flat','SpecularColorReflectance',0,...
|
||||||
% ... adjust point of view
|
'SpecularStrength',1,'SpecularExponent',10,'facealpha',.7)
|
||||||
view(42,21)
|
% ... adjust point of view
|
||||||
% ... add light
|
view(42,21)
|
||||||
light('Position',[5 -10 20],'Style','local');
|
% ... add light
|
||||||
|
light('Position',[5 -10 20],'Style','local');
|
||||||
|
end
|
|
@ -29,35 +29,20 @@ else
|
||||||
optflug = '-O';
|
optflug = '-O';
|
||||||
end
|
end
|
||||||
% SELECT SILET COMPILATION MODE.
|
% SELECT SILET COMPILATION MODE.
|
||||||
if 1
|
if 1
|
||||||
silflag = '-silent';
|
silflag = '-silent';
|
||||||
else
|
else
|
||||||
silflag = '-v';
|
silflag = '-v';
|
||||||
end
|
end
|
||||||
|
|
||||||
% TRY COMPILING MEX FILE
|
% COMPILE MEX FILE
|
||||||
fprintf('Compiling mex function... ')
|
mex(fullfile('..','..','openGJK.c'),...
|
||||||
try
|
|
||||||
mex(fullfile('..','..','openGJK.c'),... % Source of openGJK
|
|
||||||
'-largeArrayDims', ... % Support large arrays
|
'-largeArrayDims', ... % Support large arrays
|
||||||
optflug, ... % Compiler flag for debug/optimisation
|
optflug, ...
|
||||||
fullfile('-I','..','..','include'),... % Folder to header files
|
['-I',fullfile('..','..','include')],... % Folder to header files
|
||||||
'-outdir', pwd, ... % Ouput directory for writing mex function
|
|
||||||
'-output', 'openGJK',... % Name of ouput mex file
|
'-output', 'openGJK',... % Name of ouput mex file
|
||||||
'-DMATLAB_MEX_BUILD',... % Define variable for mex function in source files
|
'-DMATLAB_MEX_BUILD',... % Define variable for mex function in source files
|
||||||
silflag ) % Silent/verbose flag
|
silflag )
|
||||||
|
|
||||||
% 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('<a href="http://www.mathworks.com/help/matlab/ref/mex.html">this documentation page</a>.\n\n')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
% RUN EXAMPLE
|
% RUN EXAMPLE
|
||||||
fprintf('Running example... ')
|
fprintf('Running example... ')
|
||||||
|
|
Loading…
Reference in New Issue