A Python description of the Kinematic Bicycle Model with an animated example.

Overview

Kinematic Bicycle Model

Total alerts Language grade: Python

Abstract

A python library for the Kinematic Bicycle model. The Kinematic Bicycle is a compromise between the non-linear and linear bicycle models for high-speed integration of the library with little configuration.

At initialisation
:param wheelbase:       (float) vehicle's wheelbase [m]
:param max_steer:       (float) vehicle's steering limits [rad]
:param dt:              (float) discrete time period [s]
:param c_r:             (float) vehicle's coefficient of resistance 
:param c_a:             (float) vehicle's aerodynamic coefficient

At every time step  
:param x:               (float) vehicle's x-coordinate [m]
:param y:               (float) vehicle's y-coordinate [m]
:param yaw:             (float) vehicle's heading [rad]
:param velocity:        (float) vehicle's velocity in the x-axis [m/s]
:param throttle:        (float) vehicle's accleration [m/s^2]
:param delta:           (float) vehicle's steering angle [rad]

:return x:              (float) vehicle's x-coordinate [m]
:return y:              (float) vehicle's y-coordinate [m]
:return yaw:            (float) vehicle's heading [rad]
:return velocity:       (float) vehicle's velocity in the x-axis [m/s]
:return delta:          (float) vehicle's steering angle [rad]
:return omega:          (float) vehicle's angular velocity [rad/s]

Advantages

  • The model allows the vehicle to come to rest without passing the model a negative acceleration; similar to the non-linear bicycle.
  • This lightweight model is able to accurately represent a vehicle with no slip or tire stiffness.

Limitations

Just like with all other bicycle models, this model is a discrete model and loses its accuracy when the time step is set too large or the vehicle is made to travel at unreasonably high speeds. Usually, the FPS of the simulation should be set to the highest possible value for the greatest accuracy. However, for rendering high-quality GIFs, 50 FPS is found to be most optimal.

Requirements

pip install numpy

Demo

Install the requirements

pip install -r requirements.txt

Play the animation

python animation.py

Concept

To simplify the equations, we perform all calculations from the rear axle.

Comments
  • Animation not running and getting warning instead

    Animation not running and getting warning instead

    When I try to run the animation, I am getting the following warning message that halts the animation:

    UserWarning: Animation was deleted without rendering anything. This is most likely not intended. To prevent deletion, assign the Animation to a variable, e.g.anim, that exists until you have outputted the Animation usingplt.show()oranim.save(). warnings.warn(

    So I assigned the variable anim for function FuncAnimation and uncommented anim.save('animation.gif', writer='imagemagick', fps=50). With this change, I see the a full white plot screen and the following on the console:

    image

    Not sure what is it that I need to do to remedy this. Your help will be highly appreciated. Thanks in advance.

    opened by enter802 6
  • not subscriptable

    not subscriptable

    File "animate.py", line 9, in from libs.car_description import Description KinematicBicycleModel-main\libs\car_description.py", line 5, in class Description: KinematicBicycleModel-main\libs\car_description.py", line 80, in Description def plot_car(self, x: float, y: float, yaw: float, steer: float) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]: TypeError: 'type' object is not subscriptable

    good first issue 
    opened by myildirimm 4
  • Plot both map and camera tracks car at the same time?

    Plot both map and camera tracks car at the same time?

    Is there a way to plot animation of both original map plot and camera tracking car plot at the same time for better visualization? I'm pretty new to matplot in python. Thanks for sharing your implementation anyways!

    image image

    opened by namKolorfuL 2
  • Wrong calculation for low FPS

    Wrong calculation for low FPS

    For lower FPS values the results of the calculations are wrong.

    For fps = 50 everything works just fine, but I wanted to simulate fps = 1 (to see where the vehicle will be every 1 second) but the algorithm crash.

    I found that for dt >= 0.073 the algorithm crash... Is there any way to use the code for higher dts?

    good first issue 
    opened by rhalaly 1
  • Pure Pursuit implementation (exists?)

    Pure Pursuit implementation (exists?)

    Hi W!

    I'm looking to evaluate the pure-pursuit algorithm in your simulator. Do you have already an implementation? If not, I'd be happy to propose my solution and to hear recommendations. Specially on making the lookahead distance dynamic, maybe speed dependant as proposed here: PurePursuit [taken from https://www.coursera.org/learn/intro-self-driving-cars]

    cheers!

    opened by IonyM-BWR 1
Owner
Winston H.
I have no idea what I am doing.
Winston H.
Data Model built using Logistic Regression Algorithm on Python.

Logistic-Regression Problem Statement: Your client is a retail banking institution. Term deposits are a major source of income for a bank. A term depo

Hemanth Babu Muthineni 0 Dec 25, 2021
Algorithms-in-Python - Programs related to DSA in Python for placement practice

Algorithms-in-Python Programs related to DSA in Python for placement practice CO

MAINAK CHAUDHURI 2 Feb 2, 2022
Minimal examples of data structures and algorithms in Python

Pythonic Data Structures and Algorithms Minimal and clean example implementations of data structures and algorithms in Python 3. Contributing Thanks f

Keon 22k Jan 9, 2023
Repository for data structure and algorithms in Python for coding interviews

Python Data Structures and Algorithms This repository contains questions requiring implementation of data structures and algorithms concepts. It is us

Prabhu Pant 1.9k Jan 1, 2023
Python Sorted Container Types: Sorted List, Sorted Dict, and Sorted Set

Python Sorted Containers Sorted Containers is an Apache2 licensed sorted collections library, written in pure-Python, and fast as C-extensions. Python

Grant Jenks 2.8k Jan 4, 2023
All Algorithms implemented in Python

The Algorithms - Python All algorithms implemented in Python (for education) These implementations are for learning purposes only. Therefore they may

The Algorithms 150.6k Jan 3, 2023
A collection of design patterns/idioms in Python

python-patterns A collection of design patterns and idioms in Python. Current Patterns Creational Patterns: Pattern Description abstract_factory use a

Sakis Kasampalis 36.2k Jan 5, 2023
A lightweight, object-oriented finite state machine implementation in Python with many extensions

transitions A lightweight, object-oriented state machine implementation in Python with many extensions. Compatible with Python 2.7+ and 3.0+. Installa

null 4.7k Jan 1, 2023
:computer: Data Structures and Algorithms in Python

Algorithms in Python Implementations of a few algorithms and datastructures for fun and profit! Completed Karatsuba Multiplication Basic Sorting Rabin

Prakhar Srivastav 2.9k Jan 1, 2023
Algorithms implemented in Python

Python Algorithms Library Laurent Luce Description The purpose of this library is to help you with common algorithms like: A* path finding. String Mat

Laurent Luce 264 Dec 6, 2022
A fast python implementation of the SimHash algorithm.

This Python package provides hashing algorithms for computing cohort ids of users based on their browsing history. As such, it may be used to compute cohort ids of users following Google's Federated Learning of Cohorts (FLoC) proposal.

Hybrid Theory 19 Dec 15, 2022
A command line tool for memorizing algorithms in Python by typing them.

Algo Drills A command line tool for memorizing algorithms in Python by typing them. In alpha and things will change. How it works Type out an algorith

Travis Jungroth 43 Dec 2, 2022
A genetic algorithm written in Python for educational purposes.

Genea: A Genetic Algorithm in Python Genea is a Genetic Algorithm written in Python, for educational purposes. I started writing it for fun, while lea

Dom De Felice 20 Jul 6, 2022
Python sample codes for robotics algorithms.

PythonRobotics Python codes for robotics algorithm. Table of Contents What is this? Requirements Documentation How to use Localization Extended Kalman

Atsushi Sakai 17.2k Jan 1, 2023
An implementation of ordered dithering algorithm in python as multimedia course project

One way of minimizing the size of an image is to simply reduce the number of bits you use to represent each pixel.

null 7 Dec 2, 2022
zoofs is a Python library for performing feature selection using an variety of nature inspired wrapper algorithms. The algorithms range from swarm-intelligence to physics based to Evolutionary. It's easy to use ,flexible and powerful tool to reduce your feature size.

zoofs is a Python library for performing feature selection using a variety of nature-inspired wrapper algorithms. The algorithms range from swarm-intelligence to physics-based to Evolutionary. It's easy to use , flexible and powerful tool to reduce your feature size.

Jaswinder Singh 168 Dec 30, 2022
A Python Package for Portfolio Optimization using the Critical Line Algorithm

A Python Package for Portfolio Optimization using the Critical Line Algorithm

null 19 Oct 11, 2022
The DarkRift2 networking framework written in Python 3

DarkRiftPy is Darkrift2 written in Python 3. The implementation is fully compatible with the original version. So you can write a client side on Python that connects to a Darkrift2 server written in C# using the original Darkrift2 library, and vice versa.

Anton Dobryakov 6 May 23, 2022
🧬 Performant Evolutionary Algorithms For Python with Ray support

?? Performant Evolutionary Algorithms For Python with Ray support

Nathan 49 Oct 20, 2022