Skip to content

RobotModel.data doesn't contain all necessary data #15

@gonzalocasas

Description

@gonzalocasas

Migrated from compas-dev/compas#730


Describe the bug
Some data is missing from in RobotModel.data making the serialization of instances of this class faulty. In particular, if a RobotModel is loaded from a urdf that contains gazebo or other nonstandard tags, some information will be lost upon serialization followed by deserialization. This is exposed by attempting to write the reserialized RobotModel to URDF.

To Reproduce
Steps to reproduce the behavior:

  1. Run the following script:
import copy

from compas.files import URDF
from compas.robots import RobotModel
import compas_fab

filepath = compas_fab.get('universal_robot/ur_description/urdf/ur5.urdf')
model = RobotModel.from_urdf_file(filepath)
model_copy = RobotModel.from_data(model.data)
# model_copy = copy.deepcopy(model)
urdf = URDF.from_robot(model_copy)

(Though this script imports compas_fab, it is only for accessing a particular URDF. The relevant code lies in compas.)

Expected behavior
This should result in the creation of a valid URDF instance, however an exception is thrown about a URDFGenericElement not having a tag. This is because the protected attribute _urdf_source (or the inferred attribute tag) is not included in data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions