Unified cleanup using scoped behaviors#103
Conversation
|
Tested in sim. The only issue I noticed is that when terminating the CLI action call during robot arm motion, the tree runs the post-behavior before terminating the movement, which can be particularly harmful if the post-behavior blocks (e.g., toggling a collision object off). Instead, we want to first terminate the robot movement, and then run the post behavior. I should write comprehensive test cases for this idiom, covering:
|
Run: `colcon test --packages-select ada_feeding; colcon test-result --all --verbose` The current implementation fails on preemption order, and because `on_failure` runs if `on_success` fails
|
Wrote comprehensive test cases, and modified
The tree has become a bit unwieldy (reproduced below), but the comprehensive test cases mean that we can be fairly certain it works as outlined above. All the test cases in |
egordon
left a comment
There was a problem hiding this comment.
See comment for OnPreempt, stopping the review there for now.
…etween on_failure and on_success
…_preempt will no longer be called
…`scoped_behavior`
|
Note that even the new The tests that still need to be implemented for
|
|
Addressed all changes, added comprehensive unit tests for @egordon note that while our discussed approach worked for The only danger of the above formulation is potential name clashes with the blackboard status. However, I nest the blackboard variable within the idiom name, so the only way names will clash is if the programmer uses multiple idioms with the same name and doesn't pass a custom |
Description
In service of #54 .
In our trees, there are numerous times when we want to flip a switch, move the robot, and then flip the switch. For example, turning face detection on/off, adding/removing a collision object in the world, allowing/disallowing collisions with certain objects, etc.
What is challenging is that we want to run the "cleanup" for flipping the switch in three different cases:
Achieving the above 2 is straightforward using Selectors. Achieving the third is more difficult, because when
tree.stop(INVALID)is called, it is called on all the behaviors one-by-one, which in turn calls each behaviors'terminatefunction. Therefore, achieving the proper cleanup behavior in the third case requires performing that cleanup in aterminatefunction of a behavior.Building off of the discussion and contribution in
py_trees#427, this PR implements ascoped_behavioridiom that executes a pre-behavior, main-behavior, and post-behaviour, with a guarantee that the post-behavior will execute even if the behavior is preempted.Testing procedure
Run the necessary nodes as documented in the README. Verify the following:
ros2 action send_goal /MoveToRestingPosition ada_feeding_msgs/action/MoveTo "{}" --feedbackros2 action send_goal /MoveToMouth ada_feeding_msgs/action/MoveTo "{}" --feedbackwheelchair_collisionobject.ros2 action send_goal /MoveFromMouthToRestingPosition ada_feeding_msgs/action/MoveTo "{}" --feedbackwheelchair_collisionobject.in_front_of_wheelchair_wallfrom the collision scene.MoveToMouthandMoveFromMouthToRestingPositionseveral times iteratively to test all of the above.)ros2 action send_goal /MoveToRestingPosition ada_feeding_msgs/action/MoveTo "{}" --feedbackros2 action send_goal /MoveToMouth ada_feeding_msgs/action/MoveTo "{}" --feedbackwheelchair_collisionobject.ros2 action send_goal /MoveFromMouthToRestingPosition ada_feeding_msgs/action/MoveTo "{}" --feedbackwheelchair_collisionobject.in_front_of_wheelchair_wallfrom the collision scene.MoveToMouthandMoveFromMouthToRestingPositionseveral times iteratively to test all of the above.)colcon test --packages-select ada_feeding; colcon test-result --all --verboseBefore opening a pull request
python3 -m black .ada_feedingdirectory, run:pylint --recursive=y --rcfile=.pylintrc ..Before Merging
Squash & Merge