-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Description] Optimize code generation and enable generation of URDF …
…tests per default (#172) * add urdf test in Python with reference to the original code --------- Co-authored-by: Dr. Denis <[email protected]>
- Loading branch information
Showing
6 changed files
with
194 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 0 additions & 97 deletions
97
templates/robot_description/test_robot_description.launch.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Copyright (c) 2024, Stogl Robotics Consulting UG (haftungsbeschränkt) (template) | ||
# Copyright (c) 2022 FZI Forschungszentrum Informatik | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# * Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# | ||
# * Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# | ||
# * Neither the name of the FZI Forschungszentrum Informatik nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
|
||
# | ||
# Source of this file is https://github.com/StoglRobotics/ros_team_workspace repository. | ||
# Modified from tests in https://github.com/UniversalRobots/Universal_Robots_ROS2_Description | ||
# | ||
# Author: Lukas Sackewitz | ||
# Author (template): Manuel Muth | ||
|
||
import os | ||
import shutil | ||
import subprocess | ||
import tempfile | ||
|
||
from ament_index_python.packages import get_package_share_directory | ||
|
||
|
||
def test_urdf_xacro(): | ||
# General Arguments | ||
description_package = "$PKG_NAME$" | ||
description_file = "$ROBOT_NAME$.urdf.xacro" | ||
|
||
description_file_path = os.path.join( | ||
get_package_share_directory(description_package), "urdf", description_file | ||
) | ||
|
||
(_, tmp_urdf_output_file) = tempfile.mkstemp(suffix=".urdf") | ||
|
||
# Compose `xacro` and `check_urdf` command | ||
xacro_command = ( | ||
f"{shutil.which('xacro')}" f" {description_file_path}" f" > {tmp_urdf_output_file}" | ||
) | ||
check_urdf_command = f"{shutil.which('check_urdf')} {tmp_urdf_output_file}" | ||
|
||
# Try to call processes but finally remove the temp file | ||
try: | ||
xacro_process = subprocess.run( | ||
xacro_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True | ||
) | ||
|
||
assert xacro_process.returncode == 0, " --- XACRO command failed ---" | ||
|
||
check_urdf_process = subprocess.run( | ||
check_urdf_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True | ||
) | ||
|
||
assert ( | ||
check_urdf_process.returncode == 0 | ||
), "\n --- URDF check failed! --- \nYour xacro does not unfold into a proper urdf robot description. Please check your xacro file." | ||
|
||
finally: | ||
os.remove(tmp_urdf_output_file) | ||
|
||
|
||
if __name__ == "__main__": | ||
test_urdf_xacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters