-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for mate relations, joint name references still need to…
… be sorted out. Made the urdf pretty looking.
- Loading branch information
1 parent
764253b
commit c86e12a
Showing
10 changed files
with
208 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,3 +174,4 @@ benchmark/**/*.urdf | |
benchmark/**/*.stl | ||
benchmark/**/*.png | ||
benchmark/**/*.prof | ||
benchmark/**/*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import json | ||
import os | ||
|
||
import onshape_api as opa | ||
from onshape_api.models.document import Document | ||
|
||
SCRIPT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
if __name__ == "__main__": | ||
client = opa.Client() | ||
|
||
json_path = SCRIPT_DIRECTORY + "/arbor_press.json" | ||
json_data = json.load(open(json_path)) | ||
|
||
assembly = opa.Assembly.model_validate(json_data) | ||
document = client.get_document_metadata(assembly.rootAssembly.documentId) | ||
assembly.document = Document( | ||
did=assembly.rootAssembly.documentId, | ||
wtype=document.defaultWorkspace.type.shorthand, | ||
wid=document.defaultWorkspace.id, | ||
eid=assembly.rootAssembly.elementId, | ||
name=document.name, | ||
) | ||
|
||
print(assembly.document.url) | ||
|
||
instances, id_to_name_map = opa.get_instances(assembly) | ||
occurences = opa.get_occurences(assembly, id_to_name_map) | ||
parts = opa.get_parts(assembly, client, instances) | ||
subassemblies = opa.get_subassemblies(assembly, instances) | ||
mates, relations = opa.get_mates_and_relations(assembly, subassemblies, id_to_name_map) | ||
|
||
graph, root_node = opa.create_graph( | ||
occurences=occurences, | ||
instances=instances, | ||
parts=parts, | ||
mates=mates, | ||
) | ||
|
||
links, joints = opa.get_urdf_components( | ||
assembly=assembly, | ||
graph=graph, | ||
root_node=root_node, | ||
parts=parts, | ||
mates=mates, | ||
relations=relations, | ||
client=client, | ||
) | ||
|
||
robot = opa.Robot(name=document.name, links=links, joints=joints) | ||
robot.save("robot.urdf") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.