par implementation details
TRANSCRIPT
![Page 1: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/1.jpg)
1
PAR Implementation DetailsPAR Implementation Details
Jan M. Allbeck
11/6/2008
![Page 2: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/2.jpg)
2
OutlineOutline
• Creating Objects (and Agents)• Creating an Environment• Creating Actions• Processing Actions• Projects and Future Work
![Page 3: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/3.jpg)
3
• Model them• Convert them to obj format• Find location in• Add Parent (instances are automatic)• Edit parameters• Enter sites• Agents—roles, groups
Creating ObjectsCreating Objects
Actionary
![Page 4: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/4.jpg)
4
Creating an EnvironmentCreating an Environment
• ASCII Environment File• Room layout -> Cell and Portal Graph• Textures• Objects
• ASCII Map File• Navigate from any room to any room
![Page 5: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/5.jpg)
5
• Object name (relates to parent in Actionary)• Room name (relates to parent in Actionary)• Obj file name• Check for collisions? (0 = no, 1 = yes)• X, Y, Z position• X, Y, Z orientation• Scale factor• Used to be bounding radius (no longer used)
ASCII Environment FileASCII Environment File
![Page 6: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/6.jpg)
6
• Create animations (key framed or procedural)
• uPARs vs. iPARs• .• Python code• C++ code: register MGs
Creating ActionsCreating Actions
Actionary
![Page 7: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/7.jpg)
7
uPARsuPARs vs. vs. iPARsiPARs
• uPARs are uninstantiated or general PARs• uPARs are the semantics of the action• iPARs are an implementation of those
semantics (fill in the required blanks)• iPARs are uPARs that have been instantiated
with an agent and objects, etc. • iPARs are ready to be processed• iPARs can override parameters of the uPARs
they are created from.
![Page 8: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/8.jpg)
8
Adding a Adding a uPARuPAR to the Actionaryto the Actionary
• Determine new id and a name• Add Python file names• Determine proper placement in the hierarchy
(parent id)• Specify duration?• Specify a default priority• Specify the number of object participants• Specify a site type• Add capability for the agents
Actionary
![Page 9: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/9.jpg)
9
Python FilesPython Files
• Conditionals• Termination conditions• Applicability conditions• Preparatory specifications• Execution steps---------------------------------------------• Post assertions• During condition• Purpose achieve
![Page 10: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/10.jpg)
10
InspectCul.pyInspectCul.py
def culmination_condition(self, agent, obj):return 0
![Page 11: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/11.jpg)
11
InspectApp.pyInspectApp.py
def applicability_condition(self, agent, obj):if checkCapability(agent, self.name, [obj]):
return 1else:
return 0
![Page 12: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/12.jpg)
12
InspectPre.pyInspectPre.py
def preparatory_spec(self, agent, obj1):radius = getBoundingRadius(obj1);distnce = dist(agent, obj1);if(distnce > radius):
actions = {'PRIMITIVE':("Walk",{'agents':agent, 'objects':obj1})};return actions
else:return 1
![Page 13: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/13.jpg)
13
InspectExec.pyInspectExec.py
def execution_steps(self, agent, obj):actions = {'PRIMITIVE':("Inspect",{'agents':agent, 'objects':obj})};return actions
![Page 14: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/14.jpg)
14
C++ Code: PredicatesC++ Code: Predicatesstatic PyMethodDef prop_methods[] = {
{"getIntProperty", prop_getIntProperty, METH_VARARGS},{"setIntProperty", prop_setIntProperty, METH_VARARGS},{"checkCapability", agent_checkCapability, METH_VARARGS},{"contain", object_contain, METH_VARARGS},{"findObject", prop_findObject, METH_VARARGS},{"getVector", prop_getVector, METH_VARARGS},{"setVector", prop_setVector, METH_VARARGS},{"getPosture", prop_getPosture, METH_VARARGS},{"getStatus", prop_getStatus, METH_VARARGS},{"getLocation", prop_getLocation, METH_VARARGS},{"dist", prop_dist, METH_VARARGS}, //distance between two objects{"getBoundingRadius", prop_getBoundingRadius, METH_VARARGS},{"inFront", prop_inFront, METH_VARARGS}, //is obj1 in front of obj2{"testAppCond", prop_testAppCond, METH_VARARGS},{"testCulCond", prop_testCulCond, METH_VARARGS},{"testPreSpec", prop_testPreSpec, METH_VARARGS},{"nullCheck", prop_nullCheck, METH_VARARGS},
…{NULL, NULL}
};
![Page 15: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/15.jpg)
15
C++ Code: Register C++ Code: Register MGsMGs
• actionTable.addFunctions("Inspect", &DoInspect, &CheckInspect);
• DoInspect = function that starts the execution• CheckInspect = function that indicates
whether or not the action is completed
![Page 16: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/16.jpg)
16
Adding an Adding an iPARiPAR to the Actionaryto the Actionary
• Determine the corresponding uPAR• Create new action id• Fill in name• Fill in purpose to enable action?• Fill in act_parent_act_id = uPAR id• Fill in start time• Fill in duration if desired• Alter priority?
![Page 17: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/17.jpg)
17
Assigning an Assigning an iPARiPAR to an Agentto an Agentchar* objNames[] = {obj->getObjectName()};
iPAR* ipar = new iPAR(act->getActionName(), agent->getObjectName(), objNames);
ipar->setStartTime(partime->getCurrentTime());ipar->setPriority(11);
// add to agent's queueagt->addAction(ipar);
![Page 18: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/18.jpg)
18
System DiagramSystem Diagram
![Page 19: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/19.jpg)
19
Start
Exit
Curraction Preempt popaction paraction
nonemptyQ
activeAction
EmptyQnoFailAction
defaultCond finished
poperror
defaultcond
AgentNet
![Page 20: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/20.jpg)
20
AgentNet::AgentNet(list<iPAR*> *IParQ, AgentProc *ap):LWNet(NUMNODES)
{
iparQ = IParQ;agentproc = ap;
ipar = 0;popError = 0;
defnormalnode(START, (ACTFUNC)&AgentNet::actfunc_start);deftrans(START, (CONDFUNC) &AgentNet::nonemptyQ, CURRACTION);
defnormalnode(CURRACTION, (ACTFUNC)&AgentNet::actfunc_curraction);deftrans(CURRACTION,(CONDFUNC)&AgentNet::emptyQ, START);deftrans(CURRACTION,(CONDFUNC)&AgentNet::activeAction, PREEMPT);deftrans(CURRACTION,(CONDFUNC)&AgentNet::noFailAction, POPACTION);
defnormalnode(PREEMPT, (ACTFUNC)&AgentNet::actfunc_preempt);deftrans(PREEMPT,(CONDFUNC)&LWNet::defaultcond, START);
defnormalnode(POPACTION, (ACTFUNC)&AgentNet::actfunc_popaction);deftrans(POPACTION,(CONDFUNC)&AgentNet::condfunc_poperror, EXITNODE);deftrans(POPACTION, (CONDFUNC)&LWNet::finishcond, PARACTION);
defnormalnode(PARACTION, (ACTFUNC)&AgentNet::actfunc_paraction);deftrans(PARACTION,(CONDFUNC)&LWNet::defaultcond, START);
defexitnode(EXITNODE);} AgentNet
![Page 21: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/21.jpg)
21
Exit
Start
failExitNode
applicability
primitive
newsubparnode
preparatory coreexec
newparnode
complex
defaultcond
culminate
applicable
Applic_dict
Defaultcond
ready
Prep_dict
error
finishcond
error
finishcond
iscomplex
defaultcond
error
finish
errorfinish
PARNet
![Page 22: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/22.jpg)
22
defnormalnode(START, (ACTFUNC)&ParNet::actfunc_start);deftrans(START, (CONDFUNC)&ParNet::condfunc_culminate, EXITNODE);deftrans(START, (CONDFUNC)&LWNet::defaultcond, APPLICABILITY);
defnormalnode(APPLICABILITY, (ACTFUNC)&ParNet::actfunc_applicability);deftrans(APPLICABILITY, (CONDFUNC)&ParNet::condfunc_isapplicdictionary, NEWPARNODE);deftrans(APPLICABILITY, (CONDFUNC)&ParNet::condfunc_applicable, PREPARATORY);deftrans(APPLICABILITY, (CONDFUNC)&LWNet::defaultcond, EXITNODE);
defnormalnode(PREPARATORY, (ACTFUNC)&ParNet::actfunc_preparatory);deftrans(PREPARATORY, (CONDFUNC)&ParNet::condfunc_isprepdictionary, NEWSUBPARNODE);deftrans(PREPARATORY, (CONDFUNC)&ParNet::condfunc_ready, COREEXEC);
defcallnode(NEWPARNODE, (LWNEW)&ParNet::newpar, NULL, NULL, (void *)app_result);deftrans(NEWPARNODE,(CONDFUNC)&LWNet::errorcond,FAILEXITNODE);deftrans(NEWPARNODE, (CONDFUNC)&LWNet::finishcond, EXITNODE);
defcallnode(NEWSUBPARNODE, (LWNEW)&ParNet::newpar,NULL,NULL,&prep_result);deftrans(NEWSUBPARNODE,(CONDFUNC)&LWNet::errorcond,FAILEXITNODE);deftrans(NEWSUBPARNODE, (CONDFUNC)&LWNet::finishcond, COREEXEC);
defnormalnode(COREEXEC, (ACTFUNC)&ParNet::actfunc_coreexecution);deftrans(COREEXEC, (CONDFUNC)&ParNet::condfunc_iscomplex, COMPLEX);deftrans(COREEXEC, (CONDFUNC)&LWNet::defaultcond, PRIMITIVE);
defcallnode(COMPLEX,(LWNEW)&ParNet::newpar, NULL, (ACTFUNC)&ParNet::postactfunc_complex, &complexobj);deftrans(COMPLEX,(CONDFUNC)&LWNet::errorcond,FAILEXITNODE);deftrans(COMPLEX, (CONDFUNC)&LWNet::finishcond, EXITNODE);
defnormalnode(PRIMITIVE, (ACTFUNC)&ParNet::actfunc_primitive, (ACTFUNC)&ParNet::preactfunc_primitive,(ACTFUNC)&ParNet::postactfunc_primitive);deftrans(PRIMITIVE,(CONDFUNC)&LWNet::errorcond,FAILEXITNODE);deftrans(PRIMITIVE, (CONDFUNC)&LWNet::finishcond, EXITNODE);
defexitnode(EXITNODE); deffailexitnode(FAILEXITNODE); PARNet
![Page 23: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/23.jpg)
23
System DiagramSystem Diagram
![Page 24: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/24.jpg)
24
Agent ProcessAgent Process
• Inform: message passing• Perceive: objects that are sensed• Update:
• positions, locations, etc• Action choices
• Add action: start new performance
![Page 25: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/25.jpg)
25
Projects/Future WorkProjects/Future Work
• GUIs• Tools and checkers• Agents• Different action types• Quantifiers• Properties• Spatial reasoner• Maya plug-in for object creating and db
![Page 26: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/26.jpg)
26
The EndThe End
![Page 27: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/27.jpg)
27
voidAgentNet::actfunc_start(void){}
Back
![Page 28: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/28.jpg)
28
voidAgentNet::actfunc_curraction(void){}
Back
![Page 29: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/29.jpg)
29
voidAgentNet::actfunc_preempt(void){iPAR* cfipar = this->getFirstAction();if (ipar != NULL
&& this->readyToGo(cfipar))agentproc->ipt->
preempt(cfipar->getPriority()); }
Back
![Page 30: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/30.jpg)
30
voidAgentNet::actfunc_popaction(void){
iPAR *cfipar = getFirstAction();if (cfipar == NULL)
return;
if (readyToGo(cfipar)){
ipar = cfipar;iparQ->remove(cfipar);markfinished();
}}
Back
![Page 31: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/31.jpg)
31
voidAgentNet::actfunc_paraction(void){
ComplexObj *complexobj = new ComplexObj(ipar,0);
LWNetList::addnet(new ParNet(complexobj));}
Back
![Page 32: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/32.jpg)
32
boolAgentNet::nonemptyQ(void){return (!(iparQ->empty()));
}
Back
![Page 33: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/33.jpg)
33
boolAgentNet::emptyQ(void){return iparQ->empty();
}
Back
![Page 34: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/34.jpg)
34
boolAgentNet::condfunc_poperror(void){return popError;
}
Back
![Page 35: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/35.jpg)
35
boolAgentNet::activeAction(void){
return agentproc->ipt->activeAction();}
Back
![Page 36: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/36.jpg)
36
boolAgentNet::noFailAction(void){
return !(agentproc->ipt->failAction());}
Back
![Page 37: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/37.jpg)
37
IPAR TableIPAR Table• List of all IPARs for the agent• Status:
• notfound, • onqueue, • preproc, • prepspec, • exec, • completed, • aborted, • failure, // set when failure has been detected • failed // set after failure recovery
![Page 38: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/38.jpg)
38
voidParNet::actfunc_start(void){ap->ipt->setStatus(ipar,preproc);
}
Back
![Page 39: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/39.jpg)
39
BoolParNet::condfunc_culminate(void){
timer.startTimer("ParNet::condfunc_culminate");Bool result;PyObject* res;
res = actionary->testCulminationCond(ipar); assert(res);
if (result = fromPyObjectToBool(res))ap->ipt->setStatus(ipar,completed);
timer.stopTimer("ParNet::condfunc_culminate");return result;
}
Back
![Page 40: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/40.jpg)
40
voidParNet::actfunc_applicability(void){
timer.startTimer("ParNet::act_func_applicability");app_result = actionary->testApplicabilityCond(ipar);assert(app_result);
if(PyDict_Check(app_result)){
app_dict = 1;AgentProc *ap = agentTable.getAgent(ipar->par->getAgent()->getObjectName());assert(ap);ap->ipt->setStatus(ipar,aborted);
}else if (fromPyObjectToBool(app_result)){
app_status = 1;}else
{app_status = 0;AgentProc *ap = agentTable.getAgent(ipar->par->getAgent()->getObjectName());assert(ap);ap->ipt->setStatus(ipar,aborted);
}timer.stopTimer("ParNet::act_func_applicability");
}
Back
![Page 41: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/41.jpg)
41
BoolParNet::condfunc_applicable(void){return app_status;
}
Back
![Page 42: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/42.jpg)
42
BoolParNet::condfunc_isapplicdictionary(void){
return app_dict;}
Back
![Page 43: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/43.jpg)
43
LWNet *ParNet::newpar(void *args){
timer.startTimer("ParNet::newpar");
ComplexObj **cobj = (ComplexObj **)args;assert(cobj);
ActionNet *actionnet = new ActionNet(*cobj);assert(actionnet);
timer.stopTimer("ParNet::newpar");return actionnet;
}
Back
![Page 44: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/44.jpg)
44
voidParNet::actfunc_preparatory(void){
timer.startTimer("ParNet::actfunc_preparatory");
ap->ipt->setStatus(ipar,prepspec);prep_result = actionary->testPreparatorySpec(ipar);assert(prep_result);
if(PyDict_Check(prep_result)) {prep_dict = 1; }
else if (fromPyObjectToBool(prep_result)) {prep_status = 1; }
else { prep_status = 0; }
timer.stopTimer("ParNet::actfunc_preparatory");}
Back
![Page 45: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/45.jpg)
45
BoolParNet::condfunc_ready(void){return prep_status;
}
Back
![Page 46: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/46.jpg)
46
BoolParNet::condfunc_isprepdictionary(void){
return prep_dict;}
Back
![Page 47: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/47.jpg)
47
voidParNet::actfunc_coreexecution(void){
timer.startTimer("ParNet::actfunc_coreexecution");ap->ipt->setStatus(ipar,exec);PyObject *complexpar = actionary->testExecutionSteps(ipar); assert(complexpar);complexobj->pyobj = complexpar;complexobj->complexParent = ipar;
if(PyDict_Check(complexpar)) {prep_dict = 1; }
if(PyDict_GetItemString(complexpar,"COMPLEX")) {complex = 1; }
else if (PyDict_GetItemString(complexpar,"PRIMITIVE")) {complex = 0; }
timer.stopTimer("ParNet::actfunc_coreexecution");}
Back
![Page 48: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/48.jpg)
48
BoolParNet::condfunc_iscomplex(void){return complex;
}
Back
![Page 49: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/49.jpg)
49
voidParNet::preactfunc_primitive(void){if(!(callback = actionTable.getFunctions(ipar->par->getActionName())))printf("ERROR: No execution function found for action
%s\n",ipar->par->getActionName());elsecallback->func(ipar);
}
Back
![Page 50: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/50.jpg)
50
voidParNet::actfunc_primitive(void){
FailData *failData = new FailData;if(callback){switch(callback->finished(ipar, &failData)) {case SUCCESS:
markfinished();break;
case FAILURE:markerror(); // flag this node as errorif(ipar->complexParent) {
ap->ipt->setStatus(ipar->complexParent,failure);failData->complexIPAR = ipar->complexParent; }
ap->inform("Failure",(void *)failData); break;
default:break;
}}else markfinished();
}
Back
![Page 51: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/51.jpg)
51
voidParNet::postactfunc_primitive(void){
if((ap->ipt->getStatus(ipar) != failure) && \(ap->ipt->getStatus(ipar) != failed) &&
(ap->ipt->getStatus(ipar) != aborted)){ap->ipt->setStatus(ipar,completed); }
}
Back
![Page 52: PAR Implementation Details](https://reader034.vdocuments.mx/reader034/viewer/2022052306/62895b184019d350df6005b8/html5/thumbnails/52.jpg)
52
voidParNet::postactfunc_complex(void){
if(!errorcond()){
ap->ipt->setStatus(ipar,completed);}
}
Back