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

to_urdf fun retrun a str, not a BufferedRandom #2957

Merged
merged 1 commit into from
Jan 2, 2024
Merged
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
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
Loading