Skip to content

user behavior module

Tamara edited this page Jul 12, 2021 · 2 revisions

Behavior Module Interface

To ease the task of creating apps, a behavior module abstract class is provided to the developers.

public abstract class ABehaviourModule implements IModule {

    private static final int MIN_PERIOD = 10;
    private static final int DEFAULT_PERIOD = 50;


    /** Robobo manager instance */
    private RoboboManager robobo = null;

    /** Handler for periodic behaviour execution */
    private Handler handler = null;
    /** Code to run each period */
    private Runnable runnableCode = null;

    /** Period of each step run */
    private int stepPeriod = DEFAULT_PERIOD;

    public final RoboboManager getRobobo() {
        ...
    }

    public final void setPeriod(int period) {
        ...
    }

    @Override
    public final void startup(RoboboManager manager) throws 
        ...
    }

    @Override
    public final void shutdown() throws InternalErrorException {
        ...
    }

    protected abstract void startBehaviour() throws InternalErrorException;

    protected abstract void stopBehaviour() throws InternalErrorException;

    protected abstract void runStep();




}

This abstract class manages all the startup and shutdown process and the developer only has to implement the abstract methods concerninc to its own desired behavior.

startBehavior() is called on the startup of the module and must be filled with the code required to start-up the execution of the behaviour, like getting instances of Robobo modules or any other resource. stopBehavior() is called on the stop of the behavior and can be used to free resources. runStep() is called periodically and can be used to implement sequential behaviors, the period of this function can be configured via the setPeriod() method.

A example of this can be found on the building native apps wiki page

Clone this wiki locally