diff --git a/kos_sim/__init__.py b/kos_sim/__init__.py
index 48a9f97..8785136 100644
--- a/kos_sim/__init__.py
+++ b/kos_sim/__init__.py
@@ -1,13 +1,11 @@
+"""Defines the KOS Simulator package API."""
+
import logging
-# Configure root logger
-logging.basicConfig(
- level=logging.DEBUG,
- format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
- handlers=[logging.StreamHandler()],
-)
+import colorlogging
+
+colorlogging.configure()
-# Get logger for this package
logger = logging.getLogger("kos_sim")
__version__ = "0.0.1"
diff --git a/kos_sim/models/gpr/README.md b/kos_sim/models/gpr/README.md
deleted file mode 100644
index 58ff4a7..0000000
--- a/kos_sim/models/gpr/README.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# URDF/XML development:
-1. kol run https://cad.onshape.com/documents/bc3a557e2f92bdcea4099f0d/w/09713ac603d461fc1dff6b5d/e/5a4acdbffe6f8ed7c4e34970 --config-path config_example.json # noqa: E501
-2. python sim/scripts/create_fixed_torso.py
-3. Rotate first link
-
-
-
-
-
-
-4. Fix left leg axes to align with expected directions
-5. urf2mjcf robot.urdf -o robot.xml
-
\ No newline at end of file
diff --git a/kos_sim/models/gpr/__init__.py b/kos_sim/models/gpr/__init__.py
deleted file mode 100755
index e69de29..0000000
diff --git a/kos_sim/models/gpr/meshes/arm1_top.stl b/kos_sim/models/gpr/meshes/arm1_top.stl
deleted file mode 100644
index d393723..0000000
Binary files a/kos_sim/models/gpr/meshes/arm1_top.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/arm1_top_2.stl b/kos_sim/models/gpr/meshes/arm1_top_2.stl
deleted file mode 100644
index 20808d7..0000000
Binary files a/kos_sim/models/gpr/meshes/arm1_top_2.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/arm2_shell.stl b/kos_sim/models/gpr/meshes/arm2_shell.stl
deleted file mode 100644
index d095688..0000000
Binary files a/kos_sim/models/gpr/meshes/arm2_shell.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/arm2_shell_2.stl b/kos_sim/models/gpr/meshes/arm2_shell_2.stl
deleted file mode 100644
index 9830275..0000000
Binary files a/kos_sim/models/gpr/meshes/arm2_shell_2.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/arm3_shell.stl b/kos_sim/models/gpr/meshes/arm3_shell.stl
deleted file mode 100644
index dd787c5..0000000
Binary files a/kos_sim/models/gpr/meshes/arm3_shell.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/arm3_shell2.stl b/kos_sim/models/gpr/meshes/arm3_shell2.stl
deleted file mode 100644
index 9690a4e..0000000
Binary files a/kos_sim/models/gpr/meshes/arm3_shell2.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/body1-part.stl b/kos_sim/models/gpr/meshes/body1-part.stl
deleted file mode 100644
index 83dc091..0000000
Binary files a/kos_sim/models/gpr/meshes/body1-part.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/foot1.stl b/kos_sim/models/gpr/meshes/foot1.stl
deleted file mode 100644
index 9387485..0000000
Binary files a/kos_sim/models/gpr/meshes/foot1.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/foot3.stl b/kos_sim/models/gpr/meshes/foot3.stl
deleted file mode 100644
index 841369d..0000000
Binary files a/kos_sim/models/gpr/meshes/foot3.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/hand_shell.stl b/kos_sim/models/gpr/meshes/hand_shell.stl
deleted file mode 100644
index 4aff47d..0000000
Binary files a/kos_sim/models/gpr/meshes/hand_shell.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/hand_shell_2.stl b/kos_sim/models/gpr/meshes/hand_shell_2.stl
deleted file mode 100644
index 4aff47d..0000000
Binary files a/kos_sim/models/gpr/meshes/hand_shell_2.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/leg0_shell.stl b/kos_sim/models/gpr/meshes/leg0_shell.stl
deleted file mode 100644
index c2a3806..0000000
Binary files a/kos_sim/models/gpr/meshes/leg0_shell.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/leg0_shell_2.stl b/kos_sim/models/gpr/meshes/leg0_shell_2.stl
deleted file mode 100644
index c2a3806..0000000
Binary files a/kos_sim/models/gpr/meshes/leg0_shell_2.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/leg1_shell.stl b/kos_sim/models/gpr/meshes/leg1_shell.stl
deleted file mode 100644
index b3b2947..0000000
Binary files a/kos_sim/models/gpr/meshes/leg1_shell.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/leg1_shell3.stl b/kos_sim/models/gpr/meshes/leg1_shell3.stl
deleted file mode 100644
index 249d815..0000000
Binary files a/kos_sim/models/gpr/meshes/leg1_shell3.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/leg2_shell.stl b/kos_sim/models/gpr/meshes/leg2_shell.stl
deleted file mode 100644
index a9e9d2c..0000000
Binary files a/kos_sim/models/gpr/meshes/leg2_shell.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/leg2_shell_2.stl b/kos_sim/models/gpr/meshes/leg2_shell_2.stl
deleted file mode 100644
index a9e9d2c..0000000
Binary files a/kos_sim/models/gpr/meshes/leg2_shell_2.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/leg3_shell2.stl b/kos_sim/models/gpr/meshes/leg3_shell2.stl
deleted file mode 100644
index 6c8c68a..0000000
Binary files a/kos_sim/models/gpr/meshes/leg3_shell2.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/leg3_shell22.stl b/kos_sim/models/gpr/meshes/leg3_shell22.stl
deleted file mode 100644
index 952779e..0000000
Binary files a/kos_sim/models/gpr/meshes/leg3_shell22.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/robot_fixed.urdf b/kos_sim/models/gpr/meshes/robot_fixed.urdf
deleted file mode 100644
index cd0137a..0000000
--- a/kos_sim/models/gpr/meshes/robot_fixed.urdf
+++ /dev/null
@@ -1,638 +0,0 @@
-
-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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/kos_sim/models/gpr/meshes/shoulder.stl b/kos_sim/models/gpr/meshes/shoulder.stl
deleted file mode 100644
index 90bc392..0000000
Binary files a/kos_sim/models/gpr/meshes/shoulder.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/meshes/shoulder_2.stl b/kos_sim/models/gpr/meshes/shoulder_2.stl
deleted file mode 100644
index 59c1316..0000000
Binary files a/kos_sim/models/gpr/meshes/shoulder_2.stl and /dev/null differ
diff --git a/kos_sim/models/gpr/robot_fixed.xml b/kos_sim/models/gpr/robot_fixed.xml
deleted file mode 100644
index d89f95a..0000000
--- a/kos_sim/models/gpr/robot_fixed.xml
+++ /dev/null
@@ -1,194 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/kos_sim/test_simulator.py b/kos_sim/test_simulator.py
index ac94ab1..c688b65 100644
--- a/kos_sim/test_simulator.py
+++ b/kos_sim/test_simulator.py
@@ -9,14 +9,14 @@
def test_simulation(model_path: str, duration: float = 5.0, speed: float = 1.0, render: bool = True) -> None:
simulator = MujocoSimulator(model_path, render=render)
- for i in range(int(duration / 0.001)):
+ for _ in range(int(duration / 0.001)):
simulator.step()
time.sleep(0.001)
simulator.close()
-if __name__ == "__main__":
+def main() -> None:
parser = argparse.ArgumentParser(description="Test the MuJoCo simulation.")
parser.add_argument("--model-path", type=str, required=True, help="Path to MuJoCo XML model file")
parser.add_argument("--duration", type=float, default=5.0, help="Duration to run simulation (seconds)")
@@ -25,3 +25,8 @@ def test_simulation(model_path: str, duration: float = 5.0, speed: float = 1.0,
args = parser.parse_args()
test_simulation(args.model_path, duration=args.duration, speed=args.speed, render=not args.no_render)
+
+
+if __name__ == "__main__":
+ # python -m kos_sim.test_simulator
+ main()
diff --git a/kos_sim/test_viewer.py b/kos_sim/test_viewer.py
index e3f0235..f270d1a 100644
--- a/kos_sim/test_viewer.py
+++ b/kos_sim/test_viewer.py
@@ -1,18 +1,62 @@
-"""Test script for the viewer."""
+"""Test script for the viewer.
+
+This script is used to test the viewer.
+
+Usage:
+
+python -m kos_sim.test_viewer
+"""
+
+import asyncio
+import math
import mujoco
import mujoco_viewer
+from kscale import K
+
+api = K()
+
+# Gets the base path.
+# zbot_dir = asyncio.run(api.download_and_extract_urdf("zbot-v2"))
+# zbot_mjcf = next(zbot_dir.glob("*.mjcf"))
+
+zbot_mjcf = "/Users/ben/Github/urdfs/bots/kbot/gpr-20241204.mjcf"
-model = mujoco.MjModel.from_xml_path("models/gpr/robot_fixed.xml")
+model = mujoco.MjModel.from_xml_path(str(zbot_mjcf))
data = mujoco.MjData(model)
# create the viewer object
viewer = mujoco_viewer.MujocoViewer(model, data)
+# Get simulation timestep
+timestep = model.opt.timestep
+last_update = asyncio.get_event_loop().time()
+start_time = last_update
+
+mujoco.mj_step(model, data)
+
# simulate and render
for _ in range(100000):
if viewer.is_alive:
- mujoco.mj_step(model, data)
+ current_time = asyncio.get_event_loop().time()
+ sim_time = current_time - last_update
+
+ # Calculate elapsed time since start for sinusoidal motion
+ elapsed_time = current_time - start_time
+
+ # Apply sinusoidal motion to each joint
+ # Adjust amplitude and frequency as needed
+ amplitude = 0.5 # radians
+ frequency = 0.5 # Hz
+ for i in range(model.nu):
+ data.ctrl[i] = amplitude * math.sin(2 * math.pi * frequency * elapsed_time)
+
+ # Step the simulation to match real time
+ # while sim_time > 0:
+ # mujoco.mj_step(model, data)
+ # sim_time -= timestep
+
+ last_update = current_time
viewer.render()
else:
break