Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Urdf pybullet #2

Merged
merged 7 commits into from
Aug 20, 2024
Merged

Urdf pybullet #2

merged 7 commits into from
Aug 20, 2024

Conversation

nathanjzhao
Copy link
Contributor

@nathanjzhao nathanjzhao commented Aug 20, 2024

URDF + Pybullet CLI. Closes #1

There is bug in /store. Downloaded files are given .stl when they are .obj. Results in invalid .stls

Copy link
Member

@codekansas codekansas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice :)

match parsed_args.subcommand:
case "urdf":
urdf.main(remaining_args)
case "urdf":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Comment on lines 94 to 107
p.addUserDebugLine(pt[0], pt[1], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)
p.addUserDebugLine(pt[1], pt[3], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)
p.addUserDebugLine(pt[3], pt[2], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)
p.addUserDebugLine(pt[2], pt[0], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)

p.addUserDebugLine(pt[0], pt[4], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)
p.addUserDebugLine(pt[1], pt[5], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)
p.addUserDebugLine(pt[2], pt[6], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)
p.addUserDebugLine(pt[3], pt[7], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)

p.addUserDebugLine(pt[4 + 0], pt[4 + 1], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)
p.addUserDebugLine(pt[4 + 1], pt[4 + 3], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)
p.addUserDebugLine(pt[4 + 3], pt[4 + 2], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)
p.addUserDebugLine(pt[4 + 2], pt[4 + 0], color, 1, parentObjectUniqueId=obj_id, parentLinkIndex=link_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there must be a way to clean this up...

Comment on lines 125 to 134
pt = [
[half_extents[0], half_extents[1], half_extents[2]],
[-half_extents[0], half_extents[1], half_extents[2]],
[half_extents[0], -half_extents[1], half_extents[2]],
[-half_extents[0], -half_extents[1], half_extents[2]],
[half_extents[0], half_extents[1], -half_extents[2]],
[-half_extents[0], half_extents[1], -half_extents[2]],
[half_extents[0], -half_extents[1], -half_extents[2]],
[-half_extents[0], -half_extents[1], -half_extents[2]],
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, probably can clean up

Comment on lines 20 to 24
def fetch_urdf_info(listing_id: str) -> dict:
url = f"https://api.kscale.store/urdf/info/{listing_id}"
response = requests.get(url)
response.raise_for_status()
return response.json()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe there should be a way to use the auto-generated pydantic types here so that you don't have untyped requests and responses, however, i haven't figured it out yet

filename = os.path.join(cache_dir, artifact_url.split("/")[-1])

if not os.path.exists(filename):
logger.info(f"Downloading artifact from {artifact_url}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: don't use format strings in logger messages

Suggested change
logger.info(f"Downloading artifact from {artifact_url}")
logger.info("Downloading artifact from %s", artifact_url)

artifact_url = urdf_info["urdf"]["url"]
download_artifact(artifact_url, CACHE_DIR)
except requests.RequestException as e:
logger.error(f"Failed to fetch URDF info: {e}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto with earlier

Comment on lines 91 to 92
urdf_info = fetch_urdf_info(listing_id)
artifact_url = urdf_info["urdf"]["url"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should pre-parse with pydantic so we can use dot lookup instead of going by dict keys

logger.error(f"Failed to upload artifact: {e}")
sys.exit(1)
else:
print("Invalid command")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print statements make me sad :(

[options.entry_points]

console_scripts =
kscale = kscale.store.cli:main
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

setup.py Outdated
@@ -32,7 +32,7 @@
url="https://github.com/kscalelabs/kscale",
long_description=long_description,
long_description_content_type="text/markdown",
python_requires=">=3.11",
# python_requires=">=3.11",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sad :( we should add this back

@nathanjzhao
Copy link
Contributor Author

changed all but pydantic stuff

…-- i think it's probably a problem on the fastapi end though
@codekansas codekansas merged commit 44cf270 into kscalelabs:master Aug 20, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Manage URDFs from command line
2 participants