Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
# Set the build type. Options are:
# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage
# Debug : w/ debug symbols, w/o optimization
# Release : w/o debug symbols, w/ optimization
# RelWithDebInfo : w/ debug symbols, w/ optimization
# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)
rosbuild_init()
#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
#uncomment if you have defined messages
#rosbuild_genmsg()
#uncomment if you have defined services
#rosbuild_gensrv()
#common commands for building c++ executables and libraries
#rosbuild_add_library(${PROJECT_NAME} src/example.cpp)
#target_link_libraries(${PROJECT_NAME} another_library)
#rosbuild_add_boost_directories()
#rosbuild_link_boost(${PROJECT_NAME} thread)
#rosbuild_add_executable(example examples/example.cpp)
#target_link_libraries(example ${PROJECT_NAME})
#rosbuild_add_rostest(test/urdf.test)
# mesh file generations
rosbuild_find_ros_package(ivcon)
rosbuild_find_ros_package(convex_decomposition)
# iterate through all the stl files to:
# 1. convert to *.iv files
# 2. generate convex decomposed .stl
file(GLOB cob_stl_files ${CMAKE_CURRENT_SOURCE_DIR}/meshes/*/*.stl)
set(cob_gen_files "")
foreach(it ${cob_stl_files})
get_filename_component(basepath ${it} PATH)
get_filename_component(basename ${it} NAME_WE)
IF ( ${basename} MATCHES "_convex" )
message("ignoring stale .._convex.stl file:",${basename})
ELSE ( ${basename} MATCHES "_convex" )
# create subdirectory convex
add_custom_command(
OUTPUT ${basepath}/convex
# CMake 2.4 doesn't offer the make_directory command.
#COMMAND ${CMAKE_COMMAND} -E make_directory
COMMAND mkdir -p
ARGS ${basepath}/convex)
# create subdirectory iv
add_custom_command(
OUTPUT ${basepath}/iv
# CMake 2.4 doesn't offer the make_directory command.
#COMMAND ${CMAKE_COMMAND} -E make_directory
COMMAND mkdir -p
ARGS ${basepath}/iv)
#create obj files for convex decomposition from stl files
add_custom_command(
OUTPUT ${basepath}/convex/${basename}.obj
COMMAND ivcon
ARGS ${it} ${basepath}/convex/${basename}.obj
DEPENDS ${it} ${basepath}/convex)
set(cob_gen_files ${cob_gen_files} ${basepath}/convex/${basename}.obj)
#convex decompose object files
add_custom_command(
OUTPUT ${basepath}/convex/${basename}_convex.obj
COMMAND convex_decomposition
ARGS ${basepath}/convex/${basename}.obj -v12 -p10
DEPENDS ${basepath}/convex/${basename}.obj ${basepath}/convex)
set(cob_gen_files ${cob_gen_files} ${basepath}/convex/${basename}_convex.obj)
#convert obj files back to stlb, put in directory named convex
add_custom_command(
OUTPUT ${basepath}/convex/${basename}_convex.stlb
COMMAND ivcon
ARGS ${basepath}/convex/${basename}_convex.obj ${basepath}/convex/${basename}_convex.stlb
DEPENDS ${it} ${basepath}/convex ${basepath}/convex/${basename}_convex.obj)
set(cob_gen_files ${cob_gen_files} ${basepath}/convex/${basename}_convex.stlb)
#convert obj files back to stla, put in directory named convex
add_custom_command(
OUTPUT ${basepath}/convex/${basename}_convex.stla
COMMAND ivcon
ARGS ${basepath}/convex/${basename}_convex.obj ${basepath}/convex/${basename}_convex.stla
DEPENDS ${it} ${basepath}/convex ${basepath}/convex/${basename}_convex.obj)
set(cob_gen_files ${cob_gen_files} ${basepath}/convex/${basename}_convex.stla)
#create iv files
add_custom_command(
OUTPUT ${basepath}/iv/${basename}.iv
COMMAND ivcon
ARGS ${it} ${basepath}/iv/${basename}.iv
DEPENDS ${basepath}/iv ${it})
add_custom_command(
OUTPUT ${basepath}/convex/${basename}_convex.iv
COMMAND ivcon
ARGS ${basepath}/convex/${basename}_convex.obj ${basepath}/convex/${basename}_convex.iv
DEPENDS ${it} ${basepath}/convex ${basepath}/convex/${basename}_convex.obj)
set(cob_gen_files ${cob_gen_files} ${basepath}/iv/${basename}.iv ${basepath}/convex/${basename}_convex.iv)
ENDIF ( ${basename} MATCHES "_convex" )
endforeach(it)
add_custom_target(media_files ALL DEPENDS ${cob_gen_files})
#TODO; stop bin and lib from being generated