Skip to content

Commit

Permalink
first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
WT-MM committed Jan 14, 2025
1 parent eba77c8 commit 0518211
Show file tree
Hide file tree
Showing 35 changed files with 1,358 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ build/
dist/
*.so
out*/

# dev
ref/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ push-to-pypi: build-for-pypi
# Static Checks #
# ------------------------ #

py-files := $(shell find . -name '*.py')
py-files := $(shell find . -name '*.py' -not -path "./ref/*")

format:
@black $(py-files)
Expand Down
49 changes: 49 additions & 0 deletions kos_sim/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""Configuration for the simulator."""

import logging
from dataclasses import dataclass

import yaml

logger = logging.getLogger(__name__)


@dataclass
class SimulatorConfig:
joint_id_to_name: dict[int, str]
joint_name_to_id: dict[str, int]
kp: float = 32.0
kd: float = 10.0

@classmethod
def from_file(cls, config_path: str) -> "SimulatorConfig":
"""Load config from YAML file."""
with open(config_path, "r") as f:
config_data = yaml.safe_load(f)

# Load joint mappings
joint_name_to_id = config_data.get("joint_mappings", {})
joint_id_to_name = {v: k for k, v in joint_name_to_id.items()}

# Load control parameters
kp = config_data.get("control", {}).get("kp", 1.0)
kd = config_data.get("control", {}).get("kd", 0.1)

return cls(joint_id_to_name=joint_id_to_name, joint_name_to_id=joint_name_to_id, kp=kp, kd=kd)

@classmethod
def default(cls) -> "SimulatorConfig":
"""Create default config with standard joint mappings."""
joint_name_to_id = {
"L_hip_y": 1,
"L_hip_x": 2,
"L_hip_z": 3,
"L_knee": 4,
"L_ankle_y": 5,
"R_hip_y": 6,
"R_hip_x": 7,
"R_hip_z": 8,
"R_knee": 9,
"R_ankle_y": 10,
}
return cls(joint_id_to_name={v: k for k, v in joint_name_to_id.items()}, joint_name_to_id=joint_name_to_id)
13 changes: 13 additions & 0 deletions kos_sim/models/gpr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 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
<joint name="floating_base" type="fixed">
<origin rpy="-1.57 3.14 0" xyz="0 0 0"/>
<parent link="base"/>
<child link="body1-part"/>
</joint>

4. Fix left leg axes to align with expected directions
5. urf2mjcf robot.urdf -o robot.xml

Empty file added kos_sim/models/gpr/__init__.py
Empty file.
Binary file added kos_sim/models/gpr/meshes/arm1_top.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/arm1_top_2.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/arm2_shell.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/arm2_shell_2.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/arm3_shell.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/arm3_shell2.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/body1-part.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/foot1.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/foot3.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/hand_shell.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/hand_shell_2.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/leg0_shell.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/leg0_shell_2.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/leg1_shell.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/leg1_shell3.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/leg2_shell.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/leg2_shell_2.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/leg3_shell2.stl
Binary file not shown.
Binary file added kos_sim/models/gpr/meshes/leg3_shell22.stl
Binary file not shown.
Loading

0 comments on commit 0518211

Please sign in to comment.