Fix: Ensure parameters are initialized with default values if undefined in params.yml
#5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This merge request resolves the issue where parameters declared in a Python ROS2 node were not being initialized when missing from
params.yml
. This caused the parameters to be inaccessible in parameter management tools likerqt
and unavailable viaros2 param get
commands.Issue Reference:
Closes #4.
Changes:
params.yml
.set_parameters
after declaring the parameters to register them correctly.Steps to Reproduce:
The issue can be reproduced as follows:
param2
inparams.yml
.rqt
or viaros2 param get
. After the fix, the declared parameter should be initialized and visible.Testing:
params.yml
are initialized with default values.rqt
.ros2 param
commands (e.g.,ros2 param get
) correctly display the parameters.Impact:
This fix does not break existing functionality. Instead, it ensures that declared parameters are initialized properly, even if not defined in external configuration files.
Screenshots/Logs:
(Optional: Include screenshots or logs demonstrating the fix in action. For example, a screenshot of
rqt
showing the previously missing parameter.)Code Snippet of the Fix: