Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Aug 20, 2024
1 parent 44cf270 commit baaa44f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion kscale/formats/mjcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,4 +503,4 @@ def adapt_world(self) -> None:
self.tree = ET.ElementTree(root)

def save(self, path: str | Path) -> None:
self.tree.write(path, encoding="utf-8")
self.tree.write(path, encoding="utf-8")
18 changes: 11 additions & 7 deletions kscale/store/pybullet.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


def main(args: Sequence[str] | None = None) -> None:

parser = argparse.ArgumentParser(description="Show a URDF in PyBullet")
parser.add_argument("urdf", nargs="?", help="Path to the URDF file")
parser.add_argument("--dt", type=float, default=0.01, help="Time step")
Expand Down Expand Up @@ -96,7 +95,9 @@ def draw_box(pt: list[list[float]], color: tuple[float, float, float], obj_id: i
for i in range(4):
p.addUserDebugLine(pt[i], pt[i + 4], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)
p.addUserDebugLine(pt[i], pt[mapping[i]], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)
p.addUserDebugLine(pt[i + 4], pt[mapping[i] + 4], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)
p.addUserDebugLine(
pt[i + 4], pt[mapping[i] + 4], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id
)

# Shows bounding boxes around each part of the robot representing the inertia frame.
if parsed_args.show_inertia:
Expand All @@ -114,11 +115,14 @@ def draw_box(pt: list[list[float]], color: tuple[float, float, float], obj_id: i
box_scale_z = 0.5 * math.sqrt(6 * (ixx + iyy - izz) / mass)

half_extents = [box_scale_x, box_scale_y, box_scale_z]
pt = [[x, y, z] for x, y, z in itertools.product(
[-half_extents[0], half_extents[0]],
[-half_extents[1], half_extents[1]],
[-half_extents[2], half_extents[2]]
)]
pt = [
[x, y, z]
for x, y, z in itertools.product(
[-half_extents[0], half_extents[0]],
[-half_extents[1], half_extents[1]],
[-half_extents[2], half_extents[2]],
)
]
draw_box(pt, (1, 0, 0), robot, i)

# Show joint controller.
Expand Down
3 changes: 1 addition & 2 deletions kscale/store/urdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,14 @@ async def upload_artifact(tarball_path: str, listing_id: str, api_key: str) -> N


def main(args: Sequence[str] | None = None) -> None:

command = args[0]
listing_id = args[1]

if command == "get":
try:
api_key = os.getenv("KSCALE_API_KEY") or (args[2] if len(args) >= 3 else None)
urdf_info = fetch_urdf_info(listing_id, api_key)

if urdf_info.urdf:
artifact_url = urdf_info.urdf.url
asyncio.run(download_artifact(artifact_url, CACHE_DIR, api_key))
Expand Down

0 comments on commit baaa44f

Please sign in to comment.