Overview

Manage robot resources: Synchronize movement, led, sound. Run specific actions when another behavior wants your resources

Methods

void waitForLocalResource (const string& ressourceName, const N2AL5ALPtrINS_7ALOwnerEEE& ownerPtr, const string& callbackName, const int& timeoutSeconds)

Waits for local resource, using a pointer to the owner

ressourceName

Resource name

ownerPtr

Owner smart pointer. Object that inherit ALOwner

callbackName

The name of the method called when another owner wants the resource

timeoutSeconds

Timeout in seconds

Example in python :

from naoqi import ALProxy

try:
	# create proxy on ALMemory
	memProxy = ALProxy("ALResourceManager","localhost",9559)

	#createResource in root
	memProxy.createResource("newResource","")

	#check resource is free
	free = memProxy.areResourcesFree(["newResource"])
	print "resource free: ", free
	if (free != True):
		print "resource should be free"
		exit(1)
		
	# take resource 
	memProxy.waitForResource("newResource", "newOwner", "callback", 1)
	
	# check resource not available for someone else
	try:
		memProxy.waitForResource("newResource", "newOwner2", "callback", 1)
	except RuntimeError,e:
		print "ok timeout", e
		
	# check resource not free
	free = memProxy.areResourcesFree(["newResource"])
	print "resource free: ", free
	if (free != False):
		print "resource should be not available"
		exit(1)
		
	#release resource
	memProxy.releaseResource("newResource", "newOwner")
	
	# check resource free
	free = memProxy.areResourcesFree(["newResource"])
	print "resource free: ", free
	if (free != True):
		print "resource should be true"
		exit(1)
		
	
except RuntimeError,e:
	# catch exception
	print "error resource ", e



 

void waitForResource (const string& ressourceName, const string& ownerName, const string& callbackName, const int& timeoutSeconds)

Wait resource

ressourceName

Resource name

ownerName

Owner name

callbackName

callback name

timeoutSeconds

Timeout in seconds

void waitForLocalResources (const vector<string>& resourceNameList, const N2AL5ALPtrINS_7ALOwnerEEE& owner, const string& callbackName, const int& timeoutSeconds)

Wait for local resources

resourceNameList

Resources name

owner

Owner pointer with hierarchy. Object that inherit ALHierarchyOwner and redefine isParent method to give hierarchy information

callbackName

callback name

timeoutSeconds

Timeout in seconds

void waitForLocalResourcesTree (const vector<string>& ressourceName, const N2AL5ALPtrINS_16ALHierarchyOwnerEEE& treeOwnerPtr, const string& callbackName, const int& timeoutSeconds)

Wait for resource tree. Parent and children are not in conflict. Local function

ressourceName

Resource name

treeOwnerPtr

Owner pointer with tree hierarchy

callbackName

callback name

timeoutSeconds

Timeout in seconds

bool areResourcesOwnedBy (const vector<string>& resourceNameList, const string& ownerName)

True if all the specified resources are owned by the owner

resourceNameList

Resource name

ownerName

Owner pointer with hierarchy

Returns

True if all the specify resources are owned by the owner

void releaseResource (const string& resourceName, const string& ownerName)

Release resource

resourceName

Resource name

ownerName

Existing owner name

void releaseLocalResource (const string& resourceName, const N2AL5ALPtrINS_7ALOwnerEEE& ownerName)

Release local resource

resourceName

Resource name

ownerName

Existing owner name

void releaseResources (const vector<string>& resourceNames, const string& ownerName)

Release resources list

resourceNames

Resource names

ownerName

Owner name

void enableStateResource (const string& resourceName, const bool& enabled)

Enable or disable a state resource

resourceName

The name of the resource that you wish enable of disable. e.g. Standing

enabled

True to enable, false to disable

bool areResourcesFree (const vector<string>& resourceNames)

True if resources free

resourceNames

Resource names

Returns

True if all the specify resources are free

void createResource (const string& resourceName, const string& parentResourceName)

Create a resource

resourceName

Resource name to create

parentResourceName

Parent resource name or empty string for root resource


Methods inherited from ALModule

void exit ()

Exits and unregisters the module.

string version ()

Returns the version of the module.

Returns

A string containing the version of the module.

bool ping ()

Just a ping. Always returns true

Returns

returns true

vector<string> getMethodList ()

Retrieves the module's method list.

Returns

An array of method names.

AL::ALValue getMethodHelp (const string& methodName)

Retrieves a method's description.

methodName

The name of the method.

Returns

A structure containing the method's description.

AL::ALValue getModuleHelp ()

Retrieves the module's description.

Returns

A structure describing the module.

string getBrokerName ()

Gets the name of the parent broker.

Returns

The name of the parent broker.

string getUsage (const string& name)

Gets the method usage string. This summarise how to use the method.

name

The name of the method.

Returns

A string that summarises the usage of the method.


Copyright © 2010 Aldebaran Robotics - All rights reserved