Skip to content

Commit

Permalink
Added some changes to example scripts and docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
senthurayyappan committed Dec 19, 2024
1 parent 12f3b9a commit 80a8186
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 36 deletions.
2 changes: 1 addition & 1 deletion docs/api/robot.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Robot

::: onshape_api.models.robot
::: onshape_api.robot
53 changes: 26 additions & 27 deletions examples/simulation/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
from scipy.spatial.transform import Rotation
from transformations import compute_motor_torques

from onshape_api.connect import Client
from onshape_api.log import LOGGER, LogLevel
from onshape_api.robot import Robot

# from onshape_api.robot import RobotType, get_robot
from onshape_api.utilities import save_gif
Expand Down Expand Up @@ -113,37 +115,34 @@ def get_mujoco_element():
# )
# ballbot.show()

# client = Client()
# ballbot = Robot.from_url(
# name="ballbot",
# url="https://cad.onshape.com/documents/1f42f849180e6e5c9abfce52/w/0c00b6520fac5fada24b2104/e/c96b40ef586e60c182f41d29",
# client=client,
# max_depth=0,
# use_user_defined_root=True,
# )
# ballbot.show_tree()

# mujoco_attributes = {
# "compiler": DEFAULT_COMPILER_ATTRIBUTES,
# "option": DEFAULT_OPTION_ATTRIBUTES,
# }
client = Client()
ballbot = Robot.from_url(
name="ballbot",
url="https://cad.onshape.com/documents/1f42f849180e6e5c9abfce52/w/0c00b6520fac5fada24b2104/e/c96b40ef586e60c182f41d29",
client=client,
max_depth=0,
use_user_defined_root=True,
)
ballbot.show_tree()

# custom_element = get_mujoco_element()
# ballbot.add_custom_element(parent_name="root", element=custom_element)
mujoco_attributes = {
"compiler": DEFAULT_COMPILER_ATTRIBUTES,
"option": DEFAULT_OPTION_ATTRIBUTES,
}

# ballbot.save(file_path="ballbot.urdf")
custom_element = get_mujoco_element()
ballbot.add_custom_element(parent_name="root", element=custom_element)

spec = mujoco.MjSpec.from_xml_path(filename="ballbot.urdf")
ballbot.save(file_path="ballbot.urdf")

# data = mujoco.MjData(model)
model = mujoco.MjModel.from_xml_path(filename="ballbot.urdf")
data = mujoco.MjData(model)

# # # run_simulation(model, data, 20, 60)
mujoco.mj_resetData(model, data)

# mujoco.mj_resetData(model, data)

# with mujoco.viewer.launch_passive(model, data) as viewer:
# while viewer.is_running():
# mujoco.mj_step(model, data)
# mujoco.mj_forward(model, data)
with mujoco.viewer.launch_passive(model, data) as viewer:
while viewer.is_running():
mujoco.mj_step(model, data)
mujoco.mj_forward(model, data)

# viewer.sync()
viewer.sync()
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ nav:
- Joint: api/joint.md
- Link: api/link.md
- Mass: api/mass.md
- Robot: api/robot.md
- Variable: api/variable.md
- Connect: api/connect.md
- Graph: api/graph.md
- Log: api/log.md
- Mesh: api/mesh.md
- Parse: api/parse.md
- Robot: api/robot.md
- Urdf: api/urdf.md
- Utilities: api/utilities.md

Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ build-backend = "poetry.core.masonry.api"

[tool.mypy]
files = ["onshape_api"]
disallow_untyped_defs = "True"
disallow_any_unimported = "True"
no_implicit_optional = "True"
check_untyped_defs = "True"
warn_return_any = "True"
warn_unused_ignores = "True"
show_error_codes = "True"
disallow_untyped_defs = true
disallow_any_unimported = true
no_implicit_optional = true
check_untyped_defs = true
warn_return_any = true
warn_unused_ignores = true
show_error_codes = true



Expand Down

0 comments on commit 80a8186

Please sign in to comment.