Skip to content

Add load_from_string #54

@amalnanavati

Description

@amalnanavati

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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions