Skip to content

Add a more complex behavior

Pierre DUBAILLAY requested to merge feature/bhv_plus into develop

This PR adds the FSMBehavior which is a Finite State Machine.

When creating a FSMBehavior, you have to:

  • define states and associated behaviors
  • define transitions between states
  • define which state is the initial one and which states are the final ones

Each time the FSM state changes, the associated behavior is instantiated.

Transition are functions that take the previous state's behavior result in parameter and return True if the transition to the new state is possible.

I also changed how behaviors are managed by the agent:

  1. when a behavior is added, it is immediately scheduled
  2. every 5s, the agent perform some cleanup and remove finished behaviors

Now behaviors and agents are using a synchronization primitive to check the agent state and are automatically woke up when the agent's state is whatever they expect. No more explicit sleeping.

Merge request reports