Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: xacro compilation #361

Open
wants to merge 14 commits into
base: tier4/universe
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions aip_urdf_compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.5)
project(aip_urdf_compiler)

find_package(ament_cmake_auto REQUIRED)

ament_auto_find_build_dependencies()

# Install cmake directory
install(
DIRECTORY cmake templates scripts
DESTINATION share/${PROJECT_NAME}
)

# Export the package's share directory path

# Add the config extras
ament_package(
CONFIG_EXTRAS "cmake/aip_cmake_urdf_compile.cmake"
)
33 changes: 33 additions & 0 deletions aip_urdf_compiler/cmake/aip_cmake_urdf_compile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@



macro(aip_cmake_urdf_compile)
# Set the correct paths
find_package(PythonInterp REQUIRED) # cspell: ignore Interp
set(aip_urdf_compiler_BASE_DIR "${aip_urdf_compiler_DIR}/../")
set(PYTHON_SCRIPT "${aip_urdf_compiler_BASE_DIR}/scripts/compile_xacro.py")
set(PYTHON_TEMPLATE_DIRECTORY "${aip_urdf_compiler_BASE_DIR}/templates")
set(PYTHON_CALIBRATION_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/config")
set(PYTHON_XACRO_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/urdf")

message(STATUS "PYTHON_SCRIPT path: ${PYTHON_SCRIPT}")
message(STATUS "PYTHON_TEMPLATE_DIRECTORY path: ${PYTHON_TEMPLATE_DIRECTORY}")

# Verify that the required files exist
if(NOT EXISTS "${PYTHON_SCRIPT}")
message(FATAL_ERROR "Could not find compile_xacro.py at ${PYTHON_SCRIPT}")
endif()

# Create a custom command to run the Python script
add_custom_target(xacro_compilation ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python_script_run_flag
)

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python_script_run_flag
COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_SCRIPT} ${PYTHON_TEMPLATE_DIRECTORY} ${PYTHON_CALIBRATION_DIRECTORY} ${PYTHON_XACRO_DIRECTORY} ${PROJECT_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${PYTHON_SCRIPT}
COMMENT "Running Python script for URDF creation"
)
endmacro()
17 changes: 17 additions & 0 deletions aip_urdf_compiler/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<package format="2">
<name>aip_urdf_compiler</name>
<version>0.1.0</version>
<description>The aip_urdf_compiler package</description>

<maintainer email="[email protected]">Yukihiro Saito</maintainer>
<maintainer email="[email protected]">Yuxuan Liu</maintainer>
<license>Apache 2</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<depend>python3-jinja2</depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Loading
Loading