使用遗传算法的自动泊车系统 (2021)
Self-parking car using genetic algorithm (2021)

原始链接: https://trekhleb.dev/blog/2021/self-parking-car-evolution/

本文探讨了如何利用遗传算法训练虚拟汽车实现自动泊车。通过模拟进化过程,本项目展示了代表汽车行为的随机“基因组”如何通过一代代的更迭逐渐优化。 开发过程分为三个关键部分: * **肌肉**:实现引擎和转向控制,使车辆能够移动。 * **眼睛**:添加传感器,以便汽车探测障碍物。 * **大脑**:定义一个函数,将传感器输入转换为转向和油门指令。 通过遗传算法,汽车的“大脑”会随时间进化。起初,车辆的动作是随机且无效的,但随着进化,它们逐渐学会了驶向停车位并避开障碍物。到第 40 代时,汽车的泊车精度已显著提高。该项目使用 TypeScript 编写,包含一个基于浏览器的交互式模拟器,允许用户实时观察进化过程。本指南旨在作为遗传算法在机器人技术和自动驾驶导航应用方面的入门教程。

Hacker News new | past | comments | ask | show | jobs | submit login Self-parking car using genetic algorithm (2021) ( trekhleb.dev ) 64 points by trekhleb 1 day ago | hide | past | favorite | 5 comments help diydsp 1 day ago | next [–] This would be prime https://reddit.com/r/WatchMachinesLearn material. reply bagels 1 day ago | prev | next [–] "generic" -> "genetic", completely different meaning. I thought the rules were against editorializing the titles anyway. reply trekhleb 1 day ago | parent | next [–] Typo. Thanks for pointing that out. reply mococa 1 day ago | prev [–] 2021? Elon was saying this since… 1980? reply JSR_FDED 1 day ago | parent [–] Is this why FSD took a little longer? reply Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact Search:
相关文章

原文
Self-Parking car evolution

TL;DR

In this article, we'll train the car to do self-parking using a genetic algorithm.

We'll create the 1st generation of cars with random genomes that will behave something like this:

The 1st generation of cars with random genomes

On the ≈40th generation the cars start learning what the self-parking is and start getting closer to the parking spot:

The 40th generation start learning how to park

Another example with a bit more challenging starting point:

More challenging starting point for self-parking

Yeah-yeah, the cars are hitting some other cars along the way, and also are not perfectly fitting the parking spot, but this is only the 40th generation since the creation of the world for them, so be merciful and give the cars some space to grow :D

You may launch the 🚕 Self-parking Car Evolution Simulator to see the evolution process directly in your browser. The simulator gives you the following opportunities:

The genetic algorithm for this project is implemented in TypeScript. The full genetic source code will be shown in this article, but you may also find the final code examples in the Evolution Simulator repository.

We're going to use a genetic algorithm for the particular task of evolving cars' genomes. However, this article only touches on the basics of the algorithm and is by no means a complete guide to the genetic algorithm topic.

Having that said, let's deep dive into more details...

The Plan

Step-by-step we're going to break down a high-level task of creating the self-parking car to the straightforward low-level optimization problem of finding the optimal combination of 180 bits (finding the optimal car genome).

Here is what we're going to do:

  1. 💪🏻 Give the muscles (engine, steering wheel) to the car so that it could move towards the parking spot.
  2. 👀 Give the eyes (sensors) to the car so that it could see the obstacles around.
  3. 🧠 Give the brain to the car that will control the muscles (movements) based on what the car sees (obstacles via sensors). The brain will be simply a pure function movements = f(sensors).
  4. 🧬 Evolve the brain to do the right moves based on the sensors input. This is where we will apply a genetic algorithm. Generation after generation our brain function movements = f(sensors) will learn how to move the car towards the parking spot.

Giving the muscles to the car

To be able to move, the car would need "muscles". Let's give the car two types of muscles:

  1. Engine muscle - allows the car to move ↓ back, ↑ forth, or ◎ stand steel (neutral gear)
  2. Steering wheel muscle - allows the car to turn
联系我们 contact @ memedata.com