A comprehensive, type-safe Python interface for OmniPreSense radar sensors
Project description
OmniPreSense Radar
A comprehensive, type-safe Python interface for OmniPreSense radar sensors
Supports all OPS241/OPS242/OPS243 radar models with full API coverage
⚠️ DISCLAIMER: This is an unofficial, community-developed library. The author is not affiliated with OmniPreSense Corp. This library provides a Python interface for OmniPreSense radar sensors but is not endorsed or supported by the company.
🚀 Quick Start • 📚 Examples • 🛠️ Troubleshooting • 🤝 Contributing
✨ Features
- 📋 Complete API Coverage - All commands from the official API documentation
- 🔒 Type-Safe - Full typing support with comprehensive enums and data classes
- 📡 Multiple Sensor Support - Doppler (-A), FMCW (-B), and combined (-C) sensor types
- 🧵 Thread-Safe - Robust serial communication with proper synchronization
- 🔧 Context Managers - Automatic resource cleanup with
withstatements - 📊 Rich Data Structures - Structured radar readings with timestamps and metadata
- ⚡ High Performance - Efficient data streaming with configurable callbacks
- 🛡️ Error Handling - Comprehensive exception hierarchy with detailed messages
📡 Supported Models
| Model | Type | Features | Detection Range | Max Speed |
|---|---|---|---|---|
| OPS241-A | Doppler | Motion, Speed, Direction, Magnitude | 20-25m | 31.1 m/s |
| OPS242-A | Doppler | Enhanced sensitivity | 20-25m | 31.1 m/s |
| OPS243-A | Doppler | Advanced + Range* | 75-100m | 31.1 m/s |
| OPS241-B | FMCW | Range, Magnitude | 15-20m | N/A |
| OPS243-C | Combined | All features | 50-60m | 31.1 m/s |
*Range measurement pending in firmware
🚀 Quick Start
Installation
pip install omnipresense
Basic Usage
from omnipresense import create_radar, Units, OutputMode
import time
# Create radar sensor
radar = create_radar('OPS243-C', '/dev/ttyACM0')
# Use context manager for automatic cleanup
with radar:
# Configure sensor
radar.set_units(Units.KILOMETERS_PER_HOUR)
# Enable output modes (required for data transmission)
radar.enable_output_mode(OutputMode.SPEED, True)
radar.enable_output_mode(OutputMode.DIRECTION, True)
radar.enable_output_mode(OutputMode.MAGNITUDE, True)
# Define callback for radar data
def on_detection(reading):
if reading.speed and reading.speed > 1.0:
direction = reading.direction.value if reading.direction else "?"
distance = f", Distance: {reading.range_m:.1f}m" if reading.range_m else ""
print(f"Speed: {reading.speed:.1f} km/h, Direction: {direction}{distance}")
# Start streaming data
print("Move something in front of the radar...")
radar.start_streaming(on_detection)
time.sleep(10) # Stream for 10 seconds
Important: Always enable appropriate output modes (
OutputMode.SPEED,OutputMode.DIRECTION,OutputMode.MAGNITUDE) for data transmission. Without these, the radar will not send any data.
📋 Requirements
- Python: 3.8.1+
- Dependencies:
pyserial>= 3.4
📁 Examples
The examples/ directory contains working scripts for different use cases:
basic_usage.py- Simple km/h speed detection with distancebasic_usage_raw.py- PySerial version showing raw protocolsimple_doppler.py- Doppler radar with direction detectionsimple_range.py- FMCW range measurementcombined_example.py- OPS243-C combined featuresdebug_usage.py- Comprehensive debugging toolraw_data_test.py- Raw data inspection utility
Run any example:
python examples/basic_usage.py
⚙️ Key Configuration
Output Modes (Required)
# Enable data transmission (essential!)
radar.enable_output_mode(OutputMode.SPEED, True)
radar.enable_output_mode(OutputMode.DIRECTION, True)
radar.enable_output_mode(OutputMode.MAGNITUDE, True)
Units and Sensitivity
# Set measurement units
radar.set_units(Units.KILOMETERS_PER_HOUR) # or METERS_PER_SECOND, MILES_PER_HOUR
# Adjust sensitivity (lower = more sensitive)
radar.set_magnitude_threshold(20) # Default: 20, Range: 1-200+
Filtering
# Filter readings by speed and range
radar.set_speed_filter(min_speed=1.0, max_speed=50.0)
radar.set_range_filter(min_range=0.5, max_range=25.0)
📊 Data Structure
Each radar reading provides:
@dataclass
class RadarReading:
timestamp: float # Unix timestamp
speed: Optional[float] # Speed in configured units
direction: Optional[Direction] # APPROACHING/RECEDING
range_m: Optional[float] # Range in meters
magnitude: Optional[float] # Signal strength
raw_data: Optional[str] # Original data string
🛡️ Error Handling
from omnipresense import RadarError, RadarConnectionError
try:
with create_radar('OPS243-C', '/dev/ttyACM0') as radar:
radar.set_units(Units.METERS_PER_SECOND)
# ... use radar
except RadarConnectionError:
print("Could not connect to radar sensor")
except RadarError as e:
print(f"Radar error: {e}")
🔧 Quick Troubleshooting
No Data Received?
- Enable output modes:
radar.enable_output_mode(OutputMode.SPEED, True) - Create motion: Wave your hand in front of the sensor
- Check distance: Ensure objects are within 0.5m-25m range
- Lower threshold:
radar.set_magnitude_threshold(10)
Permission Denied (Linux)?
sudo usermod -a -G dialout $USER # Add user to dialout group
# Then logout and login again
Port Not Found?
- Linux: Try
/dev/ttyUSB0,/dev/ttyACM0,/dev/ttyACM1 - macOS: Try
/dev/cu.usbmodem*,/dev/cu.usbserial* - Windows: Try
COM3,COM4,COM5, etc.
Need more help? See the comprehensive Troubleshooting Guide.
📚 Documentation & Support
- Troubleshooting Guide - Detailed issue resolution
- Contributing Guide - Development and contribution info
- Examples Directory - Working code examples
- GitHub Issues - Bug reports and feature requests
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for:
- Development environment setup
- Code quality standards
- Testing guidelines
- Pull request process
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
⚖️ Legal Notice
This project is an independent, unofficial implementation developed by the community. It is not affiliated with, endorsed by, or supported by OmniPreSense Corp.
- Trademark: "OmniPreSense" is a trademark of OmniPreSense Corp.
- Hardware: This library is designed to work with OmniPreSense radar sensors
- Support: For hardware issues, contact OmniPreSense directly. For library issues, use our GitHub Issues.
- Warranty: This software comes with no warranty. Use at your own risk.
⭐ Star this repo if it helps you build amazing radar applications! ⭐
Made with ❤️ for the radar sensing community
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file omnipresense-0.1.4.tar.gz.
File metadata
- Download URL: omnipresense-0.1.4.tar.gz
- Upload date:
- Size: 112.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a4f933bd4bc025d78c0bac13da05ca163e4ba7ae6c329968ad5591d5edeb4a7
|
|
| MD5 |
3f5f849a42fdb8a15c6a1f0f405679f0
|
|
| BLAKE2b-256 |
c35c6334dbb0943cc250c601b90b7d977b581c711a4b38cc7bcc3f18b525a3f2
|
File details
Details for the file omnipresense-0.1.4-py3-none-any.whl.
File metadata
- Download URL: omnipresense-0.1.4-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ba6d1a425c5f5b20183a8e303de51d74a3a7c86656bbd7d1bc0b316c35b1921
|
|
| MD5 |
c5ca989e67b4e94b18d9bd858b68b4b9
|
|
| BLAKE2b-256 |
5c3a9f0145e97bf956a6e7e68007651d49b204b7c25b7baf070978fd19ed512c
|