Skip to content

Conversation

@JafarAbdi
Copy link
Contributor

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)

Copy link

@MarqRazz MarqRazz left a 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.

Comment on lines +87 to +95
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)
Copy link

@sea-bass sea-bass Feb 27, 2023

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)

JafarAbdi and others added 2 commits February 27, 2023 22:52
Co-authored-by: Sebastian Castro <4603398+sea-bass@users.noreply.github.com>
Co-authored-by: Sebastian Castro <4603398+sea-bass@users.noreply.github.com>
@JafarAbdi
Copy link
Contributor Author

Replaced with #9

@JafarAbdi JafarAbdi closed this Apr 21, 2023
@JafarAbdi JafarAbdi reopened this Apr 22, 2023
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

Successfully merging this pull request may close these issues.

3 participants