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

Add centimeter as an acceptable length unit and give error message more cotext #118

Open
RrezonPllana opened this issue Mar 25, 2024 · 3 comments

Comments

@RrezonPllana
Copy link

Motivation

I was trying to convert a robot of mine that I created in OnShape using onshape-to-robot <my-robot> but kept getting an error message Unknown unit: cm at first I really didn't understand what it meant until I spend couple of hours reading the whole onshape-to-robot repository, and then I saw in readExpression() method that the error was saying that my OnShape workspace length unit is centimeter something that is not supported by the project. So I tried to open a PR about this problem but I couldn't since I needed permission to write in the repository. The fix is below if someone wants to use it locally.

Fix

--- a/onshape_to_robot/features.py
+++ b/onshape_to_robot/features.py
@@ -49,11 +49,14 @@ def readExpression(expression):
             val = parts[0]
         return float(parts[0])
     elif parts[1] == 'mm':
-        return float(parts[0])/1000.0
+        return float(parts[0]) / 1000.0
+    elif parts[1] == 'cm':
+        return float(parts[0]) / 100.0
     elif parts[1] == 'm':
         return float(parts[0])
     else:
-        print(Fore.RED + 'Unknown unit: '+parts[1] + Style.RESET_ALL)
+        print(Fore.RED + 'Unknown unit: ' + parts[1] + '. Acceptable workspace units for angle are: radians or degrees, and for length '
+                                                       'are: millimeter, centimeter, or meter.' + Style.RESET_ALL)
         exit()
@javiCuara
Copy link

I am having a similar issue with:
"Unknown unit: in "
My project and account settings are all set to meter ...

@Gregwar
Copy link
Contributor

Gregwar commented Apr 18, 2024

I think that some unit can be enforcedly defined to inches somewhere (maybe in some part you imported for e.g.)
We could support them though

@Gregwar
Copy link
Contributor

Gregwar commented Apr 18, 2024

I added cm and in in 0.3.25 that I just pushed on pip, can you give it a try @javiCuara ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants