Skip to content

Commit

Permalink
[DEV] Use model path in sdf meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
Loki Le Dev committed Aug 3, 2021
1 parent 4d069d4 commit 6a5ba13
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion onshape_to_robot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import commentjson as json
from colorama import Fore, Back, Style
from pathlib import Path

config = {}

Expand Down Expand Up @@ -40,7 +41,7 @@ def configGet(name, default=None, hasDefault=False, valuesList=None):
print(Fore.RED+"ERROR: The file "+configFile+" can't be found"+Style.RESET_ALL)
exit()
config = json.load(open(configFile))

config['robotFolder'] = Path(robot).name
config['documentId'] = configGet('documentId')
config['versionId'] = configGet('versionId', '')
config['workspaceId'] = configGet('workspaceId', '')
Expand Down
1 change: 1 addition & 0 deletions onshape_to_robot/onshape_to_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
robot.additionalXML = config['additionalXML']
robot.useFixedLinks = config['useFixedLinks']
robot.meshDir = config['outputDirectory']
robot.robotFolder = config['robotFolder']


def partIsIgnore(name):
Expand Down
4 changes: 2 additions & 2 deletions onshape_to_robot/robot_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import uuid
from . import stl_combine


def rotationMatrixToEulerAngles(R):
sy = math.sqrt(R[0, 0] * R[0, 0] + R[1, 0] * R[1, 0])

Expand Down Expand Up @@ -62,6 +61,7 @@ def __init__(self, name):
self.addDummyBaseLink = False
self.robotName = name
self.meshDir = None
self.robotFolder = ''

def shouldMergeSTLs(self, node):
return self.mergeSTLs == 'all' or self.mergeSTLs == node
Expand Down Expand Up @@ -437,7 +437,7 @@ def addSTL(self, matrix, stl, color, name, node='visual'):
self.append('<'+node+' name="'+name+'_visual">')
self.append(pose(matrix))
self.append('<geometry>')
self.append('<mesh><uri>file://'+stl+'</uri></mesh>')
self.append(f'<mesh><uri>model://{self.robotFolder}/{stl}</uri></mesh>')
self.append('</geometry>')
if node == 'visual':
self.append(self.material(color))
Expand Down

0 comments on commit 6a5ba13

Please sign in to comment.