Back to all projects

VEHICLES - Synthetic Psychology

Published on March 12, 2025
roboticsprogrammingaipython
VEHICLES - Synthetic Psychology featured image

Implementation of Braitenberg vehicles for experiments in synthetic psychology, creating threshold devices with sensors and actuators.

VEHICLES

This hobby project is an implementation of the vehicles described in the book "Vehicles - Experiments in Synthetic Psychology" written by Valentino Braitenberg. Currently it is a prototype/proof-of-concept, closely following the book and showcasing some of the simple examples mentioned in it. It supports creation of simple threshold devices, and includes placeholders for sensors and actuators to provide input and get output to/from threshold devices. As a bonus, a graph generator is implemented to visualize the created threshold devices. Nodes and the connections in the device are outputted in DOT language and rendered with graphviz.

[1] V. Braitenberg, Vehicles, experiments in synthetic psychology. Cambridge, MA: MIT Press, 1984.

How It Works

The most basic threshold device is made up from a manager object, sensor, threshold node and an output (wire elements are automatically created when two elements are connected). After an input is provided, the manager's update function is called and the input is propagated throughout the device. Since the system architecture is serial and each element needs to perform calculations that may have to be done concurrently, the update function is made up of smaller updates.

System Components

Manager

Manager object represents the threshold device and it is the first element that needs to be initialized. It wraps all the other elements and calls each element's update function in the order:

  • update thresholds
  • update wires
  • update actuators

After the updates, manager's time value is incremented by one. Manager also includes auxiliary functions for visualization of the device.

Functions:

  • self.get_thresholds() — returns all the internal threshold values at a given time step.
  • self.display() — prints out the elements and their connections in the device.
  • self.dot_generator() — returns the generated DOT source which can be used with graphviz.
mng = v.manager(verbose = True)

Sensor (Signal Input Wrapper)

Sensor object is a wrapper for the signal input class which makes it easier to create input arrays. Signal inputs are created and added to the inputs array of the sensor object when it is initialized. Currently it is used as a simple input method which only accepts values 1 or 0.

Functions:

  • self.add_consumer(consumer, type = int[0-1], position = (x,y)) — Adds the provided element to the signal input at the position (x,y) as a consumer.
  • self.feed([input]) — Feeds the input array to the appropriate signal inputs.
sns = v.sensor(mng, (1, 5))
sns.feed([0, 0, 0, 0, 0])

Threshold

Threshold nodes get input from their producers, compare the current input to their threshold values and send an output signal to their consumers depending on the result of the comparison:

  • input = inhibition( --| ) => current = current - 1
  • input = signal( --> ) => current = current + 1

Functions:

  • self.add_consumer(consumer, type = int[0-1]) — Adds the provided element as a consumer. Type determines if the output is going to "signal" or "inhibit" the consumer.
thr = v.threshold(mng, 1)

Actuator

Actuator object is currently a placeholder. It is used as a simple output method. Actuators only print "ACTIVATED" if their producers send a signal.

act = v.actuator(mng)

Creating a Working Threshold Device

Here's how to create a complete threshold device:

import vehicles as v

mng = v.manager(verbose = True)
sns = v.sensor(mng, (1, 1))
thr = v.threshold(mng, 1)
act = v.actuator(mng)

sns.add_consumer(thr, 0, (0, 0))
thr.add_consumer(act, 0)

sns.feed([[1]])
mng.update()

Visualization with Graphviz

After creating our device we can generate a visualization:

from graphviz import Source, render

# Generate the DOT representation of the manager/t. device
dot = mng.dot_generator()
# Read the DOT file with graphviz
src = Source(dot)
# Create and save the graph
src.render(filename='tutorial', directory='graph_output//tutorial', format='png', cleanup=True) 

Applications

This project serves as a foundation for exploring concepts in synthetic psychology and simple AI systems. The threshold devices can be used to model basic reactive behaviors and demonstrate how complex behaviors can emerge from simple mechanisms.

Potential applications include:

  • Educational tool for teaching AI concepts
  • Prototyping reactive behavior systems for robotics
  • Exploring the principles of Braitenberg vehicles
  • Visualizing neural-like networks and their information flow

Future Plans

Future development will expand the capabilities to include:

  • More complex vehicles from later chapters of Braitenberg's book
  • Physical robot integration for real-world testing
  • Extended visualization tools for analyzing behavior
  • More sophisticated actuator models

Getting Started

Check out the GitHub repository for installation instructions and more detailed examples.