Self-driving car - No libraries - JavaScript course [Lecture 5]

  Рет қаралды 7,735

Radu Mariescu-Istodor

Radu Mariescu-Istodor

Күн бұрын

⭐️COURSE INTRODUCTION⭐️
Hi and welcome to the self-driving car (no libraries) JavaScript course.
You will learn to make a self-driving car simulation by implementing every component one by one. I will teach you how to implement the car driving mechanics, how to define the environment, how to simulate some sensors, how to detect collisions and how to make the car control itself using a neural network.
I will explain how artificial neural networks work, by comparing them with the real neural networks in our brain. I will teach you how to implement a neural network and how to visualize it so we can see it in action. You will also learn some optimization techniques to make our car smarter.
The entire system is quite complex, however, each component is relatively easy in and of itself. I made this course keeping in mind my high-school days back in Romania. So, the knowledge you get from school could be enough to follow along (depending on the curriculum).
We use JavaScript to implement this system and I will teach modern JavaScript techniques during this course, so, this course is perfect no matter if you want to become a software engineer or a machine learning specialist (like me - I have over 10 years research experience with machine learning).
⭐️LECTURE 5: TRAFFIC SIMULATION⭐️
We simulate traffic on the road. The simulated traffic will be dummy cars that just move with a fixed, given speed. They will be the obstacles to avoid by our self-driving car when it will make decisions by itself. We will update the sensors and collision detection codes to consider this traffic as well.
⭐️CODE⭐️
Github: github.com/gniziemazity/Self-... (4. Collision detection)
Use '5. Traffic simulation' if you plan to follow along!
My website: radufromfinland.com
⭐️ TABLE OF CONTENT ️⭐️
0:00 Intro
1:00 Generating traffic
5:23 Removing dummy car sensor
6:41 Updating collisions to consider traffic
9:10 Updating sensors to consider traffic

