Allow different namespaces for custom parameters #172
Merged
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 PR builds off of #146 by allowing multiple namespaces of parameter overrides. Specifically, custom parameters now work as follows:
default
parameters are (still) read-only.custom_namespaces
(list of strings) that defines custom namespaces.tree_kwarg
fromdefault
, e.g.,MoveToMouth.tree_kwargs.plan_distance_from_mouth
. (Note: this PR removes the need to list our all overridden parameters; if a parameter has a value, it treats it as an override.)namespace_to_use
(default:”default”
) that specifies which namespace to use.namespace_to_use
and alltree_kwargs
are the only re-writeable parameters. Ifnamespace_to_use
is set to a namespace that does not currently exist, it will create it and declare alltree_kwarg
parameters within it.Testing
python3 src/ada_feeding/start.py --sim mock
feeding
screen launched without error.ros2 param list | grep tree_kwargs
, verify that the only namespace fortree_kwargs
isdefault
ros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'namespace_to_use', value: {type: 4, string_value: 'test_namespace'}}]}"
ros2 param list | grep tree_kwargs
, verify the new namespace is thereinstall
folder of the workspace) openada_feeding_action_servers_custom.yaml
, verifycustom_namespaces
is now there with the value of the new namespace, and the namespace has no parameters.ros2 service call /ada_feeding_action_servers/get_parameters rcl_interfaces/srv/GetParameters "{names: ['test_namespace.MoveAbovePlate.tree_kwargs.f_mag']}"
ros2 service call /ada_feeding_action_servers/get_parameters rcl_interfaces/srv/GetParameters "{names: ['default.MoveAbovePlate.tree_kwargs.f_mag']}"
ros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'default.MoveAbovePlate.tree_kwargs.f_mag', value: {type: 3, double_value: 1.0}}]}"
test_namespace
parameter to an incorrect type, and verify that it failes: e.g.,ros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'test_namespace.MoveAbovePlate.tree_kwargs.f_mag', value: {type: 4, string_value: 'ASDFGHJKL'}}]}"
install
folder of the workspace),ada_feeding_action_servers_custom.yaml
is unchanged.test_namespace
parameter to a correct type, and verify that it works: e.g.,ros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'test_namespace.MoveAbovePlate.tree_kwargs.f_mag', value: {type: 3, double_value: 1.0}}]}"
install
folder of the workspace),ada_feeding_action_servers_custom.yaml
has changed to reflect the overridden parameter.MoveAbovePlate
tree was re-created.default
and verify that it is unchanged (should be 4.0): e.g.,ros2 service call /ada_feeding_action_servers/get_parameters rcl_interfaces/srv/GetParameters "{names: ['default.MoveAbovePlate.tree_kwargs.f_mag']}"
test_namespace
value of the param and verify it is set correctly (should be 1.0): e.g.,ros2 service call /ada_feeding_action_servers/get_parameters rcl_interfaces/srv/GetParameters "{names: ['test_namespace.MoveAbovePlate.tree_kwargs.f_mag']}"
ros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'test2_namespace.MoveAbovePlate.tree_kwargs.f_mag', value: {type: 3, double_value: 1.0}}]}"
ros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'namespace_to_use', value: {type: 4, string_value: 'test2_namespace'}}]}"
, verify that the YAML file updates as expectedros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'test2_namespace.MoveAbovePlate.tree_kwargs.f_mag', value: {type: 3, double_value: 1.0}}]}"
, verify it is updated correctly in the yaml file.ros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'namespace_to_use', value: {type: 4, string_value: 'default'}}]}"
,test_namespace
to 5cm:ros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'test_namespace.MoveToMouth.tree_kwargs.plan_distance_from_mouth', value: {type: 8, double_array_value: [0.05, 0.0, -0.01]}}]}"
test1_namespace
to 10cm:ros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'test2_namespace.MoveToMouth.tree_kwargs.plan_distance_from_mouth', value: {type: 8, double_array_value: [0.1, 0.0, -0.01]}}]}"
ros2 action send_goal /MoveToStagingConfiguration ada_feeding_msgs/action/MoveTo "{}" --feedback
ros2 action send_goal /MoveToMouth ada_feeding_msgs/action/MoveToMouth "{}" --feedback
test_namespace
:ros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'namespace_to_use', value: {type: 4, string_value: 'test_namespace'}}]}"
ros2 action send_goal /MoveFromMouth ada_feeding_msgs/action/MoveTo "{}" --feedback
ada_feeding
codetest2_namespace
:ros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'namespace_to_use', value: {type: 4, string_value: 'test2_namespace'}}]}"
test2_namespace
to 20cm:ros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'test2_namespace.MoveToMouth.tree_kwargs.plan_distance_from_mouth', value: {type: 8, double_array_value: [0.2, 0.0, -0.01]}}]}"
default
:ros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'namespace_to_use', value: {type: 4, string_value: 'default'}}]}"
Before opening a pull request
python3 -m black .
ada_feeding
directory, run:pylint --recursive=y --rcfile=.pylintrc .
.Before Merging
Squash & Merge