-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
executable file
·93 lines (71 loc) · 2.3 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
cmake_minimum_required(VERSION 3.10)
project(rl_controller)
# set(CMAKE_BUILD_TYPE Release)
set(CMAKE_BUILD_TYPE Release)
add_definitions(-w) # warning ignore
add_compile_options(-fPIC)
set(BUILD_PLATFORM "x86" CACHE STRING "select build cpu type")
option(BUILD_SIM "Build with simulation option enabled" OFF)
option(SEND_REMOTE OFF)
if (BUILD_PLATFORM STREQUAL arm)
message("this is arm platform")
set(BUILD_SIM off)
set(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++")
else()
message("this is x86 platform")
endif()
set(CMAKE_CXX_STANDARD 17)
if (SEND_REMOTE)
set(BUILD_SIM OFF)
endif()
message("BUILD_PLATFORM: ${BUILD_PLATFORM}")
message("BUILD_SIM: ${BUILD_SIM}")
message("SEND_REMOTE: ${SEND_REMOTE}")
get_filename_component(WORKSPACE_DIR ./ ABSOLUTE)
set(THIRD_PARTY ${WORKSPACE_DIR}/third_party)
set(Torch_DIR "${THIRD_PARTY}/libtorch/${BUILD_PLATFORM}/share/cmake/Torch")
find_package(Torch REQUIRED)
message("Torch_DIR: ${Torch_DIR}")
include_directories(
${THIRD_PARTY}/eigen/
${THIRD_PARTY}/gamepad/include
${THIRD_PARTY}/x30_motion_sdk/include
${THIRD_PARTY}/Lite3_MotionSDK/include
types
interface/robot
interface/user_command
state_machine
run_policy
${TORCH_INCLUDE_DIRS}
${WORKSPACE_DIR}/sensor/
)
add_subdirectory(interface)
if (BUILD_SIM)
add_definitions(-DUSE_RAISIM)
set(raisim_DIR "~/raisim/lib/cmake/raisim")
find_package(raisim CONFIG REQUIRED)
endif()
if (SEND_REMOTE)
set(PATH_LIB "../lib")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH ${PATH_LIB}/libtorch/${BUILD_PLATFORM}/lib)
endif()
file(GLOB_RECURSE STATE_MACHINE_SRC "state_machine/*.c*")
file(GLOB_RECURSE RUN_POLICY_SRC "run_policy/*.cpp")
file(GLOB_RECURSE SENSOR_SRC "sensor/*.cpp")
add_executable(rl_deploy main.cpp ${STATE_MACHINE_SRC} ${RUN_POLICY_SRC} ${SENSOR_SRC})
target_link_libraries(rl_deploy interface -lpthread -lm -lrt -ldl -lstdc++ torch)
if (BUILD_SIM)
message("build simulation")
target_link_libraries(rl_deploy raisim::raisim)
endif()
if (SEND_REMOTE)
add_custom_target(push_to_robot ALL DEPENDS rl_deploy)
add_custom_command(
TARGET push_to_robot POST_BUILD
COMMAND ${WORKSPACE_DIR}/scripts/sftp_to_remote.sh
WORKING_DIRECTORY ..
COMMENT "run sftp_to_remote.sh"
)
endif()