Skip to content
SjoerdL edited this page Nov 21, 2011 · 13 revisions

Behavior

Introduction

The behavior code is responsible for (how surprising) the behavior of the drone. It makes the drone fly its 8-shaped figures based on the sensory input. The behavior is implemented by means of a Finite-State Machine (FSM).

Finite-State Machine

The FSM consists of a number of States that are linked by Transitions. Each state describes a certain behavior. An example of a state would be 'Fly towards pole'. The behavior is then for the drone to fly towards a pole. Switching between states is made possible by transitions. A transition connects two states (uni-directional) and specifies conditions that must be satisfied in order for the transition to become active. An example of a transition would be 'Pole found' that connects the 'Search for pole' state to the 'Fly towards pole' state.

Implementation

The fsm package contains the FSM code to setup and run a FSM. A State is a container for Behaviors, where behaviors specify the commands that need to be sent to the drone. A State can have an entry behavior, 'normal' behaviors and an exit behavior. The entry behavior is executed once when the state becomes active. Multiple behaviors can be added to a state. These behaviors are executed in order when the state is active. When a transition is activated, an exit behavior of the state that now becomes inactive can be executed. Transitions specify the conditions that must be satisfied for the transition to become active. When a transition becomes active, a behavior can be executed. Transitions are uni-directional; they connect State A to State B, but not vice versa. A state can have multiple transitions associated with it. The list of transitions is checked in order for whether or not the transition conditions are satisfied.

States

The states that are used in the current implementation of the behavior of the drone are listed below.

  • Search pole (left and right)
  • Pass (left and right)
  • Turn (left and right)
  • Fly towards pole (left and right)

Behaviors

The behaviors that are used correspond to the states. The search pole state, for example, has the searchPoleBehavior associated with it. Other behaviors are:

  • Initialize drone behavior. This behavior puts the drone in the air. It is set as the entry behavior of the 'search pole right' state. This state is also the initial state of the FSM.
  • Hover behavior. This will put the drone in a hover mode. This is done to stabilize camera images coming from the onboard camera of the drone.
  • Twitter behavior. This will make the drone put out twitter messages.

Transitions

The transitions that connect the states to each other are listed below.

  • Pole found (left and right); used when searching for poles and when turning around poles
  • Out of sight (left and right); used when passing poles
  • Pole lost (left and right); used when flying towards poles
  • Close to pole (left and right); used when flying towards poles

BioMAV FSM

The Finite State Machine as used in the BioMAV project is displayed below. The initial state of the FSM is the 'Search Pole Right' state. This state has the TakeOff behavior as entry behavior. Not displayed in the figure are the exit behaviors of each state. Each state has the Hover behavior as exit state. This is to ensure the drone will be able to take a steady picture with its camera.

Finite State Machine of the BioMAV project

Biologically Inspired

The FSM as used in the BioMAV project is biologically inspired. Inspiration was drawn from the behavior of a fly. A fly typically shows two reactive behaviors: object avoidance and fixation on visually prominent features in the environment. These behaviors are reflected in the FSM: the drone flies towards a pole (fixation) and avoids it when it is about to hit the pole (avoidance). The flying around the pole is then a bit artificial, but is required for the task at hand.

Code

The behavior code contains 7 packages:

  • Behaviors. Contains all the behaviors as described above.
  • BioMAV. Contains the main-methods for setting up the simulator.
  • EA. First implementation of the evolutionary algorithm.
  • EA2. Second implementation of the evolutionary algorithm. This EA should be able to run distributed.
  • FSM. Contains the files for setting up an running the FSM. Behaviors and Transitions derive from the abstract classes found in this package.
  • Tools. Contains files that are useful to the behavior code in general.
  • Transitions. Contains all the transitions as described above.

Results

Running the FSM as implemented in the given version in the simulator should result in the following path to be followed:

Results of FSM in simulator

The drone starts at position (0,0) and then flies towards the first pole, located at position (5,0).

Clone this wiki locally