Skip to content

Commit

Permalink
Fix joint type enumeration. Add package path to mesh path.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-dorf committed Apr 8, 2024
1 parent a403484 commit d162950
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Fusion360/ExportURDF.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def run(context):
urdfFile.write(xmlHeader)
urdfFile.write(robotHeader % robotName)
for link in rootComp.occurrences:
urdfFile.write(fillLinkTemplate(link))
urdfFile.write(fillLinkTemplate(link, robotName))
parsed_name = link.name.replace(' ', '_').replace(':', '_')
mesh_name = os.path.join('meshes', parsed_name + '.stl')
meshPath = os.path.join(folderPath, robotName, mesh_name)
Expand All @@ -70,13 +70,13 @@ def getTemplate(templateName):
<visual>
<origin xyz = "%f %f %f" rpy = "0 0 0"/>
<geometry>
<mesh filename = "%s" scale = "0.001 0.001 0.001"/>
<mesh filename = "file://$(find %s)/%s" scale = "0.001 0.001 0.001"/>
</geometry>
</visual>
<collision>
<origin xyz = "%f %f %f" rpy = "0 0 0"/>
<geometry>
<mesh filename = "%s" scale = "0.001 0.001 0.001"/>
<mesh filename = "file://$(find %s)/%s" scale = "0.001 0.001 0.001"/>
</geometry>
</collision>
<inertial>
Expand Down Expand Up @@ -122,7 +122,7 @@ def getTemplate(templateName):
return locals()[templateName.upper()]


def fillLinkTemplate(link):
def fillLinkTemplate(link, robotName):
link_origin = link.getPhysicalProperties().centerOfMass
returnValue, xx, yy, zz, xy, yz, xz = link.getPhysicalProperties().getXYZMomentsOfInertia()
kgcm2_to_kgm2 = 1e-6
Expand All @@ -133,10 +133,12 @@ def fillLinkTemplate(link):
link_origin.x,
link_origin.y,
link_origin.z,
robotName,
mesh_name,
link_origin.x,
link_origin.y,
link_origin.z,
robotName,
mesh_name,
link_origin.x,
link_origin.y,
Expand All @@ -151,8 +153,7 @@ def fillLinkTemplate(link):


def fillJointTemplate(joint, jointType):
jointDict = {0: 'continuous', 1: 'fixed',
2: 'revolute', 3: 'prismatic'}
jointDict = {0: 'fixed', 1: 'revolute', 2: 'prismatic', 3: 'continuous'}
jointTypeStr = jointDict[jointType]
jointTemplate = getTemplate(jointTypeStr)
joint_origin = joint.geometryOrOriginOne
Expand Down

0 comments on commit d162950

Please sign in to comment.