Git Product home page Git Product logo

Comments (17)

dirk-thomas avatar dirk-thomas commented on July 18, 2024

The list parameters service call (https://github.com/ros2/rcl_interfaces/blob/master/rcl_interfaces/srv/ListParameters.srv) should provide that functionality. The service call is exposed as API in rclcpp as

RCLCPP_PUBLIC
rcl_interfaces::msg::ListParametersResult
list_parameters(
const std::vector<std::string> & parameter_prefixes,
uint64_t depth);

See http://design.ros2.org/articles/ros_parameters.html for the high level design.

from rclcpp.

firesurfer avatar firesurfer commented on July 18, 2024

Yeah. But what to pass for as prefix if I want to list all parameters? I already tried a empty list or * but it didn't work as far as I remember.

from rclcpp.

dirk-thomas avatar dirk-thomas commented on July 18, 2024

From looking at the implementation (

Node::list_parameters(
) I can't figure out how this is currently possible. Maybe @esteve can comment on this?

It would be good to also document the necessary arguments of this common use case in the .srv file.

from rclcpp.

gerkey avatar gerkey commented on July 18, 2024

#197 adds the ability to list all parameters by supplying an empty prefix list. ros2/system_tests#107 adds a test for it.

from rclcpp.

dirk-thomas avatar dirk-thomas commented on July 18, 2024

@gerkey Can you please run a CI job for it.

from rclcpp.

gerkey avatar gerkey commented on July 18, 2024

I'd like to get feedback on the approach. Is an empty prefix list and ignored depth a good way to list all parameters?

from rclcpp.

dirk-thomas avatar dirk-thomas commented on July 18, 2024

A think returning all parameters when an empty prefix list is passes is good (and this should be mentioned in the .srv file).

But the depth parameter should still be honored in that case.

from rclcpp.

gerkey avatar gerkey commented on July 18, 2024

Proposal: when the prefix list is empty, a depth of D means: return all parameters whose names contain <=D separators (currently the . character). Does that make sense?

from rclcpp.

dirk-thomas avatar dirk-thomas commented on July 18, 2024

I don't think <=D makes sense. D=1 should return everything without a separator - basically the first level. And of course also the parent group name for everything with a separator.

And I assume depth=0 has a similar semantic as an empty prefix list. So return all parameters with an arbitrary number of separators.

from rclcpp.

firesurfer avatar firesurfer commented on July 18, 2024

This doens't directly affects the approaches discussed before.
From the point of usability I think it's more convenient to have two methods in the rclcpp parameter_client.hpp.
The same as at the moment

list_parameters(
    const std::vector<std::string> & parameter_prefixes,
    uint64_t depth);

and another variant without any arguments

list_parameters();

I think that would be less confusing than empty arguments. Internally the second method could just call the first one with an empty parameter_prefixes vector.

from rclcpp.

gerkey avatar gerkey commented on July 18, 2024

I like the idea of adding the second signature of list_parameters() with no args. But we still need to decide the semantics for this query when it happens via a service call, independent of any particular client library. That is, we need to decide how to interpret the contents of the request in the rcl_interfaces/ListParameters service.

An empty prefixes list makes sense as a request for all parameters. And now that I've looked at the service spec, which defines DEPTH_RECURSIVE=0 (I didn't know that previously), I agree with @dirk-thomas's suggestion of having D==0 mean all depths, and D>0 mean all params with <D separators. I'll do that.

from rclcpp.

tfoote avatar tfoote commented on July 18, 2024

I agree that an empty list could be a special case, but I'd also argue that if you pass a zero length string as a prefix that should also match everything. Otherwise if you're passing an argument through from another source you would have to add special logic to detect the zero length prefix and follow a special special logic if you want to support the zero length prefix.

from rclcpp.

dirk-thomas avatar dirk-thomas commented on July 18, 2024

I don't think a prefix list with one empty string has the same semantic. I understood the semantic of the prefix as follows: a prefix foo

  • matches all parameters grouped under foo which means start with foo..
  • it does not match e.g. a parameter foobar

from rclcpp.

tfoote avatar tfoote commented on July 18, 2024

The question is whether you consider there to be an implicit separator at
the beginning.

foo matches foo.* but not foobar could be rewritten as
prefix matches ."prefix".*

but if you consider it more like a path with a leading separator and empty
string matches .* implying both foo and foobar would match.

If '' does not collapse and match any, I would expect that then we could
have zero length namespaces.
With that you would get things like ..foo..bar as distinct from .foo.bar.

from rclcpp.

gerkey avatar gerkey commented on July 18, 2024

In #230, I implemented the following strategy:

  • An empty prefixes list means that any parameter name will match.
  • Given the matches against prefixes, the depth argument is used to further filter the result to be those parameters that contain < depth separators. I.e., depth==1 means the first level, no separators allowed; depth==2 means the first and second level, at most 1 separator allowed; and so on. As a special case, depth==0 means all depths.

In ros2/system_tests#140 I added new tests for the empty prefixes case and updated other cases to account for the new handling of the depth argument.

from rclcpp.

gerkey avatar gerkey commented on July 18, 2024
  • Linux:
    • Build Status
  • OSX:
    • Build Status
  • Windows:
    • Build Status

from rclcpp.

gerkey avatar gerkey commented on July 18, 2024

New feature (belatedly) merged. Thanks for the request!

from rclcpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.