Skip to content

Commit

Permalink
PR #2957 from hellototoro: to_urdf fun retrun a str, not a BufferedRa…
Browse files Browse the repository at this point in the history
…ndom
  • Loading branch information
Nir-Az authored Jan 2, 2024
2 parents d7b029f + d27a327 commit 79b7fb3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions realsense2_description/launch/launch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ def to_urdf(xacro_path, parameters=None):
* xacro_path -- the path to the xacro file
* parameters -- to be used when xacro file is parsed.
"""
urdf_path = tempfile.TemporaryFile(prefix="%s_" % os.path.basename(xacro_path))
with tempfile.NamedTemporaryFile(prefix="%s_" % os.path.basename(xacro_path), delete=False) as xacro_file:
urdf_path = xacro_file.name

# open and process file
doc = xacro.process_file(xacro_path, mappings=parameters)
# open the output file
out = xacro.open_output(urdf_path)
out.write(doc.toprettyxml(indent=' '))
with open(urdf_path, 'w') as urdf_file:
urdf_file.write(doc.toprettyxml(indent=' '))

return urdf_path

0 comments on commit 79b7fb3

Please sign in to comment.