• Stars
    star
    1,340
  • Rank 35,068 (Top 0.7 %)
  • Language
    C
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

code powering the comma.ai panda

Welcome to panda

panda is the nicest universal car interface ever.

It supports 3x CAN, 2x LIN, and 1x GMLAN. It also charges a phone. On the computer side, it has USB.

It uses an STM32F413.

panda tests panda drivers

Usage

Setup dependencies:

# Ubuntu
sudo apt-get install dfu-util gcc-arm-none-eabi python3-pip libffi-dev git
# macOS
brew install --cask gcc-arm-embedded
brew install python3 dfu-util gcc@13

Clone panda repository:

git clone https://github.com/commaai/panda.git
cd panda

Install requirements:

pip install -r requirements.txt

Install library:

python setup.py install

See the Panda class for how to interact with the panda.

For example, to receive CAN messages:

>>> from panda import Panda
>>> panda = Panda()
>>> panda.can_recv()

And to send one on bus 0:

>>> panda.can_send(0x1aa, "message", 0)

Note that you may have to setup udev rules for Linux, such as

sudo tee /etc/udev/rules.d/11-panda.rules <<EOF
SUBSYSTEM=="usb", ATTRS{idVendor}=="bbaa", ATTRS{idProduct}=="ddcc", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="bbaa", ATTRS{idProduct}=="ddee", MODE="0666"
EOF
sudo udevadm control --reload-rules && sudo udevadm trigger

The panda jungle uses different udev rules. See the repo for instructions.

Software interface support

As a universal car interface, it should support every reasonable software interface.

Directory structure

.
├── board           # Code that runs on the STM32
├── drivers         # Drivers (not needed for use with python)
├── python          # Python userspace library for interfacing with the panda
├── tests           # Tests and helper programs for panda

Programming

See board/README.md

Debugging

To print out the serial console from the STM32, run tests/debug_console.py

Safety Model

When a panda powers up, by default it's in SAFETY_SILENT mode. While in SAFETY_SILENT mode, the buses are also forced to be silent. In order to send messages, you have to select a safety mode. Currently, setting safety modes is only supported over USB. Some of safety modes (for example SAFETY_ALLOUTPUT) are disabled in release firmwares. In order to use them, compile and flash your own build.

Safety modes optionally supports controls_allowed, which allows or blocks a subset of messages based on a customizable state in the board.

Code Rigor

The panda firmware is written for its use in conjuction with openpilot. The panda firmware, through its safety model, provides and enforces the openpilot safety. Due to its critical function, it's important that the application code rigor within the board folder is held to high standards.

These are the CI regression tests we have in place:

  • A generic static code analysis is performed by cppcheck.
  • In addition, cppcheck has a specific addon to check for MISRA C:2012 violations. See current coverage.
  • Compiler options are relatively strict: the flags -Wall -Wextra -Wstrict-prototypes -Werror are enforced.
  • The safety logic is tested and verified by unit tests for each supported car variant.
  • A recorded drive for each supported car variant is replayed through the safety logic to ensure that the behavior remains unchanged.
  • An internal Hardware-in-the-loop test, which currently only runs on pull requests opened by comma.ai's organization members, verifies the following functionalities:
    • compiling the code and flashing it through USB.
    • receiving, sending, and forwarding CAN messages on all buses, over USB.

In addition, we run the ruff linter on all python files within the panda repo.

Hardware

Check out the hardware guide

Licensing

panda software is released under the MIT license unless otherwise specified.

More Repositories

1

openpilot

openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.
Python
40,192
star
2

research

dataset and code for 2016 paper "Learning a Driving Simulator"
Python
4,105
star
3

neo

comma neo research platform
1,627
star
4

opendbc

democratize access to car decoder rings
C++
1,393
star
5

speedchallenge

The comma.ai Speed Prediction Challenge!
784
star
6

calib_challenge

The comma.ai Calibration Challenge!
Python
780
star
7

comma10k

10k crowdsourced images for training segnets
Python
670
star
8

laika

Simple Python GNSS processing library
Python
647
star
9

comma2k19

A driving dataset for the development and validation of fused pose estimators and mapping algorithms
Jupyter Notebook
572
star
10

rednose

Kalman filter library
Python
297
star
11

commavq

commaVQ is a dataset of compressed driving video
Jupyter Notebook
291
star
12

cereal

capnp struct definitions and messaging used in comma ecosystem
Cap'n Proto
157
star
13

cabana

CAN visualizer and DBC maker
JavaScript
154
star
14

chffrplus

open source dashcam software
C
133
star
15

eon-neos

Operating System for your comma two and EON
Python
122
star
16

connect

comma connect PWA
JavaScript
108
star
17

commacoloring

you like coloring books?
JavaScript
101
star
18

body

firmware for the comma body robotics dev kit
C
56
star
19

