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

Process xacro file test #244

Merged
merged 8 commits into from
May 15, 2024
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@

# Visual Studio Code files
.vscode

# PyCache
*.pyc
18 changes: 18 additions & 0 deletions andino_description/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.8)
project(andino_description)

find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)

install(
DIRECTORY
Expand All @@ -14,4 +15,21 @@ install(
share/${PROJECT_NAME}/
)

if(BUILD_TESTING)
find_package(ament_cmake_pytest REQUIRED)
set(_pytest_tests
test/test_xacro_processing.py
)
foreach(_test_path ${_pytest_tests})
get_filename_component(_test_name ${_test_path} NAME_WE)
ament_add_pytest_test(${_test_name} ${_test_path}
APPEND_ENV PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}
TIMEOUT 60
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endforeach()
endif()

# ament_python_install_package(${PROJECT_NAME})
JesusSilvaUtrera marked this conversation as resolved.
Show resolved Hide resolved

ament_package()
3 changes: 3 additions & 0 deletions andino_description/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
<license file="LICENSE">BSD Clause 3</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_python</buildtool_depend>

<exec_depend>joint_state_publisher_gui</exec_depend>
<exec_depend>robot_state_publisher</exec_depend>
<exec_depend>ros2launch</exec_depend>
<exec_depend>rviz2</exec_depend>
<exec_depend>xacro</exec_depend>

<test_depend>ament_cmake_pytest</test_depend>
JesusSilvaUtrera marked this conversation as resolved.
Show resolved Hide resolved

<export>
<build_type>ament_cmake</build_type>
</export>
Expand Down
16 changes: 16 additions & 0 deletions andino_description/test/test_xacro_processing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
JesusSilvaUtrera marked this conversation as resolved.
Show resolved Hide resolved
import pytest
import xacro
from ament_index_python.packages import get_package_share_directory

andino_description_pkg = get_package_share_directory("andino_description")
JesusSilvaUtrera marked this conversation as resolved.
Show resolved Hide resolved

def test_xacro_processing():
JesusSilvaUtrera marked this conversation as resolved.
Show resolved Hide resolved
jballoffet marked this conversation as resolved.
Show resolved Hide resolved
# Get the file path
JesusSilvaUtrera marked this conversation as resolved.
Show resolved Hide resolved
xacro_file_path = os.path.join(andino_description_pkg, 'urdf', 'andino.urdf.xacro')

# Test xacro processing
JesusSilvaUtrera marked this conversation as resolved.
Show resolved Hide resolved
try:
xacro.process_file(xacro_file_path)
except Exception as e:
pytest.fail(f"Xacro processing failed: {e}")
Loading