diff --git a/onshape_to_robot/robot_description.py b/onshape_to_robot/robot_description.py index 287a77e..017caff 100644 --- a/onshape_to_robot/robot_description.py +++ b/onshape_to_robot/robot_description.py @@ -32,7 +32,7 @@ def rotationMatrixToEulerAngles(R): def origin(matrix): - urdf = '' + urdf = '' x = matrix[0, 3] y = matrix[1, 3] z = matrix[2, 3] @@ -42,7 +42,7 @@ def origin(matrix): def pose(matrix, frame=''): - sdf = '%.20g %.20g %.20g %.20g %.20g %.20g' + sdf = '%g %g %g %g %g %g' x = matrix[0, 3] y = matrix[1, 3] z = matrix[2, 3] @@ -231,10 +231,10 @@ def endLink(self): self.addSTL(np.identity(4), filename, color, self._link_name, node) self.append('') - self.append('' % + self.append('' % (com[0], com[1], com[2])) - self.append('' % mass) - self.append('' % + self.append('' % mass) + self.append('' % (inertia[0, 0], inertia[0, 1], inertia[0, 2], inertia[1, 1], inertia[1, 2], inertia[2, 2])) self.append('') @@ -275,7 +275,7 @@ def addSTL(self, matrix, stl, color, name, node='visual'): self.append('') if node == 'visual': self.append(f'') - self.append('' % + self.append('' % (color[0], color[1], color[2])) self.append('') self.append('') @@ -312,19 +312,19 @@ def addPart(self, matrix, stl, mass, com, inertia, color, shapes=None, name=''): self.append(origin(matrix*shape['transform'])) self.append('') if shape['type'] == 'cube': - self.append('' % + self.append('' % tuple(shape['parameters'])) if shape['type'] == 'cylinder': self.append( - '' % tuple(shape['parameters'])) + '' % tuple(shape['parameters'])) if shape['type'] == 'sphere': - self.append('' % + self.append('' % shape['parameters']) self.append('') if entry == 'visual': self.append('') - self.append('' % + self.append('' % (color[0], color[1], color[2])) self.append('') self.append('') @@ -336,11 +336,11 @@ def addJoint(self, jointType, linkFrom, linkTo, transform, name, jointLimits, zA self.append(origin(transform)) self.append('') self.append('') - self.append('' % tuple(zAxis)) + self.append('' % tuple(zAxis)) lowerUpperLimits = '' if jointLimits is not None: - lowerUpperLimits = 'lower="%.20g" upper="%.20g"' % jointLimits - self.append('' % + lowerUpperLimits = 'lower="%g" upper="%g"' % jointLimits + self.append('' % (self.jointMaxEffortFor(name), self.jointMaxVelocityFor(name), lowerUpperLimits)) self.append('') self.append('') @@ -409,9 +409,9 @@ def endLink(self): self.append('') self.append('%.20g %.20g %.20g 0 0 0' % (com[0], com[1], com[2])) - self.append('%.20g' % mass) - self.append('%.20g%.20g%.20g%.20g%.20g%.20g' % + '_frame">%g %g %g 0 0 0' % (com[0], com[1], com[2])) + self.append('%g' % mass) + self.append('%g%g%g%g%g%g' % (inertia[0, 0], inertia[0, 1], inertia[0, 2], inertia[1, 1], inertia[1, 2], inertia[2, 2])) self.append('') @@ -440,8 +440,8 @@ def addFrame(self, name, matrix): def material(self, color): m = '' - m += '%.20g %.20g %.20g 1' % (color[0], color[1], color[2]) - m += '%.20g %.20g %.20g 1' % (color[0], color[1], color[2]) + m += '%g %g %g 1' % (color[0], color[1], color[2]) + m += '%g %g %g 1' % (color[0], color[1], color[2]) m += '0.1 0.1 0.1 1' m += '0 0 0 0' m += '' @@ -497,14 +497,14 @@ def addPart(self, matrix, stl, mass, com, inertia, color, shapes=None, name=''): self.append(pose(matrix*shape['transform'])) self.append('') if shape['type'] == 'cube': - self.append('%.20g %.20g %.20g' % + self.append('%g %g %g' % tuple(shape['parameters'])) if shape['type'] == 'cylinder': self.append( - '%.20g%.20g' % tuple(shape['parameters'])) + '%g%g' % tuple(shape['parameters'])) if shape['type'] == 'sphere': self.append( - '%.20g' % shape['parameters']) + '%g' % shape['parameters']) self.append('') if entry == 'visual': @@ -519,11 +519,11 @@ def addJoint(self, jointType, linkFrom, linkTo, transform, name, jointLimits, zA self.append(''+linkFrom+'') self.append(''+linkTo+'') self.append('') - self.append('%.20g %.20g %.20g' % tuple(zAxis)) + self.append('%g %g %g' % tuple(zAxis)) lowerUpperLimits = '' if jointLimits is not None: - lowerUpperLimits = '%.20g%.20g' % jointLimits - self.append('%.20g%.20g%s' % + lowerUpperLimits = '%g%g' % jointLimits + self.append('%g%g%s' % (self.jointMaxEffortFor(name), self.jointMaxVelocityFor(name), lowerUpperLimits)) self.append('') self.append('')