Skip to content
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

Broken ROS2 GetParameters service response if any of the parameter is declared but not defined #924

Closed
EwingKang opened this issue Aug 22, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@EwingKang
Copy link

EwingKang commented Aug 22, 2024

Bug report

Required Info:

  • Operating System:
    • Ubuntu 22.04
  • Installation type:
    • binaries
  • Version or commit hash:
    • IRON
  • DDS implementation:
    • N/A
  • Client library (if applicable):
    • ros cli (ros service)

Empty/ broken GetParameters service response if any of the parameter is declared but not defined.

Steps to reproduce issue

//my_node.cpp....

// declare parameters with default value
this->declare_parameter("alpha", 0.3, desc("alpha"));
this->declare_parameter("beta", 5.0, desc("beta"));

// This parameter is declared without default value causes problem
this->declare_parameter("help", rclcpp::PARAMETER_BOOL);

//...

Call the GetParameters service returns fine:

ros2 service call /my_node/get_parameters rcl_interfaces/srv/GetParameters "{names: [alpha, beta]}"

# Response
requester: making request: rcl_interfaces.srv.GetParameters_Request(names=['alpha', 'beta'])

response:
rcl_interfaces.srv.GetParameters_Response(values=[rcl_interfaces.msg.ParameterValue(type=3, bool_value=False, integer_value=0, double_value=0.3, string_value='', byte_array_value=[], bool_array_value=[], integer_array_value=[], double_array_value=[], string_array_value=[]), rcl_interfaces.msg.ParameterValue(type=3, bool_value=False, integer_value=0, double_value=5.0, string_value='', byte_array_value=[], bool_array_value=[], integer_array_value=[], double_array_value=[], string_array_value=[])])

However, if any one of the requested parameter has no default parameter, the entire service call returns broken entry

ros2 service call /my_node/get_parameters rcl_interfaces/srv/GetParameters "{names: [alpha, beta, help]}"

# Response
waiting for service to become available...
requester: making request: rcl_interfaces.srv.GetParameters_Request(names=['alpha', 'beta', 'help'])

response:
rcl_interfaces.srv.GetParameters_Response(values=[])

Expected behavior

For parameters with default value, return normally; for parameters without default value, some sort of flag to mark the situation

Actual behavior

As described above

Additional information

I believe this is related to ros-visualization/rqt_reconfigure#142

@EwingKang EwingKang changed the title Empty ROS2 GetParameters service response if any of the parameter is declared but not defined Broken ROS2 GetParameters service response if any of the parameter is declared but not defined Aug 22, 2024
@EwingKang
Copy link
Author

This might be related to: ros2/rclcpp#2512

@fujitatomoya
Copy link
Collaborator

@EwingKang thanks for posting issue. a couple of things i want to confirm.

Call the DescribeParameters service returns fine:

it looks like you are calling GetParameters service, is this typo?

ros2 service call /my_node/get_parameters rcl_interfaces/srv/GetParameters "{names: [alpha, beta]}"

where is this beta defined? is this supposed to be lamda?

can you check the issue description? i just want to be sure the issue description.

@EwingKang
Copy link
Author

@fujitatomoya I'm terribly embarrassed by the mistake! I fixed the description.
Thanks for catching the error! It is exactly like what you imagine. Things were lost during copy and paste.
Please let me know if there's any confusion, thanks!

@fujitatomoya
Copy link
Collaborator

@EwingKang thanks for checking this.

as you mentioned, this is similar with ros2/rclcpp#2512 which explains specifically on GetParameterTypes but the point is inconsistent behavior against documentation.

Here it complains about GetParameter, the behavior also does not match with https://docs.ros2.org/galactic/api/rcl_interfaces/srv/GetParameterTypes.html.

@fujitatomoya fujitatomoya added the bug Something isn't working label Aug 22, 2024
@fujitatomoya
Copy link
Collaborator

Note: I think this issue can move to rclcpp repository since the service server is implemented in rclcpp that responds the service request via ros2cli.

@sloretz
Copy link
Contributor

sloretz commented Aug 29, 2024

Thank you for the report! Closing as a duplicate of ros2/rclcpp#2512 🧇

@sloretz sloretz closed this as completed Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants