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

Add load_from_string #54

Open
amalnanavati opened this issue May 9, 2024 · 1 comment
Open

Add load_from_string #54

amalnanavati opened this issue May 9, 2024 · 1 comment

Comments

@amalnanavati
Copy link

Description: In some applications, as opposed to having a URDF file, one has the URDF as a string. it would be helpful to have a URDF.load_from_string method to handle such scenarios.

Sample Use Case: A common use case with MoveIt2 is to have the robot model as a xacro file, then convert the xacro file to a URDF string, and then pass that string as a parameter to move_group node. As a result, one can easily get the URDF string by calling the get parameter service. However, yourdfpy does not provide a way to load that string.

Workaround: I have currently worked around this with by adding the following code to my class. However, it is non-ideal because we are accessing a private member of the URDF class outside of the class. So it would be better to add the capability to the library itself.

from lxml import etree
from yourdfpy import URDF

parser = etree.XMLParser(remove_blank_text=True)
xml_root = etree.fromstring(urdf_str, parser=parser)
model = URDF(robot=URDF._parse_robot(xml_element=xml_root))
@amalnanavati
Copy link
Author

amalnanavati commented May 9, 2024

As a side-note: thanks for this great library! I have opened a PR to add it to the rosdep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant