FLIR Lepton
Table of contents
Overview
voxl-lepton-server (v1.4.x) is a background systemd service that publishes thermal images from a FLIR Lepton 3.5, connected via SPI and I2C, to the Modal Pipe Architecture as a camera. Currently only for QRB5165-based platforms (VOXL 2).
If you are connecting a Lepton via USB, please see voxl-uvc-flir
Supports the following FLIR cameras:
- Lepton V3.5
Images are published at the Lepton’s native 160x120 resolution at 9 fps and can be viewed live with voxl-portal.
Supported Carrier Boards
The Lepton can be connected directly to the VOXL 2 J10 connector (SPI-only) or through one of the following ModalAI carrier boards:
| Board | Notes |
|---|---|
| M0130 | SPI+I2C expansion board, VOXL 2 only (SPI bus 11, I2C bus 0) |
| M0141 | SPI+I2C (SPI bus 14, I2C bus 1), requires a system image newer than Dec 1, 2023 |
| M0173 | SPI+I2C (SPI bus 0, I2C bus 4), with rotated-image variants for Starling 2 |
| M0187 | Lepton breakout board with IO expander, supports hard resets of the Lepton |
| M0188 | VOXL 2 Mini Lepton board, I2C connection (single instance off J10 only, channel 0 of the mux) |
| M0216 / M0226 | Camera boards with a PI4IO IO expander for toggling the Lepton clock signal (server v1.4.0 and newer) |
The M0187, M0188, and M0216/M0226 IO expanders are auto-detected at runtime over I2C.
Configuration
Like all MPA services, voxl-lepton-server has a configuration script to enable or disable the service and set up the config file for your hardware:
voxl2:/$ voxl-configure-lepton -h
Usage:
voxl-configure-lepton {MODE}
Valid Modes are:
disable disable the service
VOXL2_J10 configure for SPI-only connection on VOXL2 J10
m0130 configure for SPI+I2C connection on M0130 (VOXL2 only)
m0130_flow M0130 on VOXL2 with flow shutter mode
m0130_manual M0130 on VOXL2 with manual shutter mode
m0173 configure for SPI+I2C connection on M0173
m0173_manual like above but with manual shutter
m0173_rotated like above but rotated image for Starling 2
m0173_rotated_manual like above but with manual shutter
m0188 configure for I2C connection on M0188
enable enable the service, leave config file alone
show this help message:
voxl-configure-lepton help
An m0141 mode is also accepted for configuring the M0141 board.
Config File
The service reads its configuration from /etc/modalai/voxl-lepton-server.conf. The available fields and their defaults are:
| Field | Default | Description |
|---|---|---|
spi_bus | 14 | SPI bus the Lepton is connected to |
spi_speed | 16000000 | SPI clock speed |
en_i2c | false | enable the optional I2C CCI (command and control interface) |
i2c_bus | 0 | I2C bus for the CCI |
shutter_mode | auto | one of auto, manual, or flow (see below) |
flow_shutter_s | 20 | seconds to wait between shutters in flow mode while on the ground |
closePeriodInFramesInAir | 1 | Lepton usually does 4, reduced for a faster shutter in the air |
openPeriodInFramesInAir | 0 | Lepton usually does 1, reduced for a faster shutter in the air |
desiredFfcPeriodMsInAir | 360000 | FFC period in the air; Lepton usually does 3 minutes, increased to 6 minutes |
desiredFfcTempDeltaCentiDegInAir | 600 | sensor temp delta triggering an FFC in the air, in centi-degrees C |
assign_cpu_num | 7 | assign the server to a certain CPU number, -1 to disable |
en_timing_msg | false | enable the debug timing message pipe |
en_rotate | false | rotate the image 180 degrees to compensate for being mounted upside down |
Shutter modes:
- Auto shutter mode is the factory default. The Lepton automatically runs the FFC (flat-field correction) shutter every 3 minutes or during large sensor temperature swings.
- Manual shutter mode disables the shutter unless manually commanded via the control pipe or the
voxl-lepton-shutterutility. - Flow shutter mode is specific to using the FLIR for optical flow position hold. It runs the shutter every
flow_shutter_sseconds on the ground and while flying in manual or acro mode. In position mode it lets the Lepton decide when to run the shutter, but with the updated in-air parameters above.
Pipes
voxl-lepton-server publishes the following pipes in /run/mpa/:
| Pipe | Description |
|---|---|
lepton0_raw | 8-bit greyscale thermal image |
lepton0_color | colormapped thermal image |
lepton0_16raw | 16-bit raw thermal image |
lepton0_log | Lepton log packets |
lepton0_timing | timing debug packets, only published when en_timing_msg is enabled |
lepton0_encoded | H265-encoded video stream |
Shutter Control
The voxl-lepton-shutter utility changes the shutter mode while voxl-lepton-server is running, forces an FFC shutter calibration, or reboots the Lepton. It sends commands over the lepton0_raw control pipe and requires en_i2c to be enabled.
voxl-lepton-shutter auto
voxl-lepton-shutter manual
voxl-lepton-shutter flow
voxl-lepton-shutter run
voxl-lepton-shutter reboot
The run command can be used in either manual or auto mode. Set the default mode with shutter_mode in /etc/modalai/voxl-lepton-server.conf.
Command Line Options
For debugging, voxl-lepton-server can be run manually from the command line:
voxl2:/$ voxl-lepton-server -h
Usage: voxl-lepton-server <options>
Options:
-c, --config load/create config file only, used by configurator
-d, --debug Show debug messages.
-e, --debug_ffc debug messages for shutter and CCI
-h, --help Show help.
-t, --timing Enable timing debug print messages
-v, --verbose Enable verbose messages
-x, --crystal_on Turn the m0226 crystal on only, then exit
-y, --crystal_off Turn the m0226 crystal off only, then exit