---
title: "Python behavioral models"
description: "Model ECUs that don't exist yet, in a few lines of Python"
source: https://developer.remotivelabs.com/docs/get-started/examples/python-models
last_updated: 2026-11-24
---

# Python behavioral models

- Goal: Simulate
- From: [RemotiveCar v0.9.0](https://github.com/remotivelabs/remotivelabs-remotive-car/tree/v0.9.0)
- Protocols: CAN, SOME/IP
- Vehicle domains: Lighting, Powertrain

## Run it

```bash
git clone https://github.com/remotivelabs/remotivelabs-remotive-car.git
cd remotivelabs-remotive-car

remotive topology build \
  -f instances/hello_world/main.instance.yaml \
  -f settings/can_over_udp.settings.instance.yaml \
  build

docker compose -f build/remotive_car_hello_world/docker-compose.yml --profile jupyter up --build
```

Open http://localhost:8888 and use the notebook to press the buttons that the models react to.

Writing behavioral models in python is a very simple way of creating models for ECUs that don't yet exist. For more complex models it is also useful to create unit tests.

- Part of the [RemotiveCar example](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/DOCS.md)
- Behavioral models: [bcm](https://github.com/remotivelabs/remotivelabs-remotive-car/tree/v0.9.0/models/bcm/python/bcm) and [gwm](https://github.com/remotivelabs/remotivelabs-remotive-car/tree/v0.9.0/models/gwm/python/gwm)
- Unit tests: [tests](https://github.com/remotivelabs/remotivelabs-remotive-car/tree/v0.9.0/models/bcm/python/tests)
- Instance files: [BCM/python](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/instances/ecus/BCM/python.instance.yaml) and [GWM/python](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/instances/ecus/GWM/python.instance.yaml)

Notice:
- The platform is included in each instance, since the instance depends on the platform. However, in a larger platform it would probably make sense to only include the part of the platform describing each ECU.
- In this example the same Dockerfile is used for all python code in order to reuse the same base image. You can of course use separate Dockerfile for each container.

## Running unit tests

Complex behavioral models should have unit tests. To run the unit tests for BCM:

```bash
cd models/bcm/python/bcm
uv sync
uv run poe test
```

## Where it lives in the repo

- [instances/ecus/BCM/python.instance.yaml](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/instances/ecus/BCM/python.instance.yaml)
- [instances/ecus/GWM/python.instance.yaml](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/instances/ecus/GWM/python.instance.yaml)
- [models/bcm/python/bcm/](https://github.com/remotivelabs/remotivelabs-remotive-car/tree/v0.9.0/models/bcm/python/bcm)
- [models/bcm/python/tests/](https://github.com/remotivelabs/remotivelabs-remotive-car/tree/v0.9.0/models/bcm/python/tests)
- [models/gwm/python/gwm/](https://github.com/remotivelabs/remotivelabs-remotive-car/tree/v0.9.0/models/gwm/python/gwm)

[Read this use case on GitHub](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/usecases/BEHAVIORAL_MODELS.md)

## Works well with

- [FMU models](https://developer.remotivelabs.com/docs/get-started/examples/fmu.md): Run an exported FMU as the behavior of an ECU
- [Test cases with pytest](https://developer.remotivelabs.com/docs/get-started/examples/pytest.md): Integration tests as Python code, run as part of the topology
- [Jupyter notebook](https://developer.remotivelabs.com/docs/get-started/examples/jupyter.md): Drive a running topology from a notebook with buttons and plots
