Skip to main content
The Memory class is a key-value store used by the Vehicle to pass data between parts. It acts as a shared message bus where parts can publish outputs and subscribe to inputs.

Overview

Memory enables loose coupling between parts. Parts don’t need to know about each other - they just read and write named values to memory. The Vehicle orchestrates the data flow.

Constructor

__init__(*args, **kw)

Creates a new Memory instance. No parameters required.
Attributes:
  • d - Internal dictionary storing all key-value pairs

Methods

get(keys)

Retrieves values from memory by key names.
list
required
List of string keys to retrieve from memory
Returns:
list
List of values corresponding to the keys. Returns None for keys that don’t exist.
Example: Basic Retrieval
Example: Handling Missing Keys
Example: Vehicle Usage

put(keys, inputs)

Stores values in memory. Handles both single and multiple key-value pairs.
list
required
List of string keys where values will be stored
any
required
Value(s) to store. If keys has multiple items, inputs should be a tuple or list of values.
Example: Single Value
Example: Multiple Values
Example: Vehicle Usage
Example: Error Handling

update(new_d)

Updates memory with values from a dictionary.
dict
required
Dictionary of key-value pairs to add or update in memory

Dictionary-Style Access

Memory supports dictionary-style access using [] operators:

__getitem__(key)

Retrieve values using bracket notation.
str | tuple
required
Single key (string) or multiple keys (tuple)
Example: Single Key
Example: Multiple Keys (Tuple)

__setitem__(key, value)

Store values using bracket notation.
str | tuple | list
required
Single key (string) or multiple keys (tuple/list)
any
required
Value(s) to store
Example: Single Value
Example: Multiple Values

Dictionary Methods

Memory provides standard dictionary methods for introspection:

keys()

Returns all keys in memory.

values()

Returns all values in memory.

items()

Returns all key-value pairs.

Common Memory Keys

By convention, memory keys use the format component/property:

Camera

  • cam/image_array - Camera image as numpy array
  • cam/depth_array - Depth image (for stereo/depth cameras)

User Control

  • user/angle - Steering angle from user (-1 to 1)
  • user/throttle - Throttle from user (-1 to 1)
  • user/mode - Drive mode: ‘user’, ‘local_angle’, or ‘local’

Autopilot

  • pilot/angle - Steering angle from AI model
  • pilot/throttle - Throttle from AI model
  • run_pilot - Boolean, whether autopilot should run

Drive Train

  • angle or steering - Final steering value sent to servo
  • throttle - Final throttle value sent to ESC/motor

Recording

  • recording - Boolean, whether data is being saved
  • tub/num_records - Number of records saved

Sensors

  • enc/speed - Speed from encoder (odometry)
  • imu/acl_x, imu/acl_y, imu/acl_z - Accelerometer data
  • imu/gyr_x, imu/gyr_y, imu/gyr_z - Gyroscope data
  • lidar/dist_array - LIDAR distance array

Data Flow Example

Here’s how data flows through memory in a typical vehicle:

Best Practices

Naming Conventions

Use descriptive names with component prefixes:

Handling None Values

Always check for None when reading from memory:

Memory Inspection

Debug memory contents during development:

See Also