-
Notifications
You must be signed in to change notification settings - Fork 4
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
Allow parameter changes while keeping defaults #146
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally fine given the test cases. Just one nit and 2 non-fatal concerns.
This is a pretty elegant solution for saving parameters!
@@ -90,7 +90,7 @@ def __init__( | |||
allowed_face_distance: Tuple[float, float] = (0.4, 1.25), | |||
face_detection_msg_timeout: float = 5.0, | |||
face_detection_timeout: float = 2.5, | |||
plan_distance_from_mouth: Tuple[float, float, float] = (0.025, 0.0, -0.01), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doe we expect this to ever not be 3D? When?
If not, we should keep it a Tuple to enforce the size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We always expect it to be length 3, but the issue is that ROS2 params cannot be of type tuple, only type list. And Python's typing interface doesn't currently allow us to specify a length for Lists.
However, I found this discussion in the mypy
library, which is a static type checker for Python. So I'll change it to Annotated[Sequence[float], 3]
so that future Python type checkers can verify it.
@@ -473,7 +610,7 @@ def shutdown(self) -> None: | |||
Shutdown the node. | |||
""" | |||
self.get_logger().info("Shutting down CreateActionServers") | |||
for tree in self._trees: | |||
for _, tree in self._trees.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: you can use .values
@@ -0,0 +1,6 @@ | |||
# This file is auto-generated by create_action_servers.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that this is in a commit and is updated by code, it should be added to .gitignore
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially put it in the .gitignore
, but then realized that .gitignore
doesn't do anything for files that are already in the repository. It seems like (based on this thread) the only thing we can do is running git update-index --assume-unchanged ada_feeding/config/ada_feeding_action_servers_current.yaml
in our local copy, but we can't do any global configurations to ignore changes to this file.
I'd say we just have to be vigilant in PRs to verify changes to this file are not pushed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think update-index --assume-unchanged
can mess up some git checks; like it thought I had local changes in the current.yaml file even though I didn't, so prevented me from changing branches. I'd say we should not use that command, and instead just be vigilant on the PR side to verify changes to this file don't get passed in.
Description
This PR allows us to change non-read-only parameters for
create_action_server
, have them persist across runs ofada_feeding_launch.xml
, but still maintain access to the original parameters (e.g., in case we have to revert them). In practice, only thetree_kwargs
are non-read-only.It achieves this through the following:
create_action_server
are not defined in two files: (a)ada_feeding_action_servers_default.yaml
and (b)ada_feeding_action_servers_current.yaml
.default
namespace inada_feeding_action_servers_default.yaml
.ada_feeding_action_servers_current.yaml
contains parameters in thecurrent
namespace: (a)current.overridden_parameters
which is a list of the parameters that are overridden, and (b) the values for each of those parameters.default' namespace are declared as read-only. However, for the ones that the node wants to make over-writeable, it declares a read-write version of that parameter in the
current` namespace.current
namespace, it does the following:tree_kwargs
, it re-creates the tree with the new kwargs.ada_feeding_action_servers_current.yaml
in the share folder.Testing procedure
This was tested in sim.
ros2 run ada_feeding dummy_ft_sensor.py
ros2 launch feeding_web_app_ros2_test feeding_web_app_dummy_nodes_launch.xml run_web_bridge:=false run_motion:=false
ros2 run ada_feeding_perception republisher --ros-args --params-file src/ada_feeding/ada_feeding_perception/config/republisher.yaml
ros2 launch ada_feeding ada_feeding_launch.xml use_estop:=false
ros2 param list
. For the/ada_feeding_action_servers
node, verify that all the tree_kwargs indefault
are also incurrent
.current
and verify it is unset: e.g.,ros2 service call /ada_feeding_action_servers/get_parameters rcl_interfaces/srv/GetParameters "{names: ['current.MoveAbovePlate.tree_kwargs.f_mag']}"
default
and verify that it is set as expected (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']}"
default
parameter, and verify that it fails: e.g.,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}}]}"
current
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: 'current.MoveAbovePlate.tree_kwargs.f_mag', value: {type: 4, string_value: 'ASDFGHJKL'}}]}"
install
folder of the workspace),ada_feeding_action_servers_current.yaml
is unchanged.current
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: 'current.MoveAbovePlate.tree_kwargs.f_mag', value: {type: 3, double_value: 1.0}}]}"
install
folder of the workspace),ada_feeding_action_servers_current.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']}"
current
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: ['current.MoveAbovePlate.tree_kwargs.f_mag']}"
ros2 launch ada_moveit demo.launch.py sim:=mock
ros2 action send_goal /MoveToStagingConfiguration ada_feeding_msgs/action/MoveTo "{}" --feedback
ros2 action send_goal /MoveToMouth ada_feeding_msgs/action/MoveToMouth "{}" --feedback
ros2 action send_goal /MoveFromMouthToStagingConfiguration ada_feeding_msgs/action/MoveTo "{}" --feedback
ros2 service call /ada_feeding_action_servers/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: 'current.MoveToMouth.tree_kwargs.plan_distance_from_mouth', value: {type: 8, double_array_value: [0.10, 0.0, -0.01]}}]}"
ros2 action send_goal /MoveToMouth ada_feeding_msgs/action/MoveToMouth "{}" --feedback
ada_feeding_launch.xml
code and theada_moveit
code.ros2 action send_goal /MoveToStagingConfiguration ada_feeding_msgs/action/MoveTo "{}" --feedback
ros2 action send_goal /MoveToMouth ada_feeding_msgs/action/MoveToMouth "{}" --feedback
Before opening a pull request
python3 -m black .
ada_feeding
directory, run:pylint --recursive=y --rcfile=.pylintrc .
.Before Merging
Squash & Merge