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

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

Open
ajaygunalan opened this issue Oct 15, 2019 · 8 comments

Comments

@ajaygunalan
Copy link

ajaygunalan commented Oct 15, 2019

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>

@ajaygunalan ajaygunalan changed the title Not able to generate the URDF with MatLab 2019 Not able to generate the URDF with MatLab 2019b Oct 15, 2019
@traversaro
Copy link
Member

Hi @ajaygunalan , thanks for opening the issue and sharing a SimscapeMultibodyImportXML import example file. I compared it with an example of PhysicalModelingXMLFile file that we support (see https://github.com/robotology/simmechanics-to-urdf/blob/master/test/LEGS_MECHANISM.xml) and unfortunatly the differences are not only superficial, for example just the name of some tags, but more in depth. Perhaps there are some parallelism (do Subsystem in PhysicalModelingXMLFile correspond to Assembly in SimscapeMultibodyImportXML ?) but a more throughout analysis is probably required before attemping to port the parser to also support SimscapeMultibodyImportXML .

@traversaro
Copy link
Member

In the meanwhile, if you are stuck with Matlab 2019b, I would give it a try to install the Simscape Multibody 4.8 available at https://mathworks.com/campaigns/offers/download_smlink.html anadd to install it with Matlab 2019b ? I never tried this, but perhaps it is possible to do so.

@ajaygunalan
Copy link
Author

Hi @traversaro. Actually, I did try to install SimMechanics 4.x on MatLab 2019. But, It wasn't possible.
It seems there is a link between the MatLab version and the SimMechanics version.

Kindly see the below image. Will try to get an older version of MatLab.

simmech_matlab_version

@traversaro
Copy link
Member

For reference, it seems that the first version that does not support exporting first gen files is R2017b, see https://mathworks.com/help/physmod/smlink/release-notes.html , so to use the script you need a Matlab R2017a or earlier.

@ajaygunalan
Copy link
Author

Thanks for the input on the version. Hopefully, I will try to get an older version, maybe R2016a.

@nicolasfrick
Copy link

nicolasfrick commented Aug 22, 2020

Hi @traversaro,
I'm stuck with the same problem with Inventor 2019 and Matlab 2020. I have no opportunity to get an older Inventor version than 2018. Is there any option to generate PhysicalModelingXMLFile from a newer version of a CAD program or to convert SimscapeMultibodyImportXML to PhysicalModelingXMLFile? Otherwise, simmechanics-to-urdf would not be usable anymore?

@traversaro
Copy link
Member

Is there any option to generate PhysicalModelingXMLFile from a newer version of a CAD program or to convert SimscapeMultibodyImportXML to PhysicalModelingXMLFile?

Not that I am aware.

Otherwise, simmechanics-to-urdf would not be usable anymore?

As any open source project, simmechanics-to-urdf only provides the functionality that are contributed for free by volunteers. If you or someone else are interested in contributing support SimscapeMultibodyImportXML to URDF functionality in simmechanics-to-urdf or in a new project, I will be happy to provide you support and advice, but unless someone contributes this work, simmechanics-to-urdf will continue to just support the old and deprecated PhysicalModelingXMLFile format.

@traversaro
Copy link
Member

cc @Nicogene

@traversaro traversaro changed the title Not able to generate the URDF with MatLab 2019b Support loading SimscapeMultibodyImportXML files Mar 4, 2021
@traversaro traversaro changed the title Support loading SimscapeMultibodyImportXML files Support loading SimscapeMultibodyImportXML files (i.e. support MATLAB > R2017b) Mar 28, 2023
@traversaro traversaro pinned this issue Mar 28, 2023
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

3 participants