forked from gergondet/panda_cnoid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
141 lines (122 loc) · 6.22 KB
/
CMakeLists.txt
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
130
131
132
133
134
135
136
137
138
139
140
141
cmake_minimum_required(VERSION 3.1)
# Disable in-source builds
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "This project doesn't support in-source builds")
endif()
project(panda_cnoid)
find_package(mc_rtc REQUIRED)
find_package(choreonoid QUIET)
find_description_package(franka_gazebo REQUIRED)
if(choreonoid_FOUND)
find_package(PkgConfig REQUIRED)
pkg_check_modules(OPENHRP REQUIRED openhrp3.1)
pkg_check_modules(HRPSYS_BASE REQUIRED hrpsys-base)
endif()
find_program(XACRO xacro)
if("${XACRO}" STREQUAL "XACRO-NOTFOUND")
message(FATAL_ERROR "Could not find xacro in your environment")
endif()
set(MODEL_DESTINATION "${OPENHRP_PREFIX}/share/OpenHRP-3.1/robot/panda")
if(choreonoid_FOUND)
# Install the VRML model
install(DIRECTORY model/panda/
DESTINATION ${MODEL_DESTINATION}
FILES_MATCHING PATTERN "*.wrl")
endif()
set(URDF_DESTINATION "${CMAKE_INSTALL_PREFIX}/share/panda_cnoid/")
set(CONVEX_DESTINATION "${URDF_DESTINATION}/convex")
set(MESHES_DESTINATION "${URDF_DESTINATION}/meshes/")
macro(GENERATE_ROBOT XACRO_IN ROBOT_IN)
# Generate a xacro file and the associated urdf
get_filename_component(XACRO_OUT "${XACRO_IN}" NAME)
set(XACRO_OUT "${CMAKE_BINARY_DIR}/xacro/${XACRO_OUT}")
configure_file("${XACRO_IN}" "${XACRO_OUT}" @ONLY)
get_filename_component(NAME "${XACRO_OUT}" NAME_WE)
set(URDF_OUT "${CMAKE_BINARY_DIR}/urdf/${NAME}.urdf")
set(URDF_DEPENDS "${XACRO_OUT}")
set(EXTRA_DEPENDS "${ARGN}")
foreach(EXTRA IN LISTS EXTRA_DEPENDS)
list(APPEND URDF_DEPENDS "${EXTRA}")
endforeach()
add_custom_command(OUTPUT "${URDF_OUT}" COMMAND ${XACRO} -i "${XACRO_OUT}" -o "${URDF_OUT}" DEPENDS ${URDF_DEPENDS})
add_custom_target(generate_${NAME}_urdf ALL DEPENDS ${URDF_OUT})
install(FILES "${URDF_OUT}" DESTINATION "${URDF_DESTINATION}")
# Create and install a YAML RobotModule
set(MODULE_IN "module/${ROBOT_IN}.yaml")
set(MODULE_OUT "${CMAKE_BINARY_DIR}/${MODULE_IN}")
configure_file(${MODULE_IN} "${MODULE_OUT}")
install(FILES "${MODULE_OUT}" DESTINATION "${URDF_DESTINATION}")
# Create and install an aliase
set(ALIASE_IN "module/aliase/${ROBOT_IN}.yaml")
set(ALIASE_OUT "${CMAKE_BINARY_DIR}/${ALIASE_IN}")
configure_file(${ALIASE_IN} "${ALIASE_OUT}")
install(FILES "${ALIASE_OUT}" DESTINATION "${MC_ROBOTS_ALIASES_DIRECTORY}")
endmacro()
configure_file("xacro/main.xacro" "${CMAKE_BINARY_DIR}/xacro/main.xacro" @ONLY)
configure_file("xacro/main.gazebo.xacro" "${CMAKE_BINARY_DIR}/xacro/main.gazebo.xacro" @ONLY)
configure_file("xacro/pandaA.xacro" "${CMAKE_BINARY_DIR}/xacro/pandaA.xacro" @ONLY)
configure_file("xacro/pandaA.gazebo.xacro" "${CMAKE_BINARY_DIR}/xacro/pandaA.gazebo.xacro" @ONLY)
configure_file("xacro/pandaB.xacro" "${CMAKE_BINARY_DIR}/xacro/pandaB.xacro" @ONLY)
configure_file("xacro/pandaB.gazebo.xacro" "${CMAKE_BINARY_DIR}/xacro/pandaB.gazebo.xacro" @ONLY)
configure_file("xacro/foot.xacro" "${CMAKE_BINARY_DIR}/xacro/foot.xacro" @ONLY)
configure_file("xacro/pump.xacro" "${CMAKE_BINARY_DIR}/xacro/pump.xacro" @ONLY)
install(FILES xacro/meshes/foot.stl DESTINATION "${MESHES_DESTINATION}")
install(FILES xacro/meshes/pump.stl DESTINATION "${MESHES_DESTINATION}")
# panda robot without any end-effector
#GENERATE_ROBOT("${FRANKA_GAZEBO_PATH}/robots/panda.urdf.xacro" "panda_default")
GENERATE_ROBOT("xacro/panda_default.urdf.xacro" "panda_default")
# panda robot with a two-finger gripper "hand" as end-effector
#GENERATE_ROBOT("${FRANKA_GAZEBO_PATH}/robots/panda_hand.urdf.xacro" "panda_hand")
GENERATE_ROBOT("xacro/panda_hand.urdf.xacro" "panda_hand")
# panda robot with a flat "foot" as end-effector
GENERATE_ROBOT("xacro/panda_foot.urdf.xacro" "panda_foot") # "${CMAKE_BINARY_DIR}/xacro/foot.xacro"
# panda robot with a suction cup "pump" as end-effector
GENERATE_ROBOT("xacro/panda_pump.urdf.xacro" "panda_pump") # "${CMAKE_BINARY_DIR}/xacro/pump.xacro"
# two panda robots without any end-effector
GENERATE_ROBOT("xacro/doublepanda_default.urdf.xacro" "doublepanda_default")
# Install convex
install(DIRECTORY convex DESTINATION "${URDF_DESTINATION}" FILES_MATCHING PATTERN "*-ch.txt")
# Install rsdf
install(DIRECTORY rsdf DESTINATION "${URDF_DESTINATION}" FILES_MATCHING PATTERN "*.rsdf")
macro(GENERATE_CNOID_PROJECT PROJECT_FOLDER WRL_NAME)
set(PROJECT_DESTINATION "${HRPSYS_BASE_PREFIX}/share/hrpsys/samples/${PROJECT_FOLDER}")
set(MODEL_OUT "${MODEL_DESTINATION}/${WRL_NAME}.wrl")
file(READ cnoid/${PROJECT_FOLDER}/joint_positions.cnoid JOINT_POSITIONS)
string(STRIP "${JOINT_POSITIONS}" JOINT_POSITIONS)
set(USE_UDP False)
set(SIM_SCRIPT sim_mc.py)
set(ROBOT_NAME "${PROJECT_FOLDER}")
set(SENSOR_PORT_A "LeftHandForceSensor")
set(SENSOR_PORT_B "RightHandForceSensor")
set(CONF_FILE_NAME "Virtual-${PROJECT_FOLDER}-RTC.conf")
install(FILES "cnoid/${PROJECT_FOLDER}/Virtual-${PROJECT_FOLDER}-RTC.conf" DESTINATION "${CHOREONOID_PLUGIN_DIR}/rtc/")
set(PROJECT_FILES
cnoid/common/clear-omninames.sh
cnoid/common/robot.conf
cnoid/common/rtc.conf.choreonoid
cnoid/common/sim_mc.cnoid
cnoid/common/sim_mc_withTable.cnoid
cnoid/${PROJECT_FOLDER}/sim_mc.py
cnoid/${PROJECT_FOLDER}/PDcontroller.conf.choreonoid
cnoid/${PROJECT_FOLDER}/PDgains_sim.dat
)
foreach(F ${PROJECT_FILES})
get_filename_component(F_NAME "${F}" NAME)
configure_file(${F} "${CMAKE_BINARY_DIR}/cnoid/${PROJECT_FOLDER}/${F_NAME}" @ONLY)
endforeach()
set(USE_UDP True)
set(SIM_SCRIPT sim_mc_udp.py)
set(SENSOR_PORT "lhsensor")
configure_file(cnoid/${PROJECT_FOLDER}/sim_mc.py "${CMAKE_BINARY_DIR}/cnoid/${PROJECT_FOLDER}/${SIM_SCRIPT}" @ONLY)
configure_file(cnoid/common/sim_mc.cnoid "${CMAKE_BINARY_DIR}/cnoid/${PROJECT_FOLDER}/sim_mc_udp.cnoid" @ONLY)
configure_file(cnoid/common/sim_mc_withTable.cnoid "${CMAKE_BINARY_DIR}/cnoid/${PROJECT_FOLDER}/sim_mc_udp.cnoid" @ONLY)
install(DIRECTORY "${CMAKE_BINARY_DIR}/cnoid/${PROJECT_FOLDER}/" DESTINATION "${PROJECT_DESTINATION}")
install(PROGRAMS cnoid/common/clear-omninames.sh DESTINATION "${PROJECT_DESTINATION}")
endmacro()
if(choreonoid_FOUND)
GENERATE_CNOID_PROJECT(panda_default panda_default)
GENERATE_CNOID_PROJECT(panda_hand panda_hand)
GENERATE_CNOID_PROJECT(panda_foot panda_foot)
GENERATE_CNOID_PROJECT(panda_pump panda_pump)
GENERATE_CNOID_PROJECT(doublepanda_default doublepanda_default)
endif()