-
Notifications
You must be signed in to change notification settings - Fork 227
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
feat: enable plugin allowlist #264
feat: enable plugin allowlist #264
Conversation
Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>
@gbiggs @jacobperron @ijnek Could you review this PR? Also, I wolud like to backport this change into humble. |
Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp> Signed-off-by: wep21 <border_goldenmarket@yahoo.co.jp>
52d6751
to
c5c1d99
Compare
image_transport/src/publisher.cpp
Outdated
@@ -110,9 +110,23 @@ Publisher::Publisher( | |||
impl_->base_topic_ = image_topic; | |||
impl_->loader_ = loader; | |||
|
|||
uint ns_len = node->get_effective_namespace().length(); |
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.
Can param_base_name
just be equal to base_topic
, rather than stripping off the namespace here?
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.
@gbiggs @ijnek This comes from image_transport_plugins
.
Which is better?
- use base topic name
This looks like below.
/usb_cam:
ros__parameters:
image_raw:
enable_pub_plugins:
- image_transport/compressed
format: jpeg
jpeg_quality: 95
png_level: 3
tiff:
res_unit: inch
xdpi: -1
ydpi: -1
- use whole topic name
This looks like below.
/usb_cam:
ros__parameters:
image_raw:
format: jpeg
jpeg_quality: 95
png_level: 3
tiff:
res_unit: inch
xdpi: -1
ydpi: -1
/aaa/bbb/image_raw:
enable_pub_plugins:
- image_transport/compressed
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.
Just the base topic name seems better.
As this seems like a revival of a feature that existed in ROS 1, I'd like the maintainers to decide on these changes. I do agree that a publisher getting created for every image transport plugin installed is annoying, but a whitelist sounds like a better idea than a blacklist. |
friendly ping @gbiggs @jacobperron |
Please change this to use a whitelist rather than a blacklist, with an additional option to enable all publishers. |
Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>
Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>
Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>
Should probably add all available transports to the whitelist is there are no plugins listed under |
@ijnek okay, I will set all the plugins as a default parameter. |
Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>
@wep21 Apologies for the delay. I'm just reviewing again, and I think there is no need for a separate std::set and a std::vector, if you simplify: for (const auto & lookup_name : loader->getDeclaredClasses()) {
const std::string transport_name = erase_last_copy(lookup_name, "_pub");
if (whitelist.count(transport_name)) {
try {
auto pub = loader->createUniqueInstance(lookup_name);
pub->advertise(node, image_topic, custom_qos, options);
impl_->publishers_.push_back(std::move(pub));
} catch (const std::runtime_error & e) {
RCLCPP_ERROR(
impl_->logger_, "Failed to load plugin %s, error string: %s\n",
lookup_name.c_str(), e.what());
}
}
} to: for (transport_name : whitelist_vec) {
try {
auto pub = loader->createUniqueInstance(transport_name);
pub->advertise(node, image_topic, custom_qos, options);
impl_->publishers_.push_back(std::move(pub));
} catch (const std::runtime_error & e) {
RCLCPP_ERROR(
impl_->logger_, "Failed to load plugin %s, error string: %s\n",
transport_name.c_str(), e.what());
}
} Please check that these changes do work, as I haven't tested it. |
Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>
image_transport/src/publisher.cpp
Outdated
param_base_name + | ||
".enable_pub_plugins").get_value<std::vector<std::string>>(); | ||
} | ||
for (size_t i = 0; i < whitelist_vec.size(); ++i) { |
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.
What is the purpose of copying the contents of the vector into a set if you're then just going to iterate over it?
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.
@gbiggs This is from original code, but I guess this removes duplicated plugins declared in the parameters.
image_transport/src/publisher.cpp
Outdated
} | ||
|
||
std::vector<std::string> whitelist_vec; |
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.
Please use the term "allowlist" instead of "whitelist".
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.
Signed-off-by: wep21 <daisuke.nishimatsu1021@gmail.com>
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.
@gbiggs can we merge this ?
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.
can you take a look to this windows failures ? https://ci.ros2.org/job/ci_windows/19910/console
Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde Thank you for suggesting the fix. Could you run ci again? |
@wep21 Thank you for the PR. Do you also plan to merge these changes into |
Yes, it would be great to have this in |
Yes, would also love to have this on humble |
I enabled plugin blacklist for image transport publisher.
usage: