openpilot

Crates.ioopenpilot
lib.rsopenpilot
version0.0.4
sourcesrc
created_at2023-12-29 20:51:24.46026
updated_at2024-02-23 11:44:50.75423
descriptionTowards fully autonomous driving
homepage
repositoryhttps://github.com/wiseaidev/openpilot
max_upload_size
id1083628
size89,538
Mahmoud (wiseaidev)

documentation

https://docs.rs/openpilot

README

๐Ÿš— openpilot

Crates.io docs License

openpilot is a comprehensive Rust crate designed to assist in building fully autonomous vehicles. The primary focus of this crate is to provide tools for constructing and simulating sensor models, and GPS sensors, and implementing Extended Kalman Filters (EKF). The library includes modules tailored for managing sensor readings, simple sensors, GPS sensors, and features a high-performance 1D Extended Kalman Filter (EKF) implementation.

In addition to these foundational functionalities, openpilot introduces the selfdrive package. This package is specifically designed for autonomous vehicle control, providing modules and structs that facilitate object tracking, cluster management, and detailed lead vehicle analysis.

๐Ÿฆ€ Why Rust?

I Like Yo Cut G!

Python is mostly Kids Oriented Programming (KOP)!

Choosing Rust for openpilot is like strapping a jet engine to your autonomous vehicle's code. Rust brings a level of memory safety and concurrency control that turns potential coding nightmares into a serene drive through bug-free landscapes. With its high-performance 1D Extended Kalman Filter and modules tailored for sensor management and autonomous control, openpilot in Rust isn't just a toolbox; it's the James Bond of autonomous vehicle development. So, why Rust? Because when your code is navigating the streets, you want a language that won't just drive, it'll drive with the precision of a surgical robot and the reliability of a Swiss watch. Welcome to the fast lane of autonomy, where Rust is the steering wheel that ensures you reach your destination, bug-free and in style.

โœจ Features

  • Autonomous Vehicle: The selfdrive package introduces modules and structs designed for autonomous vehicle control. This includes functionalities for object tracking, cluster management, and detailed lead vehicle analysis. These tools are crucial components for building a fully autonomous system.

Peak Auto Pilot Momentum

Look! My Honda is driving by itself!

  • Sensor Models: Easily construct and simulate sensor models with the flexibility to customize observation models and covariance matrices.

  • Simple Sensors: Create and utilize simple sensors for efficient data processing, allowing seamless integration into your autonomous system.

  • GPS Sensors: Implement GPS sensors with accurate readings, supporting latitude and longitude coordinates for precise location tracking.

  • 1D Extended Kalman Filter (EKF): Leverage the fast and efficient 1D EKF implementation for robust state estimation and tracking applications.

๐Ÿš€ Quick Start

Get started with the openpilot library by following these simple steps:

  1. Install the openpilot crate by adding the following line to your Cargo.toml file:
[dependencies]
openpilot = "0.0.4"
  1. Import the necessary modules and use the provided functionality in your Rust project:
use ndarray::arr2;
use openpilot::common::ext_kal_fltr::{SensorReading, SimpleSensor, GPS, EKF, FastEKF1D};
use openpilot::selfdrive::controls::radar_helpers::{Track, Cluster, Lead};

fn main() {
    // Example usage
    let data = arr2(&[[1.0, 2.0], [3.0, 4.0]]);
    let obs_model = arr2(&[[1.0, 0.0], [0.0, 1.0]]);
    let covar = arr2(&[[0.1, 0.0], [0.0, 0.1]]);
    let sensor_reading = SensorReading::new(data.clone(), obs_model.clone(), covar.clone());

    // Create a simple sensor
    let simple_sensor = SimpleSensor::new(obs_model.clone(), covar.clone(), 2);
    let reading = simple_sensor.read(data.clone(), None);
    println!("Simple Sensor Reading: {:?}", reading);

    // Create a GPS sensor
    let gps_sensor = GPS::new((0, 1), 2, 0.01);
    let latlon = &[37.7749, -122.4194];
    let reading = gps_sensor.read(latlon, None);
    println!("GPS Sensor Reading: {:?}", reading);

    // Create and use a fast 1D Extended Kalman Filter
    let mut fast_ekf_1d = FastEKF1D::new(0.1, 0.01, 0.001);
    fast_ekf_1d.update_scalar(&sensor_reading);
    fast_ekf_1d.predict(0.1);
    let (tf, tfj) = fast_ekf_1d.calc_transfer_fun(0.1);
    println!("EKF Transfer Function: {:?}, Jacobian: {:?}", tf, tfj);

    // Use Track, Cluster, and Lead structs and functions
    let mut track = Track::new();
    track.update(10.0, -5.0, 20.0, 15.0, 30.0, 0.1, 0.5, 0.5, 15.0, 20.0, 10.0);
    let key = track.get_key_for_cluster();
    println!("Track Key for Cluster: {:?}", key);

    let mut cluster = Cluster::new();
    let track1 = Track::new();
    let track2 = Track::new();
    cluster.add(track1);
    cluster.add(track2);
    let d_rel = cluster.d_rel();
    println!("Cluster Relative Distance: {:?}", d_rel);

    let mut lead = Lead {
        d_rel: 0.0,
        y_rel: 0.0,
        v_rel: 0.0,
        a_rel: 0.0,
        v_lead: 0.0,
        a_lead: 0.0,
        d_path: 0.0,
        v_lat: 0.0,
        v_lead_k: 0.0,
        a_lead_k: 0.0,
        status: false,
        fcw: true,
    };
    cluster.to_live20(&mut lead);
    println!("Lead Vehicle Information: {:?}", lead);
}

๐Ÿงช Testing

Run tests for the openpilot crate using:

cargo test

๐ŸŒ GitHub Repository

You can access the source code for openpilot on GitHub.

๐Ÿค Contributing

Contributions and feedback are welcome! If you'd like to contribute, report an issue, or suggest an enhancement, please engage with the project on GitHub. Your contributions help improve this crate for the community.

๐Ÿ’ฐ Support

My Meet Ain't Meeting

If you like this project, consider tossing a coin into the virtual tip jar. Your donations help keep the coffee flowing and the code cracking. So, if you want to be the hero this project deserves, why not sprinkle some gold coins in the developer's virtual hat?

๐Ÿ“˜ Documentation

Full documentation for openpilot is available on docs.rs.

๐Ÿ“„ License

This project is licensed under the MIT License.

Commit count: 0

cargo fmt