This tutorial demonstrates how to implement Error Handling.
Intera has a rich and flexible mechanism for handling errors that is modeled after the popular throw/catch scheme that has been used in behavior trees for years. This tutorial demonstrates how to use this error handling mechanism.
When an error is detected, it is ‘thrown’. For example, if the motion controller detects a collision while a Move To node is active, a collision error will be thrown. Similarly, if a Throw Error node is executed, the corresponding user-generated error will be thrown. Throwing an error stops normal processing of the behavior tree. Starting from the node that was active when the error was thrown, the system works up the tree to find the Catch Error node that is configured to ‘catch’ the error.
If such a handler is found, it ‘catches’ the error, i.e. it becomes active and handles the error as appropriate. Once the handling is complete, normal processing of the tree begins again based on the configuration of the parent Catch Error node. If no handler is found, the behavior tree stops and displays the error.
Using Error Handling
This tutorial is intended to be a basic example for how to use the error handling mechanism in Intera. These principles can and should be applied to applications which may respond to more than one error, or handle errors in more complex ways.
1. Create the following behavior tree either by inserting a pick and place with Train by Demonstration, Templates, or from scratch. This exercise will focus on the user-generated error produced by the Throw Error node built into the "Pick" template by default.
Note that when a part is mispicked, a variable named pickRetryCount is incremented. After two mispicks, the RetryFailed node becomes active and throws an error called Missed Pick. In its current state, this error will display on the user interface and the task will stop.
2. The desired error response behavior in this tutorial is to retract the robot arm, notify a human, and retry the pick sequence after the work station has been reset. In order to resume the task, the human must interact with the robot by giving it a gentle, two-finger push.
3. Add a Catch Error node as a parent of the "GripperPick" Loop If node branch. Set the condition to Re-run child nodes.
Some nodes in the behavior tree may need to be moved to create the configuration below.
4. Select the Behavior Tree drop down menu in the Error Handler node editor. The intended behavior is to respond to the Missed Pick error, so select this box.
5. Now when the task is run and an object is mispicked twice, the task will not stop with the Missed Pick error displayed. Rather, the error will be caught and handled. At this point there is no behavior to control what happens when the task is handled, so the program will retry the pick. This is because the Catch Error node is set to Re-run child nodes, and all of the logic conditions are met to execute the "GripperPick" Loop If node.
6. In order to build the desired error response behavior, add a Move To node as a child to the Error Handler node. Set this pose to the pick retract pose.
7. Add a Set To node and command the gripper to release.
8. For clarity, add another Set To node to signal the stack light to turn on. This signal can be combined with the Set To node in step 7, but may simplify troubleshooting later on if clearly separated.
9. Add a Wait Until node to respond to an interaction with a human. Set the condition to the Measured Tool Forces on the Force.net of robot tool plate to be >= 20N.
This node will wait for a human to give the robot a push with two fingers in any direction. When the net force measured at the tool plate exceeds 20N, the Wait Until node condition will be met and the robot will continue. This gives a human time to reset the work station accordingly while the robot waits.
Tip: Use Intera Insights to monitor the forces on the arm. This may help determine how hard to press on the robot.
10. Add another Set To node to signal the alarm to turn off. The children of the Error Handler should look similar to this:
11. The task is now ready to run. The complete behavior tree should look similar to this:
12. Try changing the Catch Error condition to Exit to Parent to see how this changes the behavior of the task. The task should skip down to the place branch. The Catch Error node is instructed to exit to its parent, which is the "pick-1" template node. Once it exits, the next node in sequence is the "place-21" template node.