chffr-api

API to access chffr data!
JavaScript
51
star
20

monitoring

The comma.ai Driver Monitoring Challenge!
51
star
21

openpilot-apks

The source code for the APK that runs inside openpilot.
JavaScript
47
star
22

pandajs

JavaScript
46
star
23

agnos

the operating system for your comma 3/3X
Python
39
star
24

depth10k

10k images for unsupervised depthnets
HTML
37
star
25

agnos-builder

Build AGNOS, the operating system for your comma 3/3X
Python
32
star
26

eon-neos-builder

Build NEOS, the operating system for your EON
C
27
star
27

comma-steering-control

Jupyter Notebook
25
star
28

entium

A helper for converting entwine tile data into cesium tiles
Python
21
star
29

connect-app

comma Connect Mobile App
JavaScript
21
star
30

trafficlights

Simple neural network to recognize the color of traffic lights
Jupyter Notebook
20
star
31

panda-artifacts

Releases of panda code.
Python
16
star
32

eon-neos-leeco

Operating System for your EON Gold
Shell
13
star
33

android_kernel_comma_msm8996

C
12
star
34

comma-x-native

X UI Library for React Native
JavaScript
12
star
35

vidutil.js

Decode H.264 and HEVC bitstreams in the browser using FFmpeg and WebAssembly
C
10
star
36

log_reader_js

Javascript implementation of the capnp log reader
JavaScript
10
star
37

android_device_oneplus_oneplus3

upstream: https://github.com/sultanxda/android_device_oneplus_oneplus3
C
8
star
38

gnss-data

Shell
8
star
39

agnos-kernel-sdm845

Kernel for the SDM845 modules
C
8
star
40

usr

usr directory from NEOS
Python
8
star
41

jobs

work @ comma.ai
8
star
42

new-connect

a rewrite of comma connect
TypeScript
8
star
43

android_kernel_leeco_msm8996

upstream: https://github.com/LineageOS/android_kernel_leeco_msm8996/commits/cm-13.0
C
6
star
44

android_system_core

upstream: https://github.com/CyanogenMod/android_system_core
C++
6
star
45

gnss-data-alt

Shell
5
star
46

android_vendor_oneplus_oneplus3

Makefile
5
star
47

android_frameworks_base

upstream: https://github.com/CyanogenMod/android_frameworks_base
Java
5
star
48

comma-api

JavaScript
5
star
49

android_build

upstream: https://github.com/cyanogenmod/android_build
Makefile
5
star
50

flash

JavaScript
5
star
51

panda_jungle

Code powering the Panda Jungle debug board
C
4
star
52

can-message

JavaScript
4
star
53

openpilot-pyextra

Python
4
star
54

tipsi-stripe

Fork of tipsi-stripe removing Android firebase dependency
JavaScript
4
star
55

android_system_extras_su

upstream: https://github.com/CyanogenMod/android_system_extras_su
C
3
star
56

android_packages_apps_NEOSSetup

JavaScript
3
star
57

my-comma-auth

shared auth utils for my.comma.ai apps (explorer, cabana)
JavaScript
3
star
58

tensorflow-autodetect

Automatically install the cpu or gpu version of Tensorflow
Python
3
star
59

cabana-issues

Public issue tracker for https://cabana.comma.ai
3
star
60

android_packages_apps_Settings

upstream: https://github.com/CyanogenMod/android_packages_apps_Settings
Java
3
star
61

qtlocation

C++
2
star
62

gnss-data-hourly

Shell
2
star
63

android

upstream: https://github.com/CyanogenMod/android -b cm-13.0
2
star
64

android_kernel_oneplus_msm8996

upstream: https://github.com/CyanogenMod/android_kernel_oneplus_msm8996
C
2
star
65

apkpatch

generates and applies efficient patch files to whole apks
Java
2
star
66

android_frameworks_opt_net_wifi

upstream: https://github.com/CyanogenMod/android_frameworks_opt_net_wifi
Java
2
star
67

android_packages_inputmethods_LatinIME

upstream: https://github.com/CyanogenMod/android_packages_inputmethods_LatinIME
Java
2
star
68

slurm-builder

Shell
1
star
69

android_hardware_quectel

Prebuilt RIL binaries for Quectel modems
Makefile
1
star
70

android_frameworks_opt_telephony

upstream: https://github.com/CyanogenMod/android_frameworks_opt_telephony
Java
1
star
71

android_device_oppo_common

upstream: https://github.com/CyanogenMod/android_device_oppo_common
Java
1
star
72

android_vendor_cm

upstream: https://github.com/CyanogenMod/android_vendor_cm
CSS
1
star
73

opencv-python-builder

Dockerfile
1
star
74

android_packages_apps_Bluetooth

upstream: https://github.com/CyanogenMod/android_packages_apps_Bluetooth
Java
1
star