Behavioral Programming : Intro

A more in depth explanation of behavioral programming. Starting off about what it is, how to implement it and what are the benefits of it.

What is behavioral programming?

Behavioral programming is using simple to complex behaviors to accomplish a set goal. A behavior is something that physically affects either the robot or it’s external environment. Simple behaviors are such things as turning on a motor, turning a servo, getting a distance reading from a sonar sensor, checking an infrared sensor, storing a value in a variable, and checking the status of a battery. Individually simple behaviors don’t do much, but when you call each one as needed in a linear fashion, they can be a more complex behavior such mapping, moving the robot in a straight line or turning to set direction, reading an array of infrared sensors to follow a line, etc.

Implementing Behavioral Programming

How do you use behavioral programming? You start off with making some primitive behaviors that control motors that you are using, to read whatever sensors you are in your robot and to implement the algorithms that manipulate internal variables such as the data collected by the sensors. These can be combined to make simple behaviors such as turning on the motors for a set distance and speed while taking continuous readings from their encoders, getting a distance reading from a servo mounted SONAR sensor at a specific angle and taking data gathered from the robot’s internal state and it’s sensor readings to create things like maps, maximum distance before needing to recharge and what it’s next goal is. I’ll list some simple behaviors and a few examples that combine them into more complex behaviors.

Some simple behaviors

  • Motor A(Direction, Speed)
  • Motor B(Direction, Speed)
  • Read Encoder(Pin #)
  • Servo A(Angle)
  • Trigger SONAR
  • Read SONAR

Some Simple Behaviors Combined into Complex Behaviors

Move Forward 100 encoder steps

  1. Motor A(Forward, 100)
  2. Motor B(Forward, 100)
  3. Read Encoder(Pin 5)
  4. Get 100 Encoder Steps
  5. Motor A(Forward, 0)
  6. Motor B(Forward, 0)

Get SONAR Reading

  • Trigger SONAR
  • Read SONAR

Read SONAR at a Specific Angle

  • Servo A(Angle)
  • Get SONAR Reading

This is how you combine simple behaviors into complex behaviors, so that the robot to achieve goals that require complex actions.

Benefits of Behavioral Programming

The main benefits of Behavioral Programming are:

  • saving time
  • saving memory space
  • simplifying tasks
  • simplifying problems
  • making coding less stressful

Those things allow the programmer to have more time and energy to make more complex robots that can achieve greater goals, or just have more time for other projects.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s