Module gen_activity

This behaviour provides an abstraction for object activities.

Behaviours: gen_server.

Description

This behaviour provides an abstraction for object activities. A gen_activity allows an object "to do" something during the simulation, and alla activities can be performed in parallel. For example, if the robot has an helic which is a compound Object3d(), the right way to make the helic rotating is adding an activity "rotate_helic" which uses the gen_activity behaviour and takes care of helic rotation at each step. Each activity is passed the current state of the object it is applied to, so that it is possible to modify objects properties (position, colors, etc...) as a result of the activity.
The callback module should provide those functions:

which are used, respectively, to perform a step of the activity and to get/set activity properties.

Some other modules of ROSEN, for example kinematics, simple_path and diff_drive are implemented as activities, since the movement of an object is, actually, one of the main activities of an object in a 3d sim.

Function Index

get_property/2Get the property PropName of the activity at pid Pid.
set_property/3Set the property PropName of the activity at pid Pid assigning it to value PropValue.
start_link/4create an activity for an object.
start_link/5create an activity for an object, registering it with local name Name.
step/2Perform a step of an activity.
stop/1Immediately stop the activity with pid Pid, calling the terminate/2 callback function, which should return ok.

Function Details

get_property/2

get_property(Pid, PropName) -> Result

Get the property PropName of the activity at pid Pid. The result should be {error, noprop} if the property does ot exist, and should be {value, {PropName, PropVal}} if the property exists. Also a custom CustomRes term can be returned.

set_property/3

set_property(Pid, PropName, PropertyValue) -> Result

Set the property PropName of the activity at pid Pid assigning it to value PropValue. If the property esists, it is set to the new value and the result is {ok}. Otherwise, the callback function should return {error, noprop}

start_link/4

start_link(Module, Params, ObjectPid, Object) -> Result

create an activity for an object. Module is the name of the module where callbacks are implemented. Params is the list of params to be passed to the

Module:init
function ObjectPid is the pid of the Object3d to which this activity applies, while Object must be the complete description of the object3d.
This function is not called directly, you may use
object3d:add_activity

to add an activity to a given object.

start_link/5

start_link(Name, Module, Params, ObjectPid, Object) -> Result

create an activity for an object, registering it with local name Name. Name = the name of the activity Module is the name of the module where callbacks are implemented. Params is the list of params to be passed to the

Module:init
function ObjectPid is the pid of the Object3d to which this activity applies, while Object must be the complete description of the object3d.
This function is not called directly, you may use
object3d:add_activity
to add an activity to a given object.

step/2

step(Pid, ObjectState) -> Reply

Perform a step of an activity. The step acts on the ObjectState of the object whose pid is Pid. Reply is a term returned by the activity. Note that activities are performed on a step-by-step base: whenever an object3d() is updated, all its activities perform a step.

stop/1

stop(Pid) -> ok

Immediately stop the activity with pid Pid, calling the terminate/2 callback function, which should return ok.


Generated by EDoc, Nov 21 2007, 10:13:23.