Skip to content

Conversation

rdelfin
Copy link
Contributor

@rdelfin rdelfin commented Sep 28, 2025

A lot of ROS libraries use generate_parameter_library to create parameter definitions with type information. This PR adds a bazel helper to use it and generate corresponding C++ and python libraries.

Copy link
Owner

@mvukov mvukov left a comment

Choose a reason for hiding this comment

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

💯

url = "https://github.com/ros/urdfdom_headers/archive/refs/tags/1.0.6.tar.gz",
)

maybe(
Copy link
Owner

Choose a reason for hiding this comment

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

This is an autogenerated file, please move this to e.g. within https://github.com/mvukov/rules_ros2/blob/main/repositories/repositories.bzl#L237.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I didn't realise this was autogenerated. I'll move it over

Comment on lines +17 to +18
requirement("Jinja2"),
requirement("typeguard"),
Copy link
Owner

Choose a reason for hiding this comment

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

You'll need to update the req inputs and to regenerate the python lock file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops... What I get for not checking from my test

load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_python//python:defs.bzl", "py_library")

def parameter_library(name, parameter_file, cpp_header_name = None, python_file_name = None):
Copy link
Owner

Choose a reason for hiding this comment

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

For me it's just fine to omit cpp_header_name and python_file_name and have them fixed.

Besides this, please split this macro to cc_ros2_parameter_library and py_ros2_parameter_library.

How is C++ namespace assigned?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, good question about the namespace! I'm not too sure, but let me see if that's configurable.
I put them together because of how I was using them, but splitting them into two makes a ton more sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I've checked through and the namespace is based on the contents of the parameter file, so if you put the parameters in a my_parameters dictionary in the yaml file, it will put everything in the my_parameters namespace. I think you can nest to get more nested namespaces.

py = "{}.py".format(name)
else:
py = python_file_name
native.genrule(
Copy link
Owner

Choose a reason for hiding this comment

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

I'd also create a python library that has this one as srcs.

@rdelfin
Copy link
Contributor Author

rdelfin commented Oct 5, 2025

I've added some fixes but they're incomplete, I'll re-request a review once I've gotten everything working

@rdelfin rdelfin force-pushed the parameter-library branch from a74cbd2 to 92a2ffd Compare October 5, 2025 21:27
@rdelfin rdelfin marked this pull request as ready for review October 5, 2025 21:27
@rdelfin rdelfin requested a review from mvukov October 5, 2025 21:27
@rdelfin
Copy link
Contributor Author

rdelfin commented Oct 5, 2025

Took me a bit of work, but managed to get it working 😄

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.

2 participants