title
Self-driving Car - Python plays Grand Theft Auto 5 p.7

description
As I was contemplating the next steps, I was curious about a couple of choices for Artificially Intelligent driving. One thought I had was that we could detect both lanes, and then attempt to orient the car in between the two lanes, so long as those two lanes had different slopes. ...then I began to think about it, and wondered if the problem coudl be even more simple than that. I noticed that the times when the lanes would "both" be on one side or the other was when we were getting to close to one of the edges. So next I wondered, hmm, what if we just work with the following logic: If one lane's slope is positive, and the other is negative, then we're fine, continue straight. If both lane's slopes are negative, then we're too far left, and we should turn right. If both lane's slopes are posotive, then we're too far right, and we should turn left. ...surely it can't be that simple right? Project Github: https://github.com/sentdex/pygta5 https://twitter.com/sentdex https://www.facebook.com/pythonprogramming.net/ https://plus.google.com/+sentdex

detail
{'title': 'Self-driving Car - Python plays Grand Theft Auto 5 p.7', 'heatmap': [{'end': 575.742, 'start': 553.745, 'weight': 1}], 'summary': 'Chapter 1 focuses on implementing an ai driving algorithm using slope detection and image processing for lane detection and rule definition, including countdown implementation. chapter 2 documents tests of an autonomous scooter and ai-driven vehicle, emphasizing the need for quick release key functionality, safety, and future enhancements.', 'chapters': [{'end': 435.016, 'segs': [{'end': 115.247, 'src': 'embed', 'start': 85.646, 'weight': 0, 'content': [{'end': 97.397, 'text': "so the idea is basically if the lines are like, if both slopes are negative, that means they're to the left of us, so we should go right.", 'start': 85.646, 'duration': 11.751}, {'end': 106.446, 'text': "and if both slopes are positive, that means they're both to the right of us and we should go left and beyond that nothing else matters.", 'start': 97.397, 'duration': 9.049}, {'end': 115.247, 'text': 'And so I want to just try that really simple logic, Before we try to get too far in depth with like.', 'start': 108.962, 'duration': 6.285}], 'summary': 'If both slopes are negative, go right; if positive, go left.', 'duration': 29.601, 'max_score': 85.646, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CLFp9D9-0Eo/pics/CLFp9D9-0Eo85646.jpg'}, {'end': 196.087, 'src': 'embed', 'start': 170.016, 'weight': 1, 'content': [{'end': 174.179, 'text': "so we'll do lane one if you can't see that lane one.", 'start': 170.016, 'duration': 4.163}, {'end': 182.544, 'text': "so in this return right, we're returning the two coordinates, but also lane one, id and lane 2 id.", 'start': 174.179, 'duration': 8.365}, {'end': 190.806, 'text': 'cool, so we return those and then now, where did we return them here?', 'start': 182.544, 'duration': 8.262}, {'end': 193.146, 'text': "so then that's actually slope one, slope two.", 'start': 190.806, 'duration': 2.34}, {'end': 196.087, 'text': "so i'm just gonna call it m1, m2.", 'start': 193.146, 'duration': 2.941}], 'summary': 'Returning two coordinates, lane 1 id, and lane 2 id as slope 1 and slope 2.', 'duration': 26.071, 'max_score': 170.016, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CLFp9D9-0Eo/pics/CLFp9D9-0Eo170016.jpg'}, {'end': 362.638, 'src': 'embed', 'start': 328.015, 'weight': 2, 'content': [{'end': 329.497, 'text': 'And this means we want to slow down.', 'start': 328.015, 'duration': 1.482}, {'end': 332.1, 'text': "So we're going to release all the keys.", 'start': 329.517, 'duration': 2.583}, {'end': 342.864, 'text': 'now. um, okay, so now we have the actual driving directions.', 'start': 335.979, 'duration': 6.885}, {'end': 345.406, 'text': "uh, the other thing we want to do is we're going to do that.", 'start': 342.864, 'duration': 2.542}, {'end': 362.638, 'text': "um, let's see for uh, for i in list range um, four and list, uh, colon negative one, to count down three, three, i plus one time dot sleep one.", 'start': 345.406, 'duration': 17.232}], 'summary': 'Releasing keys to slow down, working on driving directions, and iterating through a list.', 'duration': 34.623, 'max_score': 328.015, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CLFp9D9-0Eo/pics/CLFp9D9-0Eo328015.jpg'}], 'start': 2.205, 'title': 'Ai driving algorithm and image processing', 'summary': 'Covers implementing a simple ai driving algorithm using slope detection to determine vehicle direction and explains image processing functions for lane detection and rule definition, including countdown implementation and conditional statements based on slope values.', 'chapters': [{'end': 140.156, 'start': 2.205, 'title': 'Implementing an ai driving algorithm', 'summary': "Discusses implementing a simple ai driving algorithm using slope detection to determine the vehicle's direction based on the position of the lanes in the road.", 'duration': 137.951, 'highlights': ["The algorithm determines the vehicle's direction based on the slopes of the detected lanes, with negative slopes indicating a need to go right and positive slopes indicating a need to go left. The algorithm uses simple logic to determine the vehicle's direction based on the slopes of the lanes, making it a straightforward implementation.", 'The chapter emphasizes the simplicity and effectiveness of the proposed driving algorithm, focusing on a basic approach before delving into more complex tasks. The chapter highlights the intention to start with a simple driving algorithm to test its effectiveness, prioritizing a straightforward approach over complexity.', 'The video tutorial series is part seven of the Python plays Grand Theft Auto series, focusing on implementing the AI driving algorithm. This is the seventh part of the Python plays Grand Theft Auto series, with a specific focus on implementing the AI driving algorithm discussed in the transcript.']}, {'end': 244.761, 'start': 140.156, 'title': 'Image processing function explanation', 'summary': 'Explains the function for processing image data, including accessing code from github, extracting lane coordinates and ids, setting default values, and returning processed image data and slope values.', 'duration': 104.605, 'highlights': ['The function explains the process of extracting lane coordinates and IDs for slope calculation.', 'It details setting default values for slope calculations to ensure functionality even when coordinates are not found.', 'The explanation includes the process of returning processed image data and slope values for further decision making.', 'The chapter also mentions accessing code from GitHub for implementation.']}, {'end': 435.016, 'start': 244.801, 'title': 'Defining driving directions and rules', 'summary': 'Covers defining driving directions and rules for going straight, turning left, turning right, and slowing down through key presses and releases, as well as implementing a countdown and conditional statements based on slope values, particularly for the scenario when both slopes are negative.', 'duration': 190.215, 'highlights': ['The chapter covers defining driving directions and rules for going straight, turning left, turning right, and slowing down through key presses and releases.', 'Implementing a countdown using a for loop with a sleep function to count down from 4 to 1.', 'Implementing conditional statements based on slope values to determine the direction, particularly for the scenario when both slopes are negative.']}], 'duration': 432.811, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CLFp9D9-0Eo/pics/CLFp9D9-0Eo2205.jpg', 'highlights': ["The algorithm determines the vehicle's direction based on the slopes of the detected lanes, with negative slopes indicating a need to go right and positive slopes indicating a need to go left.", 'The function explains the process of extracting lane coordinates and IDs for slope calculation.', 'The chapter covers defining driving directions and rules for going straight, turning left, turning right, and slowing down through key presses and releases.']}, {'end': 908.679, 'segs': [{'end': 586.347, 'src': 'heatmap', 'start': 553.745, 'weight': 1, 'content': [{'end': 555.328, 'text': "In fact, I'll just keep holding forward.", 'start': 553.745, 'duration': 1.583}, {'end': 558.795, 'text': 'And just see how it does.', 'start': 557.915, 'duration': 0.88}, {'end': 560.356, 'text': "Oh, we're freaking.", 'start': 559.376, 'duration': 0.98}, {'end': 560.896, 'text': "No, we're done.", 'start': 560.356, 'duration': 0.54}, {'end': 562.957, 'text': 'Oh, no.', 'start': 562.537, 'duration': 0.42}, {'end': 568.279, 'text': 'Okay Oh, my gosh.', 'start': 565.398, 'duration': 2.881}, {'end': 569.64, 'text': "That's too great.", 'start': 568.76, 'duration': 0.88}, {'end': 575.742, 'text': "Yeah, that's why we picked a slow vehicle.", 'start': 574.082, 'duration': 1.66}, {'end': 576.223, 'text': 'But, yeah.', 'start': 575.822, 'duration': 0.401}, {'end': 580.665, 'text': 'Wow, are we still falling? Are you kidding? Oh, man.', 'start': 576.303, 'duration': 4.362}, {'end': 581.865, 'text': "That's hilarious.", 'start': 580.925, 'duration': 0.94}, {'end': 586.347, 'text': 'Oh, my gosh.', 'start': 585.507, 'duration': 0.84}], 'summary': 'Experiencing a humorous and unexpected outcome while using a slow vehicle.', 'duration': 32.602, 'max_score': 553.745, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CLFp9D9-0Eo/pics/CLFp9D9-0Eo553745.jpg'}, {'end': 637.34, 'src': 'embed', 'start': 611.318, 'weight': 4, 'content': [{'end': 615.501, 'text': "i'm thinking like you might not want to hold that turn for very long.", 'start': 611.318, 'duration': 4.183}, {'end': 625.527, 'text': 'so i just wonder if we should throw a release key um, very quickly, like if we just want to tap that key real quick but not hold it down.', 'start': 615.501, 'duration': 10.026}, {'end': 633.032, 'text': 'because the problem with gta is like, and especially driving with a keyboard is the turns are just so fast and so violent.', 'start': 625.527, 'duration': 7.505}, {'end': 634.773, 'text': "it's just like a full-on turn every time.", 'start': 633.032, 'duration': 1.741}, {'end': 637.34, 'text': 'Anyway, that was actually.', 'start': 635.76, 'duration': 1.58}], 'summary': 'Suggesting a quick tap release key for fast and violent turns in gta while driving with a keyboard.', 'duration': 26.022, 'max_score': 611.318, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CLFp9D9-0Eo/pics/CLFp9D9-0Eo611318.jpg'}, {'end': 767.577, 'src': 'embed', 'start': 714.25, 'weight': 1, 'content': [{'end': 722.197, 'text': 'one thing we could do is, rather than trying to slow the speed, we could turn more sharply based on how fast we believe ourselves to be going.', 'start': 714.25, 'duration': 7.947}, {'end': 723.978, 'text': "possibly i'm not really sure.", 'start': 722.197, 'duration': 1.781}, {'end': 726.28, 'text': "i'm not really sure how we can know the speed.", 'start': 723.978, 'duration': 2.302}, {'end': 735.148, 'text': 'uh, without some sort of mod to the game, and i was really hoping not to have to use mods to get other game data.', 'start': 726.28, 'duration': 8.868}, {'end': 745.633, 'text': 'i was really hoping to be able to just do this completely uh, with just the AI there we go back in back on track.', 'start': 735.148, 'duration': 10.485}, {'end': 748.034, 'text': "that's actually pretty cool, like I just had to barely turn around.", 'start': 745.633, 'duration': 2.401}, {'end': 749.674, 'text': "I'm impressed.", 'start': 748.034, 'duration': 1.64}, {'end': 757.655, 'text': "I know this probably looks horrible, but at the same time I'm uh, I'm pretty content with this.", 'start': 749.674, 'duration': 7.981}, {'end': 759.816, 'text': "I'm excited, I don't care what you guys are.", 'start': 757.655, 'duration': 2.161}, {'end': 767.577, 'text': 'yeah, this is cool, so I can at least navigate this.', 'start': 759.816, 'duration': 7.761}], 'summary': 'Exploring alternative methods to control speed and direction in the game, expressing satisfaction with the results.', 'duration': 53.327, 'max_score': 714.25, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CLFp9D9-0Eo/pics/CLFp9D9-0Eo714250.jpg'}, {'end': 888.154, 'src': 'embed', 'start': 859.473, 'weight': 0, 'content': [{'end': 864.021, 'text': "I might even just keep building on top of that because the next thing that we're going to have issue with is traffic.", 'start': 859.473, 'duration': 4.548}, {'end': 872.93, 'text': "intersections, and then also, maybe I'll move us to another location and see how well we work in another location besides just this one,", 'start': 865.507, 'duration': 7.423}, {'end': 876.551, 'text': "because we've kind of created everything for this area.", 'start': 872.93, 'duration': 3.621}, {'end': 878.251, 'text': "anyway. that's pretty exciting.", 'start': 876.551, 'duration': 1.7}, {'end': 881.472, 'text': 'our first self-driving scooter.', 'start': 878.251, 'duration': 3.221}, {'end': 882.272, 'text': "that's pretty cool.", 'start': 881.472, 'duration': 0.8}, {'end': 883.673, 'text': "I'm very excited about that.", 'start': 882.272, 'duration': 1.401}, {'end': 888.154, 'text': "I wasn't, I wasn't sure how long that was going to wind up taking, especially after the last tutorial.", 'start': 883.673, 'duration': 4.481}], 'summary': 'Excited about the first self-driving scooter and planning to test in a new location.', 'duration': 28.681, 'max_score': 859.473, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CLFp9D9-0Eo/pics/CLFp9D9-0Eo859473.jpg'}], 'start': 435.016, 'title': 'Testing autonomous vehicles', 'summary': 'Documents tests of an autonomous scooter and ai-driven vehicle, highlighting challenges faced, excitement, and suggestions for improvements, emphasizing the need for quick release key functionality, safety, and future enhancements.', 'chapters': [{'end': 634.773, 'start': 435.016, 'title': 'Autonomous scooter test', 'summary': 'Documents the test of an autonomous scooter, highlighting the excitement and challenges faced, including issues with turning and speed control, with an emphasis on the need for quick release key functionality and the use of slow vehicles for safety.', 'duration': 199.757, 'highlights': ['The autonomous scooter test documented the excitement and challenges faced, including issues with turning and speed control.', 'Emphasis on the need for quick release key functionality for controlling turns and the use of slow vehicles for safety.', 'The test revealed the need to modulate the speed and not go too fast, as well as the challenge of making turns and releasing relatively quickly.', 'Issues with the violent and fast turns in GTA and the difficulty of driving with a keyboard were discussed.', 'The chapter also highlighted the humorous and entertaining aspects of the test, despite the challenges faced.']}, {'end': 767.577, 'start': 635.76, 'title': 'Ai driving test', 'summary': "Discusses the testing of an ai-driven vehicle, where the narrator expresses contentment with the vehicle's performance and suggests potential improvements for speed control and navigation.", 'duration': 131.817, 'highlights': ["The narrator expresses contentment with the AI's driving ability, despite potential setbacks and challenges.", 'The narrator suggests potential improvements for speed control and navigation by logging the number of forwards and adjusting the turning sharpness based on speed.', 'The narrator discusses the desire to achieve AI-driven navigation without the use of game mods, expressing excitement and contentment with the progress made.']}, {'end': 908.679, 'start': 767.577, 'title': 'Self-driving scooter development', 'summary': 'Discusses the development of a self-driving scooter, highlighting the need to improve speed and performance, and the excitement about successful progress and plans for future enhancements and testing in different locations.', 'duration': 141.102, 'highlights': ['The development of a self-driving scooter, with a focus on improving speed and performance, and plans to test in different locations.', 'Excitement about successful progress in developing the self-driving scooter, particularly in handling traffic intersections.', "The need to address the issue of speed and action responsiveness for the self-driving scooter's performance improvement."]}], 'duration': 473.663, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CLFp9D9-0Eo/pics/CLFp9D9-0Eo435016.jpg', 'highlights': ['The development of a self-driving scooter, with a focus on improving speed and performance, and plans to test in different locations.', 'The narrator discusses the desire to achieve AI-driven navigation without the use of game mods, expressing excitement and contentment with the progress made.', 'The narrator suggests potential improvements for speed control and navigation by logging the number of forwards and adjusting the turning sharpness based on speed.', 'The autonomous scooter test documented the excitement and challenges faced, including issues with turning and speed control.', 'Emphasis on the need for quick release key functionality for controlling turns and the use of slow vehicles for safety.']}], 'highlights': ["The algorithm determines the vehicle's direction based on the slopes of the detected lanes, with negative slopes indicating a need to go right and positive slopes indicating a need to go left.", 'The chapter covers defining driving directions and rules for going straight, turning left, turning right, and slowing down through key presses and releases.', 'The function explains the process of extracting lane coordinates and IDs for slope calculation.', 'The development of a self-driving scooter, with a focus on improving speed and performance, and plans to test in different locations.', 'The narrator suggests potential improvements for speed control and navigation by logging the number of forwards and adjusting the turning sharpness based on speed.', 'Emphasis on the need for quick release key functionality for controlling turns and the use of slow vehicles for safety.', 'The autonomous scooter test documented the excitement and challenges faced, including issues with turning and speed control.', 'The narrator discusses the desire to achieve AI-driven navigation without the use of game mods, expressing excitement and contentment with the progress made.']}