534  Braitenberg Vehicles: Sensor-Behavior Relationships

Learning Objectives

After completing this chapter, you will be able to:

  • Understand the Braitenberg vehicle model for sensor-actuator behavior
  • Design simple reactive systems using sensor inputs
  • Create emergent behaviors from sensor-actuator coupling
  • Apply these principles to IoT system design

534.1 Prerequisites

534.2 From Sensors to Behavior: The Braitenberg Model

~20 min | Intermediate | P06.C08.U04

Before diving into complex AI and machine learning, understand that simple sensor-actuator connections can create surprisingly intelligent-seeming behavior. Valentino Braitenberg’s thought experiments (1984) showed that vehicles with just sensors and motors can exhibit behaviors that look like fear, aggression, love, and exploration.

This matters for IoT because: - Simple is often better (fewer failure points) - Reactive systems respond faster than AI - You can build useful devices with basic logic

534.3 The Braitenberg Vehicles

Braitenberg imagined simple vehicles with sensors connected directly to motors. The connection type determines the behavior:

%%{init: {'theme':'base', 'themeVariables': {'primaryColor':'#2C3E50','primaryTextColor':'#fff','primaryBorderColor':'#16A085','lineColor':'#16A085','secondaryColor':'#E67E22','tertiaryColor':'#ECF0F1','fontSize':'14px'}}}%%
flowchart LR
    subgraph Vehicle1["Vehicle 1: FEAR"]
        S1L[Left Sensor] -->|Same side| M1L[Left Motor]
        S1R[Right Sensor] -->|Same side| M1R[Right Motor]
    end

    subgraph Vehicle2["Vehicle 2: AGGRESSION"]
        S2L[Left Sensor] -->|Cross| M2R[Right Motor]
        S2R[Right Sensor] -->|Cross| M2L[Left Motor]
    end

    style Vehicle1 fill:#e8f5e9
    style Vehicle2 fill:#ffebee

534.3.1 Vehicle Behaviors

Vehicle Connection Behavior IoT Example
1a: Fear Same-side, excitatory Runs away from stimulus Light-avoiding robot
2a: Aggression Cross-wired, excitatory Attacks stimulus Line-following robot
2b: Explorer Cross-wired, inhibitory Explores, avoids obstacles Roomba-like navigation
3: Love Same-side, inhibitory Approaches and stays near Plant-watering robot

534.3.2 Code Example: Fear Behavior

# Braitenberg Vehicle 1a: Fear (runs from light)
# Left sensor -> Left motor, Right sensor -> Right motor

def fear_behavior():
    while True:
        left_light = read_sensor("left_ldr")
        right_light = read_sensor("right_ldr")

        # Same-side connection: more light = faster motor
        left_motor.speed = map_value(left_light, 0, 1023, 0, 255)
        right_motor.speed = map_value(right_light, 0, 1023, 0, 255)

        # Result: Robot runs AWAY from light
        # (brighter side spins faster, turning away from light)

534.3.3 Code Example: Aggression Behavior

# Braitenberg Vehicle 2a: Aggression (attacks light)
# Left sensor -> Right motor, Right sensor -> Left motor

def aggression_behavior():
    while True:
        left_light = read_sensor("left_ldr")
        right_light = read_sensor("right_ldr")

        # Cross-wired connection
        left_motor.speed = map_value(right_light, 0, 1023, 0, 255)
        right_motor.speed = map_value(left_light, 0, 1023, 0, 255)

        # Result: Robot ATTACKS light source
        # (brighter side makes opposite motor faster, turning toward light)

534.4 IoT Applications of Braitenberg Principles

534.4.1 Smart Lighting System

# Light follows darkness (love behavior applied to LEDs)
# Sensor on left side controls right-side dimmer, and vice versa

def adaptive_lighting():
    left_ambient = read_lux_sensor("left")
    right_ambient = read_lux_sensor("right")

    # Cross-wired, inhibitory (love behavior)
    # Low light on left -> brighten right side
    right_led.brightness = map_inverse(left_ambient, 0, 1000, 0, 100)
    left_led.brightness = map_inverse(right_ambient, 0, 1000, 0, 100)

    # Result: Room maintains even lighting
    # Darker areas get more artificial light

534.4.2 Temperature-Seeking Robot

# Robot that finds and stays near heat sources
# (like a cat finding a sunny spot)

def heat_seeker():
    while True:
        left_temp = read_thermistor("left")
        right_temp = read_thermistor("right")

        # Cross-wired, inhibitory (love behavior)
        # Warmer side slows opposite motor
        left_motor.speed = BASE_SPEED - map_value(right_temp, 20, 40, 0, 200)
        right_motor.speed = BASE_SPEED - map_value(left_temp, 20, 40, 0, 200)

        # Result: Approaches heat source and slows down near it

534.5 Why This Matters for IoT

TipDesign Principle

Before writing complex code, ask: “Can I achieve this behavior with a simpler sensor-actuator relationship?”

Many IoT behaviors can be implemented with direct sensor-actuator mapping: - Thermostat: Temperature sensor directly controls heater - Light switch: Motion sensor directly controls light - Fan controller: Temperature directly sets fan speed

Complex AI is often unnecessary when simple reactive systems work.

534.6 Design Principles from Braitenberg

  1. Simple connections create complex behavior - Don’t over-engineer
  2. Sensor placement matters - Position determines what the system “sees”
  3. Connection polarity affects outcome - Excitatory vs inhibitory
  4. Cross-wiring vs same-side wiring - Determines approach vs avoidance
  5. Start simple, add complexity only when needed - Don’t over-engineer

534.7 Summary

Key takeaways from Braitenberg vehicles:

  1. Simple sensor-actuator links create emergent behavior
  2. Connection type determines behavior (approach, avoid, explore)
  3. Many IoT systems are essentially Braitenberg vehicles
  4. Consider reactive design before complex AI

534.8 What’s Next

Now that you understand sensor-behavior relationships:

Continue to Infrastructure Sensing ->