Parameter service behavior is inconsistent with the documentation of rcl_interfaces
I maintainer di solito rispondono entro 1 giorno
@fujitatomoya ci sta già lavorando.
Dal 29/4/2024.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Bug report
Required Info:
- Operating System:
- Ubuntu 22.04
- Installation type:
- Any
- Version or commit hash:
- Iron / Humble
- DDS implementation:
- Any
- Client library (if applicable):
- rclcpp and rclpy
While implementing parameter services for rclrs, we noticed that the behavior of rclcpp and rclpy is inconsistent with the documentation of rcl_interfaces/srv/GetParameterTypes which says it returns a "List of types which is the same length and order as the provided names." and also "ParameterType.PARAMETER_NOT_SET indicates that the parameter is not currently set.".
However in the implementation of rclcpp and rclpy, if the node is set with allow_undeclared_parameters(false) and the service request includes an undeclared parameter, you get an empty response back:
$ ros2 service call /minimal_publisher/get_parameter_types rcl_interfaces/srv/GetParameterTypes "{names: [use_sim_time, hello]}"
requester: making request: rcl_interfaces.srv.GetParameterTypes_Request(names=['use_sim_time', 'hello'])
response:
rcl_interfaces.srv.GetParameterTypes_Response(types=[])
This contradicts the documentation for the service, which does not indicate any situation in which the response array would be a different size from the request array.
It seems the current behavior of rclcpp and rclpy was an intentional choice with the rationale that asking about an undeclared parameter should be seen as an error. However the mismatch between the behavior of the client libraries and the service documentation means either:
- the client libraries must be changed to match the service documentation, or
- the service documentation must be changed to match the client library behavior.
I would argue that the current service documentation makes more sense than the client library behavior, so the client libraries should change their behavior to comply with it for the following reasons:
- Returning an empty array is unhelpful whether the client is a human or a program. It provides the least amount of information possible in response to the service request and forces clients to always make multiple service requests in order to reliably detect the values of parameters.
- The concept of declared / undeclared does not even exist in
rcl_interfaces. I see parameter declaration as an implementation detail for parameter management that's internal to a node. Clients of parameter services should not generally need to be concerned about parameter declaration settings within a node that they are querying, but the current behavior is leaking that abstraction into the behavior of the parameter services. - An undeclared parameter in an
allow_undeclared_parameters(false)node can be thought of as unsettable, and therefore its value is just permanently unset. Naturally this means any client asking for the value of that parameter should be told that the value of the parameter is unset. - If we guarantee that the response array is always the same size as the request array, we reduce the likelihood that clients will write an accidental buffer overflow while iterating through the request and response arrays simultaneously because they weren't aware of the service behavior diverging due to parameter declaration.
Furthermore if a client calls rcl_interfaces/srv/SetParameters with an undeclared parameter on a node with allow_undeclared_parameters(false) then the client libraries should return something like { successful: false, reason: "Parameter is not declared by the node, which only allows declared parameters" } where the reason value is a fixed and consistent string literal across all client libraries so that parameter service clients can do a simple string comparison against. I would recommend defining the string literal inside of rcl_interfaces/msg/SetParametersResult with a name like REASON_UNDECLARED_PARAMETER. Currently rclcpp and rclpy produce different reason values for this same situation. Admittedly the service documentation says that reason should only be read by humans, but I think this particular case warrants a fixed and consistent value.
I'm happy to submit PRs for these recommended changes, but I thought I'd open a discussion on this first in case there are any strong objections. Tagging @fujitatomoya @ivanpauno and @wjwwood as the main people who participated in the original discussion.
- Lingua principale
- C++
- Stelle
- 829
- Fork
- 587
- Merge medio
- 4g 6h
- PR unite (30g)
- 30
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ros2/rclcpp
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
-
Memory grows per callback group created and destroyed on long lived nodesForse già presa @jwallace42 l’ha presa 1 giorno fa. Apertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 28/100
ros2/rclcpp#3428 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
removing and immediately re-adding a node to the EventsCBGExecutor leaves its entities unregisteredForse già presa @skyegalaxy l’ha presa 10 giorni fa. Apertabug
ros2/rclcpp#3418 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[Humble] Removing a node with more than one auto-added callback group leaves a dangling guard condition in the executorForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
ros2/rclcpp#3410 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
arch-based bug niri
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
noctalia-dev/noctalia#5552 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
EchoTools/nevr-runtime#2912 ·
I maintainer di solito rispondono entro 1 giorno
-
area/docdb kind/failing-test priority/medium status/awaiting-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
yugabyte/yugabyte-db#39462 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
meshtastic/firmware#12519 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno