Managing the resources between behaviors
A resource is an element needed for executing a task or a program. To speak, NAO uses the TextToSpeech resource. To speak and move the left hand at the same time, NAO uses the TextToSpeech and left arm and hand motors resources. NAO has got many resources such as LEDs, microphones, motors, TextToSpeech, camera settings. You can set for each box the resources that can be used and how to manage the resources between behaviors. Managing the resources is important when exchanging behaviors for two reasons:
For resolving conflicts
Example: | You have two behaviors: one makes NAO dance on a music (Tai Chi Chuan box). The second makes NAO walk when the left bumper is touched (Walk Toward + Bumper boxes). As the legs are used for the dance and the walk, you should manage the resources in order to avoid sending contradictory commands to NAO's legs when the 2 behaviors are on NAO. |
---|
For synchronizing the resources
Example: | Your behavior makes NAO greet with the left hand and say Hello. The two resources need to be available at the same time for the behavior to start. |
---|
Setting the Resource Manager
Note: | The Resource Manager is an improved solution compared to the Resources Acquisition (in the Timeline). We recommend you to update your older behaviors to replace the Resources Acquisition setting by the Resource Manager. |
---|
- Right-click a box.
- Select in the contextual menu.
- Define the first setting: i.e. what happens when the same resources are called by another behavior:
-
: the ongoing behavior is not be stopped.-
: the ongoing behavior is stopped (the OnStop entry of the ongoing box is stimulated).-
: (for advanced user only) apply the onResource function. You should define the onResource function in the script of the box (see below for more information).-
: the ongoing behavior is interrupted and starts again when the resources are released. It should be used only for moves (i.e. with timeline). - Define the
-
: if the resources are not immediately available, the box does not play.-
: define how long the behavior should wait for available resources. Set how many seconds below.-
: this setting should be used only in particular cases when it is possible to wait forever. The behavior does not release the resources and does not stop.
: i.e. how long does a behavior should wait for available resources
- Select in the list the impacted resources (multiple selection is recommended). In a timeline box, you can detect and select the resources used by clicking the button
- Click .
Setting the onResource function
When set to
, the onResource function is called.Example: | Here is an example of the code: |
---|
def onResource(self, resource): print "another behavior asks for your resource ", resource