Пікірлер: 62
@Radu
@Radu 2 жыл бұрын
Next week the really cool AI part begins. Are you excited? :-) Course playlist: kzbin.info/aero/PLB0Tybl0UNfYoJE7ZwsBQoDIG4YN9ptyY
@cloudzero2049
@cloudzero2049 Жыл бұрын
today I added a reset button. I press the "r" key to run a reset function that places the cars back at the start and sets damaged = false; Something like this is useful if you want to keep the same code running without reloading the whole web page.
@Radu
@Radu Жыл бұрын
@@cloudzero2049 Great idea :-)
@yaroslavambrozyak882
@yaroslavambrozyak882 2 ай бұрын
This channel is a gem. Thanks to KZbin for this recommendation Radu, you are a genius 🙂
@Radu
@Radu 2 ай бұрын
Not a genius, just had a lot of practice :-)
@josephsam2145
@josephsam2145 2 ай бұрын
Thank you for the video
@Radu
@Radu 2 ай бұрын
You're welcome :-)
@aitorplaza2560
@aitorplaza2560 2 жыл бұрын
Thank you Radu, very well explained, as always. I am looking forward to the machine learning lessons.
@Radu
@Radu 2 жыл бұрын
You're welcome! And, check again on Friday :-)
@berbagimadani
@berbagimadani 2 жыл бұрын
Wow, very cool. thanks
@Radu
@Radu 2 жыл бұрын
Hi Ade, sure! No problem!
@drumforhim
@drumforhim Жыл бұрын
I recently discover your channel. Very good work explaining and teaching. Keep up!
@Radu
@Radu Жыл бұрын
Thanks and welcome :-)
@javifontalva7752
@javifontalva7752 6 ай бұрын
I loved doing this one. I can't believe I managed. I still need to understand what I am doing but I'll repeat it a few times.
@Radu
@Radu 6 ай бұрын
You can always ask.
@christopherrice891
@christopherrice891 Жыл бұрын
This video was made on April 8th, 2022 which happens to be the very next day after my birthday. I just found this video tonight and i love learning to code so i am going to watch it🤗
@Radu
@Radu Жыл бұрын
Cool :-) Maybe it's a sign!
@ghassanclassic7689
@ghassanclassic7689 2 жыл бұрын
I love your content 🥇
@Radu
@Radu 2 жыл бұрын
Thank you :-) glad to hear!
@bloppai9462
@bloppai9462 10 ай бұрын
Great video, thank you so much! Can't wait to learn how neural networks work next :D
@Radu
@Radu 10 ай бұрын
Great to hear! I plan to start the continuation to this course sometime in September.
@bloppai9462
@bloppai9462 10 ай бұрын
@@Radu I see, I'm glad to hear that there will be a part 2. I look forward to it!
@Radu
@Radu 8 ай бұрын
It will start today (in about 5 hours, actually) ;-)
@16sense
@16sense 2 ай бұрын
Hello. I am facing a problem where even after implementing the switch case I am still controlling the “DUMMY” car. The code is running without any problems and no errors in the console. Edit: The controls work using if-elseif but not using switch case. Any help would be appreciated.
@Radu
@Radu 2 ай бұрын
Could it be that you're missing the break in the switch?
@howl2339
@howl2339 Жыл бұрын
i simply copy-pasted the code and the sensor are in the wrong car, any idea?
@Radu
@Radu Жыл бұрын
Would like to see the code somehow, often there can be small differences when copying.
@JanderSilva01
@JanderSilva01 5 ай бұрын
@Radu
@Radu 5 ай бұрын
:-)
@bravetreeapple1677
@bravetreeapple1677 Жыл бұрын
So, when i implemented the dummy car, when i try to pass it, my car gets damaged, even when i'm as far as i can away. So what i mean, i can,'t pass the dummy or i get damaged. And my so called RoadBorder ends at the side of my dummy car, so when i set the dummy car to spawn in front of me, i instantly die. What do i have to do?
@Radu
@Radu Жыл бұрын
I suspect there is some problem with the segment intersection method implementation... Maybe it does line intersection instead of segment intersection? Can you recheck that part of code?
@bravetreeapple1677
@bravetreeapple1677 Жыл бұрын
@@Radu Ok, i'll let you know if it helps.
@ScriptRaccoon
@ScriptRaccoon 2 жыл бұрын
I was wondering why you are using classical for loops to iterate through arrays even though we have Array.forEach and for-of-loops? So for instance traffic.forEach(car => car.draw()) is much cleaner. The classical for loop is a bit more performant for large arrays, but here it should not make any difference. While watching the video I also thought that maybe instead of the String "ControlType" it's better to have a class "ControlledCar" which inherits from "Car" and only add the sensors there. Also, the code for the sensors for the road was very similar to the code for the sensors reacting to the traffic. Probably this can be unified. Say, every car has an obstacles array, which is set to be [...road.borders,...traffic.map(c => c.poly)] for the ControlledCar. Then the code should deal with every obstacle.
@Radu
@Radu 2 жыл бұрын
Hi, all are good points! The one about forEach is a bit funny because it was supposed to be like that, but I did a last minute change for a classical for loop and video was supposed to have a text saying 'can you rewrite this using a forEach?' to practice some syntax (but I forgot). 'ControlledCar' subclass would have been better... and 'AICar' would have been nice for the next lectures. I'll keep this in mind next time. Another good point about using one parameter instead of 2 (and not just for the sensors, but for assessing damage, as well). I think I didn't do it because for the polygons I had to loop through each segment. And looping for the road border (1 segment) is a bit confusing, especially because it should loop back to the starting point... essentially checking collision twice, unnecessarily for the road border. So, a bit questioning this last one, but it does make some things better as well. Thanks for the tips :-)
@Radu
@Radu 2 жыл бұрын
I think I'll use all these observations to update the code and make a live stream (probably in the summer / autumn) where I code the entire project with these improvements. So, keep the observations coming :-)
@ScriptRaccoon
@ScriptRaccoon 2 жыл бұрын
@@Radu I'm glad you found these tips helpful :). The question about for-loops was on my mind since viewing your first video ^^. Probably I also had some ideas while watching the other videos from the "driving car" playlist, but I cannot remember them right now. Generally speaking, I am a (too) big fan of refactoring and reusable code. Even when drawing concrete shapes on a canvas I use all sorts of variables to make the shape adjustable - just in case. The math background helps here. But many viewers don't have this background, and they prefer a more "hands on" solution. So while I appreciate that you are open for updating the code, I also very much appreciate your style and enjoy watching your videos as they are now :).
@ScriptRaccoon
@ScriptRaccoon 2 жыл бұрын
Ah I remember one more thing: I saw that you write x*x in the distance formula for example. I like to write this as Math.pow(x,2). Especially when x is a compound term. But no big ideal ...
@Radu
@Radu 2 жыл бұрын
@@ScriptRaccoon Yeah... I gave up on that. Now I teach the minimum engineering needed to get the thing to work... Because if I prepare the code for something that 'may' happen, I need to explain why I do that... It will be a break in the flow of the video and for no reason, really... I think the current code leaves quite a bit of room for experimentation and it can be done quite easily, but, of course, if you want to change many things about it, you will need to refactor some things. Glad you like the content. Thanks for watching! :-)
@sagittario8796
@sagittario8796 Жыл бұрын
Crazy how you find a relevant joke each time lol.
@Radu
@Radu Жыл бұрын
A lot of googling :-))
@OptimumConsulting
@OptimumConsulting 2 жыл бұрын
After hearing your singing... i will definitely move to Finland to become a singing teacher rather than a Javascript developer...
@Radu
@Radu 2 жыл бұрын
Please don't :-)) it's the only thing I ever sung...
@Eternam
@Eternam 2 жыл бұрын
one funny and dangerous thing you can do when the sensor is not defined is using the operator ? instead of if (self.sensor) like this: this.sensor?.setAngle(this.angle) this.sensor?.setX(this.x) this.sensor?.setY(this.y) this.sensor?.update(roadBorders) and also in this.sensor?.draw(ctx); This will not yell error if this.sensor is not defined. it will be ignored.
@Radu
@Radu 2 жыл бұрын
Haha, I see you like to play dangerously :-) also... 'self'? Somebody's into python :-)
@Eternam
@Eternam 2 жыл бұрын
Hahaha yes, Python, you got me.
@ScriptRaccoon
@ScriptRaccoon 2 жыл бұрын
Good point, but why is that "dangerous"? :)
@Radu
@Radu 2 жыл бұрын
@@ScriptRaccoon I'm not exactly sure why @Eternam said that. But what I was thinking was that in this course I try to go through several different JavaScript features on purpose, to give an overview of the language (far from all the features, but quite many of them). I think that if a code base has too many of them, it's confusing to colleagues who don't master the language yet. Like '?' has multiple roles in JavaScript... if you don't know that, you may think this is a quick way to write the ternary operator (without the 'else' part) and misuse it in the future. I know, ideally, people should learn and adapt, but from my experience, sticking to fewer features in the code base leads to better code understanding in the team.
@Eternam
@Eternam 2 жыл бұрын
​@@ScriptRaccoon it's "dangerous" because if you do a typo on a method, parameter or property with ? it will not throw any exception and can be hard to find it. I should have just warn about.
@kissmeifyouloveme5983
@kissmeifyouloveme5983 3 ай бұрын
Sir, Where is part 6? Please respond quick I mean lecture 6
@Radu
@Radu 3 ай бұрын
Check the playlist in the description or in the pinned content for the proper order to watch the videos. Lecture 6 is the video on Neural Networks.
@kissmeifyouloveme5983
@kissmeifyouloveme5983 3 ай бұрын
@@Radu ok Sir thank you.
@Radu
@Radu 3 ай бұрын
No problem.
Self-driving car - No libraries - JavaScript course [Lecture 7]
36:14
Radu Mariescu-Istodor
Рет қаралды 15 М.
Self-driving car - No libraries - JavaScript course [Lecture 8]
28:44
Radu Mariescu-Istodor
Рет қаралды 10 М.
IS THIS REAL FOOD OR NOT?🤔 PIKACHU AND SONIC CONFUSE THE CAT! 😺🍫
00:41
La revancha 😱
00:55
Juan De Dios Pantoja 2
Рет қаралды 43 МЛН
Чай будешь? #чайбудешь
00:14
ПАРОДИИ НА ИЗВЕСТНЫЕ ТРЕКИ
Рет қаралды 2,9 МЛН
Omega Boy Past 3 #funny #viral #comedy
00:22
CRAZY GREAPA
Рет қаралды 37 МЛН
Bash Scripting on Linux (The Complete Guide) Class 05 - If Statements
31:43
Segment intersection formula explained
35:26
Radu Mariescu-Istodor
Рет қаралды 30 М.
Autocomplete and Snippets in Neovim | FREE COURSE // EP 5
17:07
A Virtual World - JavaScript Course: Lesson 6 / 11 [Pseudo 3D with JavaScript]
33:43
Machine Learning Course - Lesson 1: JavaScript Drawing App
47:35
Radu Mariescu-Istodor
Рет қаралды 29 М.
AMD ZEN 6 - Next-gen Chiplets & Packaging
16:37
High Yield
Рет қаралды 175 М.
Every Weird Math Paradox
11:15
ThoughtThrill
Рет қаралды 7 М.
IS THIS REAL FOOD OR NOT?🤔 PIKACHU AND SONIC CONFUSE THE CAT! 😺🍫
00:41