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

ros2 param dump does not work if a node has declared parameters without a value #936

Closed
reinzor opened this issue Sep 20, 2024 · 5 comments

Comments

@reinzor
Copy link

reinzor commented Sep 20, 2024

Bug report

Required Info:

  • Operating System:

Ubuntu 24.04

  • Installation type:

Debian package

  • Version or commit hash:
0.32.1
  • DDS implementation:

Cyclone

Steps to reproduce issue

python3 -c "import rclpy; rclpy.init(); node = rclpy.create_node('test'); node.declare_parameter('param', rclpy.Parameter.Type.INTEGER); rclpy.spin(node)"
ros2 param dump /test

Expected behavior

Correct yaml file

Actual behavior

UnboundLocalError: cannot access local variable 'e' where it is not associated with a value, should be fixed with #933 but then it will return an empty yaml file.

Additional information

Follow up of cra-ros-pkg/robot_localization#903, related to #930

@fujitatomoya
Copy link
Collaborator

@reinzor thanks for creating issue.

i just want to confirm that #933 can fix this issue as well, right?

@reinzor
Copy link
Author

reinzor commented Sep 21, 2024

No, it will not fix this behavior. It will only ensure that no UnboundLocalError is raised. Instead it will return an empty yaml. However, this is not correct.

@fujitatomoya
Copy link
Collaborator

@reinzor

so i tested with your example and #933 applied.

### your sample
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 run prover_rclpy ros2cli_936 

### dumping parameters
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 param dump /test
/test:
  ros__parameters: {}

it works as expected we have talked in #933 (comment)?

fujitatomoya added a commit to fujitatomoya/ros2_test_prover that referenced this issue Sep 23, 2024
@reinzor
Copy link
Author

reinzor commented Sep 24, 2024

Yes but this issue describes another problem.

python3 -c "import rclpy; rclpy.init(); node = rclpy.create_node('test'); node.declare_parameter('param', rclpy.Parameter.Type.INTEGER); rclpy.spin(node)"

Gives an empty output; but,

python3 -c "import rclpy; rclpy.init(); node = rclpy.create_node('test'); rclpy.spin(node)"

returns

/test:
  ros__parameters:
    start_type_description_service: true
    use_sim_time: false

So the problem is here that if we have one parameter without a value defined, the ros2 param dump command does not work. This is different from issue #930

@fujitatomoya
Copy link
Collaborator

@reinzor

Ah, yeah that is right. my expectation was wrong there...

So the thing is not related to ros2cli nor ros2param package, root cause why we end up having the empty parameter yaml file as output of ros2 param dum is ros2/rclcpp#2512. that explains well, but in quick, the GetParameter service response will be empty if any parameter undeclared or no default values.

I think we can proceed this behavior change with ros2/rclcpp#2512 (follow up needs to be done with rclpy for sure), so i will go ahead to close this issue. if you find specific issue on ros2cli, please feel free to reopen this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants