-
Notifications
You must be signed in to change notification settings - Fork 10
Support !degree & !randians yaml prefixes #7
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
base: main
Are you sure you want to change the base?
Conversation
MarqRazz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JafarAbdi the changes look simple enough but do we have a easy way to test this? I though I had a quick way but I don't have a moveit_config that uses the param_builder.
The ur_moveit_launch.py does not use it.
Maybe we could add it to the moveit_resources_panda_robot demo.launch.py so we can verify this is working properly.
| try: | ||
| yaml.SafeLoader.add_constructor("!radians", construct_angle_radians) | ||
| yaml.SafeLoader.add_constructor("!degrees", construct_angle_degrees) | ||
| except Exception: | ||
| raise Exception("yaml support not available; install python-yaml") | ||
|
|
||
| try: | ||
| with open(file_path, "r") as file: | ||
| return yaml.load(file, Loader=yaml.FullLoader) | ||
| except EnvironmentError: # parent of IOError, OSError *and* WindowsError where available | ||
| return yaml.safe_load(file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on this resource and some limitation I found when integrating this in Studio, I have a suggestion.
First, make a function like this which we can use standalone:
def get_yaml_loader():
"""Gets a YAML loader that additionally supports custom constructors."""
loader = yaml.SafeLoader
loader.add_constructor("!radians", construct_angle_radians)
loader.add_constructor("!degrees", construct_angle_degrees)
return loader
Then, in your implementation, you can do:
def load_yaml(file_path: Path, loader=get_yaml_loader()):
...
return yaml.load(file, Loader=loader)
Co-authored-by: Sebastian Castro <4603398+sea-bass@users.noreply.github.com>
Co-authored-by: Sebastian Castro <4603398+sea-bass@users.noreply.github.com>
|
Replaced with #9 |
This's makes it so it's possible to have '!degrees' and '!radians' in the yaml config files (UR's joint limits for an example)