-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Error codes in NavigateToPose/NavigateThroughPoses #4341
Comments
@SteveMacenski what is your appetite for the interface change of adding a That would allow a pathway to propagate failure messages with details out to the action client. For instance in planner_server, the calls to exceptionWarning could either return a string, or take one as a reference and then add that to the result->error_msg.
Similar for controller server.
For backward compatibility would you prefer new actions? |
We had a discussion about that when we initially added in the error codes. We decided towards enums so that you weren't trying to parse strings for exact matches for checking which error this string represents programmatically. Having error messages in addition to could be useful, I agree! It would just be a bit of repetitive work to: add it to each action interface, populate it all in for the various servers when populating its error code (I think you can do Or perhaps don't store / serve on the BTs? The error enums should be the actionable bits for logic. How do you imagine using those messages? I suppose that has an impact about what we do with it at the Navigator and above levels.
What would you have in mind? For |
Adding a I think storing in the blackboard the error code in enum format will simplify the logic for populate it at higher level. For example, storing the last error code ocurred (from the BT node that fails). Regarding backward compatibility, there are no error codes in humble so, if this feature is implemented, can't be backported to humble. |
My use case for error messages is to be able to bubble up reasons that the behavior tree action aborted to a user interface. I foresee it helping a wider spectrum of people being able to reason about behavior and ultimately lead to them coming up with ideas for behavior tree improvements. I think, right now, that it is reasonable that the error message strings are not put into the behavior tree blackboard. (Limited experience so I could be easily swayed on this front). I agree that behavior tree logic that responds to errors is best done against against enums, rather than string matching. If the behavior tree is complete/complex enough to handled the errors encountered then the noise of error messages is not necessarily interesting. On the other hand a dedicated published log of error messages interposed with successful behavior transitions could be very useful for explain-ability. Maybe putting the error message strings into the blackboard would facilitate that. Maybe a ReportError action or ?decorator? could control what messages are deemed important enough to make it into such a log.
I agree that dual action definitions like NavigateToPoseWithErrorString/NavigateThroughPosesWithErrorString or NavigateToPose2/NavigateThroughPoses2 would be distateful and either be a naive cut and paste, or possibly use some template logic to detect the presence of and populate an error_message string in an action Result class. I personally, build from source on humble and track close to main periodically by back porting it to humble myself. I would like to change the existing action result messages to include the error_message string and can accept that this will not be available in humble/iron. You have a wider audience and hence my check in with your appetite for such a change. My read is that it would not be a back ported change to the interface. |
We can always add it later too. We can / probably should follow the same patterns we use for the error IDs just now with messages. How are the messages proping to your User Interface then?
That seems like a reasonable solution for this. Though, if you can add in the Would you be able to do that ASAP? I'm looking to cut Jazzy today... but I could delay to Monday or Tuesday if that makes a difference.
Correct, due to API/ABI stability of existing users, can't be breaking people's robots out in the wild |
I just saw this. I'll have a go now. |
Signed-off-by: Mike Wake <[email protected]>
See #4459 |
Signed-off-by: Mike Wake <[email protected]>
…on#4341) Introduces error codes:- - NO_WAYPOINTS_GIVEN - STOP_ON_MISSED_WAYPOINT Signed-off-by: Mike Wake <[email protected]>
…on#4341) Introduces error codes:- - NO_WAYPOINTS_GIVEN - STOP_ON_MISSED_WAYPOINT Signed-off-by: Mike Wake <[email protected]>
Here is a second pull request with a first pass at populating the error_msg, and error_code where it was missing (FollowWaypoints) See #4460 It builds but is untested and probably incomplete so I left it as draft. |
…on#4341) Introduces error codes:- - NO_WAYPOINTS_GIVEN - STOP_ON_MISSED_WAYPOINT Signed-off-by: Mike Wake <[email protected]>
…on#4341) Introduces error codes:- - NO_WAYPOINTS_GIVEN - STOP_ON_MISSED_WAYPOINT Signed-off-by: Mike Wake <[email protected]>
) Signed-off-by: Mike Wake <[email protected]>
Added a second pass to use the error_code and error_msg expected in each action in nav2_simple_navigator. Not run them yet. |
Finally figured out that "proping" probably means propagating. The error messages are currently not propagating to my user interface. Hence I went searching for why, came across this issue and also felt the pain point. With these changes I will be able to get the errors to our user interface. |
And now I am at the nav2_bt_navigator/src/navigators level and staring down the catch(...) and wondering if that is my target.
|
Now I am thinking that ResultStatus needs to be the one carrying the error message.
|
This is why I asked how you planned to propagate the error messages through to your interface. You'll see that the individual BT nodes that have actions with error codes populate in the BT blackboard the error codes which are aggregated by the BT Navigator into the action's result message for the highest priority failure number (but realistically there should only be 1 at at time, though possible to have multiple if multiple things go wrong simultaneously). If you want Nav2Pose and NavThruPoses to have the error message, then it'll need to propogate through the tree into the Navigator's action result callback. If you track down the
That's for the behavior server, wrong place. Example
|
Signed-off-by: Mike Wake <[email protected]>
) Signed-off-by: Mike Wake <[email protected]>
Signed-off-by: Mike Wake <[email protected]>
Signed-off-by: Mike Wake <[email protected]>
Only actions provide error_code and error_msg in their result msg. Signed-off-by: Mike Wake <[email protected]>
…) (ros-navigation#4459) Signed-off-by: Mike Wake <[email protected]>
…) (ros-navigation#4459) Signed-off-by: Mike Wake <[email protected]>
…ion#4341) Signed-off-by: Mike Wake <[email protected]>
…ros-navigation#4341) Signed-off-by: Mike Wake <[email protected]>
Signed-off-by: Mike Wake <[email protected]>
…avigation#4341) Signed-off-by: Mike Wake <[email protected]>
…avigation#4341) Signed-off-by: Mike Wake <[email protected]>
Signed-off-by: Mike Wake <[email protected]>
Signed-off-by: Mike Wake <[email protected]>
Signed-off-by: Mike Wake <[email protected]>
This allows setting a default failure error_code and message in nav2_system_tests behavior_tree dummy_action_server Signed-off-by: Mike Wake <[email protected]>
…navigation#4341) Signed-off-by: Mike Wake <[email protected]>
Signed-off-by: Mike Wake <[email protected]>
…gation#4341) NOTE: This stuff does not really test the error_msg/error_code handling as its all dummy servers. Signed-off-by: Mike Wake <[email protected]>
…gh_poses_w_replanning_and_recovery.xml (ros-navigation#4341) To facilitate error_msg system tests allow progress and goal checkers to be changed via the behaviour tree mechanism. Signed-off-by: Mike Wake <[email protected]>
…os-navigation#4341) Signed-off-by: Mike Wake <[email protected]>
Signed-off-by: Mike Wake <[email protected]>
…-navigation#4341) Signed-off-by: Mike Wake <[email protected]>
…ation#4341) Signed-off-by: Mike Wake <[email protected]>
…os-navigation#4341) Signed-off-by: Mike Wake <[email protected]>
Signed-off-by: Mike Wake <[email protected]>
…os-navigation#4341) Signed-off-by: Mike Wake <[email protected]>
Signed-off-by: Mike Wake <[email protected]>
…#4341) Signed-off-by: Mike Wake <[email protected]>
Signed-off-by: Mike Wake <[email protected]>
Signed-off-by: Mike Wake <[email protected]>
PR to be merged imminently within the next couple of days / weeks #4460 |
Awesome work @ewak !! |
…ros-navigation#4341) Signed-off-by: Mike Wake <[email protected]>
* Populate error_msg in action result messages (#4341) Signed-off-by: Mike Wake <[email protected]> * FollowWaypoints - Add usage of error_code and error_msg (#4341) Introduces error codes:- - NO_WAYPOINTS_GIVEN - STOP_ON_MISSED_WAYPOINT Signed-off-by: Mike Wake <[email protected]> * nav2_simple_commander: use error_code and error_msg (#4341) Signed-off-by: Mike Wake <[email protected]> * Create and populate BT::OutputPort(s) for error_msg (#4341) Signed-off-by: Mike Wake <[email protected]> * Add error_msg handling to nav2_bt_navigators (#4341) Signed-off-by: Mike Wake <[email protected]> * nav2_simple_command track LastActionError (#4341) Only actions provide error_code and error_msg in their result msg. Signed-off-by: Mike Wake <[email protected]> * Restore output format of planner server message (#4341) Signed-off-by: Mike Wake <[email protected]> * Fix opennav_docking error_msg/code usage (#4341) Signed-off-by: Mike Wake <[email protected]> * Fix error_msg type -> BT::OutputPort<std::string> (#4341) Signed-off-by: Mike Wake <[email protected]> * report index of failed initializeGoalPoses (#4341) Add the index of the pose that cannot be transformed in NavigateThroughPosesNavigator::initializeGoalPoses to the error_msg Signed-off-by: Mike Wake <[email protected]> * Add error_msg to (un)dock_robot bt (#4341) Signed-off-by: Mike Wake <[email protected]> * fix dock/undock use of error_msg (#4341) Signed-off-by: Mike Wake <[email protected]> * Improve comment to populate error_msg if goal not accepted (#4341) Signed-off-by: Mike Wake <[email protected]> * change robot_navigator api to (get|set|clear)TaskError() (#4341) Signed-off-by: Mike Wake <[email protected]> * remove exceptions from navigator onLoop (#4341) Signed-off-by: Mike Wake <[email protected]> * change error code to GOAL_TRANSFORMATION_ERROR (#4341) Signed-off-by: Mike Wake <[email protected]> * check getCurrentPose in initialiseGoalPoses (#4341) This mirrors the check done in NavigateToPose::initializeGoalPose checking that we can get a current pose in order to not accept the goal request. Signed-off-by: Mike Wake <[email protected]> * change error_code_names_ to error_code_name_prefixes_ (#4341) Signed-off-by: Mike Wake <[email protected]> * add error_msg port to default behavior xml files (#4341) Signed-off-by: Mike Wake <[email protected]> * Fix 'basic_string::_M_construct null not valid' exception(#4341) This was tough to spot. The nav2_system_tests waypoint follower provided a reproducable test Found out how to run just the waypoint_follower test colcon test --packages-select nav2_system_tests --ctest-args -N --event-handler console_direct+ | grep waypoint_follower changed src/navigation2/nav2_bringup/launch/navigation_launch.py to start nav2_bt_navigator Node with + prefix=['gnome-terminal -- gdb -ex run --args'], + respawn=False, Trying to use gdb to catch where the exception was thrown is too slow and the test gives up on itself. I found the relevant throw std::logic_error on my system by writing tiny program and breaking on std::logic_error int main() { const char *a = nullptr; try { std::string b(a); } catch (const std::logic_error &ex) { std::cout << "logic_error:" << ex.what() << std::endl; } catch (const std::exception &ex) { std::cout << "some other type:" << ex.what() << std::endl; } } Turns out it get thrown here on my system /usr/include/c++/11/bits/basic_string.tcc:212 Created ~/.gdbinit set breakpoint pending on break /usr/include/c++/11/bits/basic_string.tcc:212 This specific breakpoint on a line works fast enough for the integration test to throw the 'basic_string::_M_construct null not valid' and the silly initialisation mistake to be found. Signed-off-by: Mike Wake <[email protected]> * fix error_code_name_prefixes: in nav2_system_param.yml (#4341) Signed-off-by: Mike Wake <[email protected]> * Add error_msg handling to builtin nav2_behaviors plugins (#4341) Signed-off-by: Mike Wake <[email protected]> * simple_action_server improve "Aborting handle" log (#4341) Use SFINAE to log get_error_details_if_availble() in ActionT::Result Ideally all Action messages would have error_code and error_msg fields in their Result. BUT the tests use standard messages that do not and will not. i.e. test_msgs/action/Fibonacci.action Some Action messages only have error_code and not error_msg Signed-off-by: Mike Wake <[email protected]> * Add vim temporary files to .gitignore Signed-off-by: Mike Wake <[email protected]> * Fix include what you use (#4341) Signed-off-by: Mike Wake <[email protected]> * Fix cpplint and uncrustify (#4341) Signed-off-by: Mike Wake <[email protected]> * nav2_waypoint_follower do is_premppt_requested() before is_cancel_requested() (4341)(4602) Signed-off-by: Mike Wake <[email protected]> * fix behavior tree xml Backup backup_code_error_msg (#4341) Signed-off-by: Mike Wake <[email protected]> * Fix internal error tracking of navigators (#4341) Key point is only use the internal_error_(code|msg)_ if the action result error_code is 0. Signed-off-by: Mike Wake <[email protected]> * fix halt() in ComputePathToPose ComputePathThroughPoses (#4341) Clear output path for ComputePathThroughPoses similar to ComputePathToPose Explicitly note NOT to clear error_code_id and error_msg behavior tree output ports. Otherwise we cannot read them when the navigator reports errors. Signed-off-by: Mike Wake <[email protected]> * fix NavigateToPose onLoop current_path blackboard existance logic (#4341) Make it consistent with NavigateThroughPoses. This was introduced when changing logic to remove internal exception. Signed-off-by: Mike Wake <[email protected]> * nav2_msgs MissedWaypoint interface change, add error_msg (#4341) Allow of reason for missed waypoint as error_msg. Signed-off-by: Mike Wake <[email protected]> * Fix waypoint_follower error_msg handling (#4341) Include error_msg in reason for missed waypoint Signed-off-by: Mike Wake <[email protected]> * Fix cpplint uncrustify (#4341) Signed-off-by: Mike Wake <[email protected]> * Add tool to help check for error_code and error_msg in behavior trees (#4341) Signed-off-by: Mike Wake <[email protected]> * controller_server: Remove redundant logging (#4341) Signed-off-by: Mike Wake <[email protected]> * timed_behaviour: pass through on_run_result.error_msg (#4341) Signed-off-by: Mike Wake <[email protected]> * nav2_waypoint_follower - revert logic swap experiment (#4341) It was a red herring in search for error_msg clearing bug on abort Signed-off-by: Mike Wake <[email protected]> * nav2_waypoint_follower: clear error_msg when clearing error_code (#4341) Signed-off-by: Mike Wake <[email protected]> * Remove tool to check behaviour tree error_msg compliance (#4341) Signed-off-by: Mike Wake <[email protected]> * nav2_simple_commander: improve goal request rejection error reporting (#4341) Signed-off-by: Mike Wake <[email protected]> * nav2_system_tests: ensure error_msg not empty (#4341) Signed-off-by: Mike Wake <[email protected]> * nav2_system_tests: behaviour_tree error_code, error_msg checks (#4341) Signed-off-by: Mike Wake <[email protected]> * nav2_system_tests: behaviour_tree error_code, error_msg checks (#4341) Signed-off-by: Mike Wake <[email protected]> * doc: fix hint on how to run bt_navigator tests with ctest. Use -R to invoke the regular expresion. Signed-off-by: Mike Wake <[email protected]> * nav2_system_tests: log error_code and error_msg. (#4341) Signed-off-by: Mike Wake <[email protected]> * lint: remove tab (#4341) Signed-off-by: Mike Wake <[email protected]> * add result->error_msg for new CONTROLLER_TIMED_OUT (#4341) Signed-off-by: Mike Wake <[email protected]> * Add error codes NONE and UNKNOWN to Wait.action (#4341) This allows setting a default failure error_code and message in nav2_system_tests behavior_tree dummy_action_server Signed-off-by: Mike Wake <[email protected]> * move internal error tracking into bt_action_server.hpp and test (#4341) Signed-off-by: Mike Wake <[email protected]> * uncrustify and flake8 (#4341) Signed-off-by: Mike Wake <[email protected]> * nav2_system_tests behavior_tree result handling improvement (#4341) NOTE: This stuff does not really test the error_msg/error_code handling as its all dummy servers. Signed-off-by: Mike Wake <[email protected]> * Add ProgressCheckerSelector and GoalCheckerSelector to navigate_through_poses_w_replanning_and_recovery.xml (#4341) To facilitate error_msg system tests allow progress and goal checkers to be changed via the behaviour tree mechanism. Signed-off-by: Mike Wake <[email protected]> * Add nav2_system_tests for controller_server/behaviour tree error_msg (#4341) Signed-off-by: Mike Wake <[email protected]> * Improve README hint on how to run error_msg tests (#4341) Signed-off-by: Mike Wake <[email protected]> * fix PostStampedArray usage in nav_through_poses_tester_error_msg (#4341) Signed-off-by: Mike Wake <[email protected]> * nav_through_poses_tester_error_msg - towards clean pyright (#4341) Signed-off-by: Mike Wake <[email protected]> * SmoothPath fix error_(code_id|msg) output ports nav2_tree_nodes.xml (#4341) Signed-off-by: Mike Wake <[email protected]> * Wait action add error_(code_id|msg) output ports (#4341) Signed-off-by: Mike Wake <[email protected]> * Add error_code_id and error_msg ports to example behavior_tree xml (#4341) Signed-off-by: Mike Wake <[email protected]> * Add more default error_code_name_prefixes (#4341) Signed-off-by: Mike Wake <[email protected]> * Add error_(code_id|msg) to opennav_docking_bt example (#4341) Signed-off-by: Mike Wake <[email protected]> * error_msg review fixes (#4341) Signed-off-by: Mike Wake <[email protected]> * Adjust Navigator error code ranges (#4341) Signed-off-by: Mike Wake <[email protected]> * Fix Navigate(ToPose|ThroughPoses)Navigator::goalCompleted warning log (#4341) Signed-off-by: Mike Wake <[email protected]> --------- Signed-off-by: Mike Wake <[email protected]> Signed-off-by: Mike Wake <[email protected]> Co-authored-by: Mike Wake <[email protected]>
Moving the conversation here to discuss the possibility of adding error codes for NavigateToPose/NavigateThroughPoses actions in a similar way as the other servers (planner, controller, etc.)
I'm thinking of a use case where you call the NavigateToPose action from a high-level system, and I want to know why the robot can't reach the goal from the action client itself. It would be nice to add or populate some error codes from the "subservers" like tf_error, timeout, invalid path, etc.
The text was updated successfully, but these errors were encountered: