Skip to content

Commit

Permalink
Building tera_renderer from source (#30)
Browse files Browse the repository at this point in the history
* build: compile tf_renderer (also work for arm)

* fix: cmake lint
  • Loading branch information
damien-robotsix authored Sep 14, 2024
1 parent e718a63 commit 87d5614
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
36 changes: 24 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,32 @@ if(${BUILD_ACADOS_TEMPLATE})
if(NOT EXISTS "${TERA_RENDERER}")
# Add empty bin directory (used to download the tera renderer)
install(DIRECTORY DESTINATION "opt/${PROJECT_NAME}/bin")
message(STATUS "Downloading tera renderer")

set(TERA_VERSION "0.0.34")
if(UNIX AND NOT APPLE)
set(TERA_SUFFIX linux)
elseif(APPLE)
set(TERA_SUFFIX osx)
set(TERA_VERSION "0.0.35")
# Clone the tera renderer
message(STATUS "Cloning Tera renderer")
if(NOT EXISTS "${ACADOS_SOURCE_BUILD_DIR}/tera_renderer")
execute_process(COMMAND git clone --quiet https://github.com/acados/tera_renderer -b v${TERA_VERSION}
WORKING_DIRECTORY "${ACADOS_SOURCE_BUILD_DIR}"
RESULT_VARIABLE TERA_GIT_OUT
OUTPUT_VARIABLE TERA_GIT_OUT)
if(NOT TERA_GIT_OUT EQUAL 0)
message(FATAL_ERROR "Failed to clone Tera renderer")
endif()
else()
set(TERA_SUFFIX windows)
message(STATUS "${ACADOS_SOURCE_BUILD_DIR}/tera_renderer already exists")
endif()

file(DOWNLOAD
"https://github.com/acados/tera_renderer/releases/download/v${TERA_VERSION}/t_renderer-v${TERA_VERSION}-${TERA_SUFFIX}"
${TERA_RENDERER})
# Compile the tera renderer
message(STATUS "Building Tera renderer")
execute_process(COMMAND cargo build --quiet --release
WORKING_DIRECTORY "${ACADOS_SOURCE_BUILD_DIR}/tera_renderer"
RESULT_VARIABLE TERA_BUILD_OUT
OUTPUT_VARIABLE TERA_BUILD_OUT)
if(NOT TERA_BUILD_OUT EQUAL 0)
message(FATAL_ERROR "Failed to build Tera renderer")
endif()
# Copy the tera renderer
file(COPY "${ACADOS_SOURCE_BUILD_DIR}/tera_renderer/target/release/t_renderer"
DESTINATION "${ACADOS_SOURCE_DIR}/bin")
file(CHMOD
${TERA_RENDERER}
PERMISSIONS
Expand Down
2 changes: 2 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<buildtool_depend>ament_cmake_vendor_package</buildtool_depend>
<buildtool_depend>pkg-config</buildtool_depend>

<build_depend>cargo</build_depend>

<exec_depend>casadi-pip</exec_depend>

<buildtool_export_depend>pkg-config</buildtool_export_depend>
Expand Down

0 comments on commit 87d5614

Please sign in to comment.