Skip to content

Support loading SimscapeMultibodyImportXML files (i.e. support MATLAB > R2017b) #39

@ajaygunalan

Description

@ajaygunalan

When I try to generate the URDF by running:

simmechanics_to_urdf MAIN.xml  --output xml

I get the following error:

Traceback (most recent call last):
  File "/usr/local/bin/simmechanics_to_urdf", line 9, in <module>
    load_entry_point('simmechanics-to-urdf==0.2', 'console_scripts', 'simmechanics_to_urdf')()
  File "/usr/local/lib/python2.7/dist-packages/simmechanics_to_urdf-0.2-py2.7.egg/simmechanics_to_urdf/firstgen.py", line 1871, in main
  File "/usr/local/lib/python2.7/dist-packages/simmechanics_to_urdf-0.2-py2.7.egg/simmechanics_to_urdf/firstgen.py", line 167, in convert
  File "/usr/local/lib/python2.7/dist-packages/simmechanics_to_urdf-0.2-py2.7.egg/simmechanics_to_urdf/firstgen.py", line 781, in buildTree
KeyError: None

I think it is due to the XML syntax difference between the latest (2019b) and the older version.

Is it possible to modify the parser to work with the Matlab 2019b (Simscape Multibody 6.2) ?

The following file (MAIN.xml) is an XML of a simple (creo 4.0) model generated by MatLab 2019b .

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<SimscapeMultibodyImportXML version="2.0" xmlns="urn:mathworks:SimscapeMultibody:import" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Created by="agunalan" on="10/15/19||13:12:42" using="Simscape Multibody Link Version 6.0" from="Pro/Engineer Creo 4.0 - 2018300"/>
<ModelUnits mass="lbm" length="in"/>
<RootAssembly name="MAIN" uid="MAIN_asm" version="160">
<AssemblyFile name="MAIN.asm" type="ProEngineer Assembly"/>
<InstanceTree>
<Instance name="CHASSIS_SUB" grounded="true" uid="40" entityUid="CHASSIS_SUB_asm" rigid="true">
<Transform>
<Rotation>1 0 0 0 1 0 0 0 1</Rotation>
<Translation>0 0 0</Translation>
</Transform>
<Instance name="CHASSIS" grounded="true" uid="40" entityUid="CHASSIS_prt">
<Transform>
<Rotation>1 0 0 0 1 0 0 0 1</Rotation>
<Translation>0 0 0</Translation>
</Transform>
</Instance>
</Instance>
<Instance name="WHEEL_SUB" uid="41" entityUid="WHEEL_SUB_asm" rigid="true">
<Transform>
<Rotation>0.71534599119091613 0 0.69877042931644284 0 -1 0 0.69877042931644284 0 -0.71534599119091613</Rotation>
<Translation>432.5 -175 24.999999999999996</Translation>
</Transform>
<Instance name="WHEEL" grounded="true" uid="40" entityUid="WHEEL_prt">
<Transform>
<Rotation>1 0 0 0 1 0 0 0 1</Rotation>
<Translation>0 0 0</Translation>
</Transform>
</Instance>
</Instance>
<Instance name="WHEEL_SUB" uid="49" entityUid="WHEEL_SUB_asm" rigid="true">
<Transform>
<Rotation>-0.74418529807233724 0 -0.6679732345932633 0 -1 0 -0.6679732345932633 0 0.74418529807233724</Rotation>
<Translation>57.499999999999993 -175 25</Translation>
</Transform>
<Instance name="WHEEL" grounded="true" uid="40" entityUid="WHEEL_prt">
<Transform>
<Rotation>1 0 0 0 1 0 0 0 1</Rotation>
<Translation>0 0 0</Translation>
</Transform>
</Instance>
</Instance>
<Instance name="WHEEL_SUB" uid="52" entityUid="WHEEL_SUB_asm" rigid="true">
<Transform>
<Rotation>0.9875990416790178 0 0.15699723843012575 0 1 0 -0.15699723843012575 0 0.9875990416790178</Rotation>
<Translation>432.5 175 25</Translation>
</Transform>
<Instance name="WHEEL" grounded="true" uid="40" entityUid="WHEEL_prt">
<Transform>
<Rotation>1 0 0 0 1 0 0 0 1</Rotation>
<Translation>0 0 0</Translation>
</Transform>
</Instance>
</Instance>
<Instance name="WHEEL_SUB" uid="55" entityUid="WHEEL_SUB_asm" rigid="true">
<Transform>
<Rotation>0.26531500391128116 0 -0.96416178554201004 0 1 0 0.96416178554201004 0 0.26531500391128116</Rotation>
<Translation>57.499999999999986 175 24.999999999999996</Translation>
</Transform>
<Instance name="WHEEL" grounded="true" uid="40" entityUid="WHEEL_prt">
<Transform>
<Rotation>1 0 0 0 1 0 0 0 1</Rotation>
<Translation>0 0 0</Translation>
</Transform>
</Instance>
</Instance>
</InstanceTree>
<Constraints>
<Coincident name="Coincident_41_0">
<ConstraintGeometry geomType="line">
<InstancePath>
<Uid>40</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>432.5 125 25</Position>
<Axis>0 -250 0</Axis>
</ConstraintGeometry>
<ConstraintGeometry geomType="line">
<InstancePath>
<Uid>41</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>0 0 -3.8270212473354789e-015</Position>
<Axis>0 50 0</Axis>
</ConstraintGeometry>
</Coincident>
<Distance name="Distance_41_1">
<ConstraintGeometry geomType="plane">
<InstancePath>
<Uid>40</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>-130 -125 0</Position>
<Axis>0 -1 0</Axis>
</ConstraintGeometry>
<ConstraintGeometry geomType="plane">
<InstancePath>
<Uid>41</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>0 0 0</Position>
<Axis>0 1 0</Axis>
</ConstraintGeometry>
</Distance>
<Coincident name="Coincident_49_0">
<ConstraintGeometry geomType="line">
<InstancePath>
<Uid>40</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>57.5 -125 25</Position>
<Axis>0 250 0</Axis>
</ConstraintGeometry>
<ConstraintGeometry geomType="line">
<InstancePath>
<Uid>49</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>0 0 -3.8270212473354789e-015</Position>
<Axis>0 50 0</Axis>
</ConstraintGeometry>
</Coincident>
<Distance name="Distance_49_1">
<ConstraintGeometry geomType="plane">
<InstancePath>
<Uid>40</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>-130 -125 0</Position>
<Axis>0 -1 0</Axis>
</ConstraintGeometry>
<ConstraintGeometry geomType="plane">
<InstancePath>
<Uid>49</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>0 0 0</Position>
<Axis>0 1 0</Axis>
</ConstraintGeometry>
</Distance>
<Coincident name="Coincident_52_0">
<ConstraintGeometry geomType="line">
<InstancePath>
<Uid>40</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>432.5 125 25</Position>
<Axis>0 -250 0</Axis>
</ConstraintGeometry>
<ConstraintGeometry geomType="line">
<InstancePath>
<Uid>52</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>0 0 -3.8270212473354789e-015</Position>
<Axis>0 50 0</Axis>
</ConstraintGeometry>
</Coincident>
<Distance name="Distance_52_1">
<ConstraintGeometry geomType="plane">
<InstancePath>
<Uid>40</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>620 125 0</Position>
<Axis>0 1 0</Axis>
</ConstraintGeometry>
<ConstraintGeometry geomType="plane">
<InstancePath>
<Uid>52</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>0 0 0</Position>
<Axis>0 1 0</Axis>
</ConstraintGeometry>
</Distance>
<Coincident name="Coincident_55_0">
<ConstraintGeometry geomType="line">
<InstancePath>
<Uid>40</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>57.5 -125 25</Position>
<Axis>0 250 0</Axis>
</ConstraintGeometry>
<ConstraintGeometry geomType="line">
<InstancePath>
<Uid>55</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>0 0 -3.8270212473354789e-015</Position>
<Axis>0 50 0</Axis>
</ConstraintGeometry>
</Coincident>
<Distance name="Distance_55_1">
<ConstraintGeometry geomType="plane">
<InstancePath>
<Uid>40</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>620 125 0</Position>
<Axis>0 1 0</Axis>
</ConstraintGeometry>
<ConstraintGeometry geomType="plane">
<InstancePath>
<Uid>55</Uid>
<Uid>40</Uid>
</InstancePath>
<Position>0 0 0</Position>
<Axis>0 1 0</Axis>
</ConstraintGeometry>
</Distance>
</Constraints>
</RootAssembly>
<Assemblies>
<Assembly name="CHASSIS_SUB" uid="CHASSIS_SUB_asm" version="180">
<AssemblyFile name="CHASSIS_SUB.asm" type="ProEngineer Assembly"/>
</Assembly>
<Assembly name="WHEEL_SUB" uid="WHEEL_SUB_asm" version="120">
<AssemblyFile name="WHEEL_SUB.asm" type="ProEngineer Assembly"/>
</Assembly>
</Assemblies>
<Parts>
<Part name="CHASSIS" uid="CHASSIS_prt" version="238">
<PartFile name="CHASSIS.prt" type="ProEngineer Part"/>
<MassProperties>
<Mass>9375000</Mass>
<CenterOfMass>245 0 25</CenterOfMass>
<Inertia>50781250000 441406250000 488281250000 0 0 0</Inertia>
</MassProperties>
<GeometryFile name="chassis_prt.stl" type="STL"/>
</Part>
<Part name="WHEEL" uid="WHEEL_prt" version="799">
<PartFile name="WHEEL.prt" type="ProEngineer Part"/>
<MassProperties>
<Mass>606213.48535157135</Mass>
<CenterOfMass>-0.15994610631045164 24.96957000305591 -0.10072871630685017</CenterOfMass>
<Inertia>723312153.26175296 1193655486.7731125 723423085.03918469 154515.91560309008 2156097.7563693691 245354.25417733006</Inertia>
</MassProperties>
<GeometryFile name="wheel_prt.stl" type="STL"/>
</Part>
</Parts>
</SimscapeMultibodyImportXML>

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