Parameter service behavior is inconsistent with the documentation of rcl_interfaces
Los mantenedores suelen responder en 1 día
@fujitatomoya ya está trabajando en esto.
Desde el 29/4/2024.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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.
- Lenguaje dominante
- C++
- Estrellas
- 829
- Forks
- 587
- Merge medio
- 4 d 6 h
- PR fusionados (30 d)
- 30
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ros2/rclcpp
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 1 día
-
Memory grows per callback group created and destroyed on long lived nodesPosiblemente ocupada @jwallace42 la tomó hace 1 día. Abiertobug
Dificultad 4/5 3-5 días Aptitud para principiantes 28/100
ros2/rclcpp#3428 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
removing and immediately re-adding a node to the EventsCBGExecutor leaves its entities unregisteredPosiblemente ocupada @skyegalaxy la tomó hace 10 días. Abiertobug
ros2/rclcpp#3418 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[Humble] Removing a node with more than one auto-added callback group leaves a dangling guard condition in the executorPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
ros2/rclcpp#3410 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de ros2/rclcpp
Issues similares
-
arch-based bug niri
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
noctalia-dev/noctalia#5552 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 1/5 1-3 horas Aptitud para principiantes 82/100
EchoTools/nevr-runtime#2912 ·
Los mantenedores suelen responder en 1 día
-
area/docdb kind/failing-test priority/medium status/awaiting-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
yugabyte/yugabyte-db#39462 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
meshtastic/firmware#12519 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
Los mantenedores suelen responder en 1 día