Learn Python with Talk Python's 270 hours of courses

#281: Python in Car Racing Transcript

Recorded on Wednesday, Jul 22, 2020.

00:00 I'd love to bring you stories of Python being used in amazing places outside the traditional tech silos of pure web development and data science. On this episode, you'll meet Robert Cain Replogle who works on simulation and test software at Richard Childress Racing, the NASCAR team that just finished number one and two at the Texas motor speedway. You'll hear how Python is allowing them to model car behavior airflow and much more faster than others using outdated tools. This is talk Python to me Episode 281 recorded July 22 2020.

00:33 Wait, wait, wait, wait. Normally I'd play a little guitar riff right here to kick off the episode. But this episode is about racing and race cars. So let's kick it off with a different kind of instrument. And note, let's jump into a 2017 Indy pro Mazda for a lap around the storied Brands Hatch circuit and let the engine notes be the music.

01:43 Welcome to talk Python to me, a weekly podcast on Python, the language, the libraries, the ecosystem in the personalities. This is your host, Michael Kennedy. Follow me on Twitter where I'm at m Kennedy. Keep up with the show and listen to past episodes at talk python.fm and follow the show on Twitter via at talk Python. This episode is brought to you by sonar cube and linode. Please check out what they're offering during their segments. This is a really fun episode, you're going to enjoy Kane's story. And if you're interested, you can find the full five minute video that drive around Brands Hatch at talk Python dot f m slash hatch gain. Welcome to talk Python to me. Thanks. Glad to be here. Yeah, it's awesome to have you here. I get to bring to the things that I'm really passionate about together racing in Python. All right, and you got some really cool stories to tell a kid tell already. So looking forward to having you on the show. Thanks for having me. I'm excited about it. Yeah, it's gonna be a lot of fun. And I guess as usual, let's just start at the beginning. How did you get into programming in Python? Well, pretty long story. But I started off with Do you remember the basic game guerrillas? It was like Windows 3.1. And you threw the bananas that blew up? Yeah. Yeah, that's where I started. A friend of mine showed me how to get in there and hack the explosion side. So I could never lose my brother. So that was that was the intro. At least got me started on looking at logic and reading code. And then my next project was actually programming my HP calculator. I don't know if you ever used one of those. But you know, I, I gotta admit, I was always a ti sort of person. Yeah. When I didn't have the HP when I had the T I even had one of those big widescreen, ti 90 threes that had a QWERTY keyboard in it. It was crazy. Oh, yeah. But yeah, I remember. Now this one goes back to the reverse Polish notation and everything else that everybody hated. But you were shamed if you had a ti in mechanical engineering, so everybody had a GPS. But yeah, so I did a couple scripts with that stuff, just mostly playing around. At O'Byrne. We studied Fortran 77. This was back in 96. You were in engineering? Yes. in mechanical engineering study, mechanical engineering and Auburn. Yeah, I was in chemical engineering for a year and I wanted to take C++ and they told me no, no, no, you have to take Fortran it's going to be the most important language you ever learned. Yeah. Yeah. And the older generation of mechanical engineers are still diehard Fortran, interesting. One of the teams I worked with a few years ago, their simulation was actually written mostly in Fortran. And I mean, you can't argue with the processing speed of numerical calculations, which is all the sim really is. So yeah, it smoked. By the time I was like a sophomore year, I had moved on to MATLAB. And most people were using MATLAB for their coursework and projects and things like that. So yeah, I was a big fan of MATLAB for a long time. And then all my graduate work. I did my master's at Purdue with a focus on vehicle dynamics. And all my master's work was done in MATLAB. So got a pretty good amount of experience in that I really like the scripting languages. I've done some objective c stuff in felt out of place. You know, we've compiled code and not being able to really dig into it after use MATLAB for so long. So I can just open up those API's and have a look at him right now.

05:00 They're binary. Right? Right. Yeah. And so a lot of the problems that we work on in this industry, you have to explore the data a ton before you know what you're going to do with the project. So the scripting is good for me. My co workers that are the C# and C++ guys shame me, and tell me I'm not a real programmer, you know, so, but it's all in good fun. And I continue to use MATLAB. As I started my career, Ford Motor Company had pretty much all their stuff in MATLAB at the time, when I left Ford and went to Hendrick Motorsports to be the race engineer for the 24 car with Jeff Gordon, I was sadly, sadly depressed to not be given a license from MATLAB. So I mean, they were doing everything in Excel. And they were the ones who sim runs in Fortran, right? So it was a simulation, they used Excel as a GUI, and then had this back end of Fortran piped in to run it. So it was pretty interesting, because having the power of Excel where I can just click here and do some calculations was pretty useful. Yeah, Excel is really powerful like that, right? Except it's hard to follow the logic of it, if you've got this formula leads to that, which is back over there. And then there's a conditional which jumps here and oh, it's impossible. It's impossible. I cringe when somebody sends me a big excel sheet with all kinds of formulas all over the place. The logic of the structure of it is what makes sense. And I am not a fan of VBA. So I don't like getting in the back end of that, either. But yeah, moving into the, you know, racing stuff, we spend a million dollars to try to make five horsepower, but we can't spend $2,000 on a MATLAB license to solve analytical problems. Yeah, I think that's the I mean, that's the racing take on that story. But you hear to see that story all over the place, like companies spending millions of dollars, or there's millions of dollars of efficiencies to be gained. But like, No, no, no, you're gonna use this crappy old computer that doesn't work that well, it's all locked down, or you're going to not get a license to this thing or that thing? Because for whatever reason, it's very blows my mind how some of these, these sort of organizations can be like, Pennywise pound foolish. Yeah, yeah. And it's like I had just finished simplified vehicle simulation optimization program as my masters. So I see the power of not even having to figure out what you want the car to do. You give the simulation, these limits of things that you want for the balance and for the travels and things and you just say go, and it finds the setups that will get you those vehicle outputs. And it's like, wow, that's still not really being done in the same way as what I was doing way back when. So when you're talking about simulations, is this like tire pressure, right? High camber is like the mechanical setup or something else? No, it's a full model physical model of a vehicle. So the big modeling package right now is de Mola, which is built on modelica. And it okay handles all the dynamics and vehicle parts. But there's still a lot more to it, when you want to have a nice GUI interface. You want to be able to output files. There's a whole realm of difficulty in putting this stuff together. It's pretty impressive that a lot of the teams develop their own in house. Yeah, the commercially available ones are very expensive. And you don't get what you want, you get what they produce. So if you want to do your arrow map in a different way, like there's no way you can do that, no, we use this table. And it's like, well, why can't I use this psychic learn model that I fit? And so that's some of the stuff that I'm trying to get implemented even in our in house Sim, just to move it forward and have a better model. Right. But yeah, so I kind of moved on, try to get out of racing. Actually, after I left Hendrick didn't really know what I wanted to do. You know, the schedule is just brutal in NASCAR's 38 events. And my last year on the road with the 24, we had 22 tests. So I was in town 31 hours a week, wow. And eight to 12 of those hours. Were at the shot working. And I mean, I was not having good relationship. We were having problems and and it just got to the point where I got moved into the r&d group where I did only about half as much travel and got to work on some pretty cool projects doing experimental, I guess I should say, exhibition races. So like Dale Jr, decides he's going to run the three car in xfinity with his dad's old Wrangler paint scheme, right. And they would work out a deal with Hendrick to make that race happen. And so I still get to do some race engineering. But I was mostly doing beta testing and breaking things, because I had a reputation for being able to break any sim release. So they all went through me before it got released to the guys, you know, that were going to the track. So but I still wasn't programming much. But through that I got a lot of experience with the user experience, part of it, like just making suggestions to the group of the simulation group of, Hey, can we add this little calculator thing over here? And can we add that this would be really useful for the race engineers.

10:00 The track, and maybe I'm lazy, but I like software to work very easily and fluidly. And I hate doing a lot of clicking. And if it takes 75 clicks for me to get the sim to run, I'm not happy I, you know, yeah, exactly. But then moving on after that I kind of did an about face and started doing lighting design for concerts, and I wasn't happy with the software that was available for that. So this is where I delved into the Objective C part, using x code, with course composer and doing some video projection stuff and pretty fun stage lighting, motion lights, had some pretty cool little gimmicks. I always got frustrated at shows where they had lights and video, but the color schemes clashed. So I programmed mine where the projection mapping would follow the complimentary color set of the lighting design. Oh, that's clever. That's cool. Yeah. And then I ran into the problem, we're not, you know, sometimes I would just do the projection stuff, and there would be another lighting designer, but they wouldn't have an output that they could give me easily to receive what their color scheme was. So I started using a digital camera. And I had a app that I had built from my iPad, where I could pick from the video image, and it would decode what that color of those pixels were. And then I had a color matching deal that would match it up. So even if I didn't have that data coming in, really, I was solving problems. That's what I do. Right? Yeah, that's awesome.

11:30 This portion of talk Python, to me is brought to you by sonar cube. Here's something I get asked a lot. Once you've mastered the basics of Python, how do you keep building your skill of the language? Not everyone is lucky enough to have a well versed mentor who can take the time to look over new commits and guide them in mastering the more subtle aspects of Python. That's where sonar cube static analysis comes in. Sugar Cube finds bugs, vulnerabilities, code smells and security hotspots in your code. every issue is presented in the context of the code. But the detailed description of why it's a problem and code examples to guide you in making the fix. It's powerful, fast and accurate. Out of the box. Oh, yeah. And it's free. To learn more and download sonar cube today at talkpython.fm/sonar. That's talk Python, FM slash sonar s o n AR.

12:20 Yeah. So get back into racing. Obviously, the pay is pretty good. compared to normal engineers pay. So they drove me back in I did a technical director role at a small team. And then we're still doing the lighting on the side. But then I moved on to I got invited. While I was still racing. I got invited to be an associate professor at UNC Charlotte, the University of North Carolina Charlotte. Oh, awesome. in mechanical engineering, it was in they actually have a mechanical engineering Motorsports division. Oh, wow. That's pretty specific. That's awesome. Yeah. And so they try to prepare the students for getting out into the actual race industry, which is pretty much centered here in Charlotte. Especially for NASCAR. Yeah, that's sort of the world headquarters for NASCAR like Indianapolis is for Indy, and maybe UK is for Formula One. Yeah. And I mean, it helps physically for all the teams to be close together. Because there's a lot of turnover between different teams and all and you know, as you go, not have to move all over the country to go to different places. It's just the length of my commute changes for what team I'm working with, buddy. Yeah, but so I started thinking a lot on designing this new vehicle dynamics class, and how what I was seeing in other industries with this data science movement and machine learning stuff, is that it's going to be the way of the future. I mean, there is no doubt about it. The gains that we're able to make by applying machine learning algorithms to this data is just leaps and bounds of what anybody could do in an Excel spreadsheet. And it's fast. And it's fast to develop, and somebody can have a super great idea. But the three other engineers that are going to be using this tool, they want some small aspects of it change, like how you break up the track, where you're looking at cornering forces and things. And so I felt like I wanted to make the class a lot like the vehicle dynamics class, I took my master's program, and it was heavily numerical based, it was all MATLAB. And so I just said, well, it's been a few years since I use MATLAB, but I'm sure it can't be hard to relearn. So, while I was on a full travel schedule, again, I was staying up till one and two in the morning, just making toy projects and doing tutorials and trying to get my class together because I only had two months to have not only seals enough to teach the material, but I had to write the whole course. I had to write all the homework assignments and write all the tests. And I think I was getting like four hours of sleep there for that two month period. And then when I finally had the class done, I slept for like 24 hours straight.

15:01 And it doesn't help you still just wake up tired, you know, wow. But I had a lot of great feedback. You know, they had never even had a MATLAB class, any of the students, they don't teach that in the department. And so they were all learning from scratch. And one of my ta is he loved it so much. He took my class the first semester. And then one was my ta the second semester. And he came to me, like halfway through the semester, and he's like, I almost had my whole thesis research work redone in MATLAB, because he was trying to use Excel to process engine data that was recording it like 1000 hertz, you know, 50 channels that 1000 hertz, he had these spreadsheets that were just massive. And I mean, Excel can't handle that. Yeah, the document too large or whatever. Like it only took five minutes at a time. Who knows? Yeah. And he redid it. And he was just so proud of himself. And I mean, I was proud for him, because that is a big thing to take the semester you're about to graduate and just start at Ground Zero. Yeah. But to have the skill to be able to do that and make it happen is pretty good. He actually ended up taking a job at Caterpillar designing huge diesel engines for the earthmoving equipment. Okay, yeah, Caterpillar is doing a bunch of stuff with Python. Oh, oh, yeah. Yeah. Actually, Caterpillar is one of our sponsors, too. I don't know if you knew that for our team. No, I didn't know that. Yeah, they were telling us I met with some of the guys, we were comparing machine learning notes. And he was telling us about their division that does all the reliability testing and things. So they have all their trucks instrumented. And as they're going out there, beaming the data up to a satellite and beaming it back to their data science department and processing it and trying to figure out when these engines are going to fail in a certain way. Wow. It's pretty impressive how industry has really latched on to the data science, but racing still lagging behind a field. But we still haven't got to my Python, you know, one of the things. That's right, but just one quick comment, I think the type of software that you're talking about is really interesting challenges. I got to work in this for a while as well, where it's event based, like human event based, yeah, right. We're gonna go to the track in on Saturday, the software has to work, because we're going to run the simulation in the morning and apply it in the afternoon. And if it doesn't work, it's not like well, we'll fix the bug next week. We'll push that to the next sprint like, yeah, that was the Daytona 500. And it didn't work. So you miss Oh, yeah. Tell me about it. I mean, in. And it's even worse than that, what I always tell all the young engineers that I've trained, is, there's really two things you need to do to be successful in the racing industry as an engineer, the first thing and foremost is you need to remember that the decisions you're making on this car, are gonna potentially affect somebody's life. I mean, much less, you could crash the car, you could crash the car and hurt the driver, you could kill the driver, you could crash the car, so bad that parts go through the catch fence and hurt fans, which has happened before. And so I always try to make sure that they understand the impact that they could have. But when it comes to the key talent that you need, it's measuring disappointment, because it doesn't matter how hard you try, you can show up to the racetrack with the fastest car and be the fastest in every practice and qualify on the pole in lead the most laps of the race. And then by no fault of your own cut a tire plowed into the fence, and your whole weekend. Now, no matter how good it was to that point. You're a failure now, you know, and yeah, absolutely. Yeah, I see a lot of young people really have a problem battling with depression. And I mean, I tell this story is kind of a joke, in a way, but it's serious. And it's easy to get disgruntled and like, think of yourself as a failure in this industry. Yeah, I can imagine. I mean, you have to set your expectations, right stuffs gonna happen, things are gonna go wrong, right. Sometimes your fault sometimes not. Sometimes finishing in the middle is something you got to be proud of, and not like seen as a failure or whatever. Right? Like it just I think it does take that mental sort of not necessarily toughness, but just setting the expectations in a real way. Absolutely. It seems really frustrating. Like you spend the whole weekend someone takes you out in the first corner of the race doesn't matter how good your simulation was, nope, you you're packing it up, and you're going back home. Yeah, yeah. And there's a few other aspects of it to where, I mean, we're a team, right? So if one guy gets down on the team, and you're riding back the hotel and your your minivan, and he makes some comments about how bad practice was that day, or something that affects everybody around you. And so having that positive mental attitude is the only way to be successful. And I mean, I've definitely learned a lot through my career, which is why I try to share that but in my earlier days, it was rough. I was not a good teammate and would say harsh things and I would have harsh things said to me

20:00 But back on the Python track since we still haven't made it there. So after I had my son I couldn't do working on a race team full time and teaching classes. So I had to quit the UNC Charlotte job. And I loved it and love my time with MATLAB, but then I lost my license because I was on educational license. So I had to look at the landscape of like, what I want to do at Richard Childress Racing, we had some legacy licenses at the time. But they were so old, that going back and re learning what the syntax changes were, was not really something that I had any interest in. And now we've actually upgraded we have plenty of MATLAB licenses as well. But I've put so much effort into my Python experience. And I just love it. I mean, it's clean. Yeah, my code is beautiful. I love Pepe. I love black. Oh, yeah. And just not even having to think about the whitespace. And how I do my continuation lines. And I mean, just every aspect of it. I really, the most surprising thing to me is that Python didn't show up on my radar during my entire career up until three years ago, and that is pretty interesting. Yeah, cuz just nobody in my industry used it. But yeah, so I've kind of gone full tilt on the Python kick. probably done 20 or 25, online courses and everything that's on the kaggle page. Been working on the fast AI. Yeah, I think you interviewed Jeremy Howard, who is just an amazing teacher has an amazing teaching style. You can't not like that guy. Yeah, awesome. Yeah. I don't think I have interviewed him. I should. But yeah, fast AI is cool. Yeah. And clean in I was already using pi torch. And it works on top of pi torch now. So okay, so maybe give me a perspective. Now you're three years in, you know, you're not new to the Python world at all anymore. But some of the stuff we're gonna talk about they've been doing, it's incredible. But it's still pretty fresh in your mind, I suspect, you'll come in from like this commercial MATLAB, every little aspect of a library, every toolkit I want to use, it's like another thousand dollars in a negotiation with a purchasing side of my company, versus if you can find it on GitHub or on pi pi. And it's works decent. Now, that's another thing you can do. It feels like the world is more open to just doing what you want to solve your problem. Well, and I think to put that even further, I would say that the competition level is really interesting with open source is, as you see some new idea come out, you might see a package start and then another flower pops up somewhere else. And the contributors look at each other's work. And they're like, Okay, I'm gonna come work on yours now. Yeah, you know, and just like abandon that space if somebody comes out with like a better approach to solving some issue. And I think that that is a powerful thing that these commercial software's can't compete with. Right, exactly. And they definitely can't compete with all the free help that people give. Yeah, absolutely. That's really, really interesting. So let's talk really quickly, just about like some high level stuff in racing, want to keep it a little bit focused. So we can spend a lot of time on the Python that you're writing the simulations you're doing. But just give us a sense of what type of data you're collecting. You know, is this during the race you're tracking, like tire wear? Or is it speeds? Or are you trying to simulate when you should pit? Like, what kind of stuff are you guys doing? Yeah, pretty much. Most of that were limited during the race NASCAR has they issue us, a data logger, and it is nothing that you can really mess with. And it only has certain channels. So we're only allowed to have a few channels during the race, you know, GPS location. So lat long elevation type stuff, a few basic driver things. So you'll have brake pressure, throttle position, and steering wheel angle, everything he's doing, he controls with those three things. So I mean, other than shifting gears, but most of the time, we don't even shift gears on track because you get to fourth gear, and that's where you stay for the for the whole lap. Unless you're on a read course. Yeah, yeah. But during tests, we might have a small test where we just have like 50 instruments where we're actually tracking damper travels for the suspension, all kinds of engine things, air flows through the radiators, air throws, air flows through brake ducts, you know, for running out of braking track, we have these things called wheel force transducers that are like the top of the line. They're the most expensive sensor. So you typically actually detune your car when you go test with this, because you don't want to risk hitting the wall. But it measures the three directions of force three directions, torque, tire pressure, tire temperature, and so there's quite a few sensors on just that one tire, you know, we'll use pido tubes mounted to the roof to track airflow across the top of the roof. So we can look at the pressure difference there. There's inside the engine, there's just hundred things that you could do. So the data system, the data person job is pretty demanding as well. Yeah, it sounds like it, you get, but the system we use for the races is pretty small. It's pretty lightweight.

25:00 It's not a big deal. Yeah. And then I mean, not to mention we go to the wind tunnel. I don't know if you've seen the wind shear wind tunnel, which is what we use most of the time, but it's yeah, I don't think so maybe tell people about it. Yeah, yeah, it's 180 mile an hour rolling road wind tunnel, like a treadmill. But that goes 180 miles an hour. It's a treadmill with a $300,000 stainless steel belt, my goodness, okay, you know, and so there's force pads under the belt to measure the weight on the tires. And you're also trying to capture the wind speed through the radiator, and that kind of test too. And you don't want to mess with that belt? Because it's very expensive. But 180 miles an hour is the I believe it's still the fastest wind tunnel in the world. Wow. That's pretty awesome. And I love when we do a wind tunnel test, because I only live about three miles from the wind tunnel, and I live 40 miles from the shop. So it's much nicer commute, but they don't get to listen to as much podcast. Yeah, that's true. That's definitely a drawback. But yeah, a three mile commute is pretty sweet. Yeah. So one of the things that you actually have been spending a lot of time lately is applying Python and scikit. Learn to this wind tunnel data, right? Oh, yeah, we had an aerodynamicist leave at the end of 2018, who managed the wrangling of all the data from the raw wind tunnel data into what our sim needs to ingest, to do all of its calculations. And he kind of left all of a sudden, and so I wasn't that busy. And so I was just like, hey, pick me. And so I took it over. And I have to say that the system that they were using for all this wind tunnel data in Excel was a nightmare. And so our manufacturer, General Motors had been working with a company to develop a new fitting algorithm to fit the state, you have to imagine this data is four dimensional. So you have to travel things on the body, that tell you that to your car. And then you have the yaw angle that your car is to the wind, and then you have roll, right? Okay, so it's a 40 fit problem. So they're kind of struggling with getting the accuracy that we were trying to demand and their system, the workflow is pretty hairy, and a lot of manual cutting and pasting and putting it into a form that you needed. And I got so fed up with it with this wind tunnel a few months ago, that I said, you know, what, there's another guy who's helping with this now, hey, you start with their stuff, and try to do it, mash it through. And I'm just gonna write a new script in Python. And let's see who finishes and what the results are. And so, you know, at first I was really nervous, because it was like, the first time I had tried to fit a four dimensional surface like that, in Python. And at the end of the second day, I had improved the accuracy of the fit by five times, wow, in some parts of the map, and just 500% improvement, that's insane. Yeah, I'm like, you know, but where it missed, it missed really bad. It wasn't bad everywhere. Okay. But where it missed, it was really bad. So I might have had, we talked when total terms in terms of counts, which is coefficient, but they might have an error at some point of the map of 80 counts. And I might have an error of one count, or two counts at that same point. And so the support vector regression algorithm in scikit learn is phenomenal and so easy to work with. And it fits super fast for the amount of data that we're using. But yeah, I think another interesting aspect of that project is the other aerodynamicists I was working with who kind of went on and got the headaches of the of the other package. You take the bumpy road. Yeah. When he came back? Well, I've been doing it for almost three years at that point, two and a half years. So I had suffered enough. But yeah, he, he came back and I showed him what I was doing. And he was struggling with his cheat that he uses in the wind tunnel of his excel sheet locking up and things like that. And so we had a few discussions back and forth about MATLAB versus Python and everything else. And I showed him the code for the arrow map fitter that I built. And he was like, I'm so that looks so easy. That looks so easy. And so he actually jumped on board and has been working on this project to replace his thing. And he finished it last week and use it for the first time in the wind tunnel last week. So kudos to him. That's a that's pretty good advancement. And that's a big achievement. Yeah, in a two month span, you know, yeah. Wow. But he also had a good teacher, I guess, since he calls me up. But one thing that she talked about on the show a lot is the imposter syndrome. And I have to say that it hits me right in the heart because every project I do, I've got to learn something new to finish the project. And it's like when will I ever like know enough to just sit down and not have

30:00 To pull up the documentation on some package or something, and, and you know, it kind of gets to you after a while you get stuck on some pandas. I forget what it's called. Now it's like, it's where pandas is trying to make pandas thinks you're trying to make a copy of data, but what you're really doing is pointing to the same spot in memory, right? So you're gonna run into problems when you change the one thing. And now the other thing changes. And that kind of stuff is hard to get your head around when you come from the MATLAB space. So he has lots of errors like that. But you know, having my coworker come to me, and show me what he's struggling with me let you know, just have that. Wow, I remember struggling with that. Here's how you fix it. Yeah. And that really takes away a lot of the imposter part, when you can provide so much help so quickly, without any effort. That's a great point. Because so often you're pushing the edge of the envelope, trying to do more and more of your current skill set. So you always are pushing against that edge and always, right, you got it. You feel that like that struggle, but then you get a chance to look back and help others. You're like, Oh, actually, this is easy. I clearly see what you need to do. I remember this was hard, but it doesn't feel hard anymore. Yeah, great. Well, and you know, in the racing industry, I mean, I have data that I'm processing that comes directly from NASCAR, I have the track data that's coming from multiple sources, I have the wind tunnel data that's coming from source. Your joke about I think is your Brian May said the joke about 80% of a data scientist job is wrangling data and getting it into the right form. Yeah. And 20% is them complaining about spend so much time wrangling the data, I definitely have been accused that because I will complain. But again, you have all these different sources that you don't control. And so when you have a sheet, a data file being delivered to you that changes size, in all different aspects every week, depending on the track, it has different widths and different lengths and all this stuff. And doing dealing with that by hand is just a nightmare. So Python has been a definite blessing with regards to that.

32:09 This portion of talk Python to me is brought to you by linode. Whether you're working on a personal project, or managing your enterprises infrastructure, linode has the pricing support and scale that you need to take your project to the next level, with 11 data centers worldwide, including their newest data center in Sydney, Australia, enterprise grade hardware, s3 compatible storage, and the next generation network linode delivers the performance that you expect at a price that you don't get started on the node today with a $20 credit and you get access to native SSD storage, a 40 gigabit network industry leading processors, their revamped Cloud Manager cloud.linode.com root access to your server along with their newest API and a Python COI just visit talkpython.fm/ linode when creating a new linode account, and you'll automatically get $20 credit for your next project. Oh, and one last thing they're hiring go to lynda.com slash careers to find out more, let them know that we sent you.

33:08 I can imagine and you know, the version of the software changes or you go to the track the next time they're like, Oh, we've changed the format of this, or we've added a column or taken away a column and you're like, Oh, great. Here we go. Yeah, constantly. Oh, and they always would add the column, they don't add it at the end. So in Excel where you had all your formulas related to that cell, now that cell is not the same data anymore, and you got to go through and change all your formulas again, and and it's just like halfway through the session, it's changed or something. Yeah.

33:39 I know. Or, you know, it's a data stream. So maybe the data is just not coming in anymore. Like it just you missed a packet. Yeah, like, what do you do then? And you're there's a big section of blank. Yeah, so dealing with that with pandas is just a dream come true. Cuz as like the drop in as that just gets rid all the NAS or you can replace all the NAS with zero or whatever kind of makes sense for whatever that entity is. And especially for the amount of data that we're processing from a race event where the data is all being recorded at 20 hertz, right? for hours. It's a four hour event with 10 channels at 20 hertz. Oh, and NASCAR releases all 40 cars data. So everybody had so you don't just have your two cars that are in the race, you've got the 40 cars that are in the race. That's interesting. Do you do a lot of analysis on the competitors cars? Yes, I can imagine Yes, quite quite a bit. We're actually right now what I'm gearing up to do is do a full suite of dashboards to try to get the hands into are the data in a usable format into the hands of the less technical people or even the technical people who just don't have Python experience? It's been hard for me to provide them with it. It's mostly them sending me work orders where it's like, Hey, can you run this on these files? I need this for a

35:00 Yeah, give me the report. Yeah. And so you had done. I guess it's been a couple months ago, you had the guy from streamlet. On? Yeah. Adrian on from Streamlight. Yeah, Andrew. Yeah. And I had been working with plotly and dash. And I think for the end, polished product, maybe you can make it look nicer with dash still. But you have to do all the CSS programming. I mean, who really wants to do all that stuff? So I actually downloaded streamlet today for the first time, and started working with this afternoon. And I've already got a dashboard built that is functioning with lap beta. Oh, that's cool. Plotting out lap times. And it I mean, it is just it is, wow, what a simple thing. Yeah. So for those folks who haven't heard about streaming letter didn't listen to that episode, I'll give my take on it, you can give your take on it. So the idea is, you take something that would be just a top to bottom regular script, maybe that's functions, maybe it doesn't. And you want to turn that into an interactive website. That sounds like a very far bridge to cross. But the way streamlet works is it does a bunch of magic to give you stuff that you just put into your script. And then it turns that into interactive dashboards with sliders and drop downs, and search fields, and all kinds of stuff, and integrates with plotly. And other tools as well. Yeah, it's pretty slick, right? It's really slick. And like one of the things that I'm surprised Adrian didn't really touch on or maybe didn't, I just didn't recall, it works similar to like, I do a lot of stuff in Jupyter notebook. So I'm always wanting to review my data. So I create a data frame, and then it's df dot head so I can see right, it makes sure that it's in the right form and stuff in streamlet does that and it puts it on your webpage. So you don't even have to tell it st dot table or whatever, you just put the data frame, you know, just DataFrame and then bam, it's on your page, nice. Anything that is a variable that is on a line by itself. It just assumes you want it to put that output to the HTML. And I mean, how awesome is that? I mean, this is like the best laziest package I've ever seen productivity, productive laziness or something like that. There's got to be a term for it. Yeah. And working with it for the few hours that I did. And to already have a dashboard that doesn't look great, but is functioning is I think it's pretty impressive. So yeah, I definitely listen to this something you could publish for people to interact with more real time data or so they don't have to bother you. They can go do the slider themselves or select the thing themselves. And they get the answer, right. Yeah, exactly. And sometimes too many opinions is too much definitely in racing, because everybody's making decisions from partial information. But I still think getting tools like that into as many hands in front of as many eyeballs as possible, has got to be an improvement of somebody noticing something that the other people haven't noticed yet. And hey, what's with this, or Hey, look at this correlation, you know, if you do this output metric versus your finishing position, and you see a trend of spring rates and things, having all those people poke around at this stuff, because we do have, I think our simulation has 634 user inputs, right now. So in some of those aren't, some of those are not stuff that you touch all the time, a lot of them aren't. But there's about 275 things that you set in the model to actually be able to simulate a car. And it gets worse every day, because things keep getting added to it. Right? So right, different knobs, you can turn different adjustments you can make. Yeah, and everything's interactive. It's a dynamic system. It's not a dynamic part. You can't change this spring in change. You can't change one thing and get any benefit. You have to change a system of parts, right? You change the springs to make them softer, that it changes the right height, which changes the aerodynamics, which changes the wind pressure or whatever, right? Like it's all Exactly. It's like a whack a mole, you change one thing, it's gonna change a bunch of others. Yeah, yeah, exactly. And you'll have crew chiefs that will come to you, you know, in eight minutes left and practice and want to change these five things, and expect you to know how to set the other things to keep your car from crashing into the ground. So it better run quick. Yeah, yeah. So how do you run these things? Is it computationally slow? Or do you just have a lot of hardware or is it not actually that bad?

39:27 Yes.

39:30 So it depends, there's different aspects. There's the full dynamic model, and that needs to solve at 1000 hertz. So that's a lot of data, a lot of decisions being made for how all these parts are moving on the suspension and everything how the cars sliding up with the tires across the pavement, that I won't say is slow, but it's way slower than a steady state model, which is getting rid of all the dynamics

40:00 Basically using a set of data inputs that are super simplified, and only solving at 10 hertz, so you don't get the same answer. But like in a case where you need to make a decision really quick and like right now, that is a great tool to have as well, right? If you can get an answer that you're 90% sure of, in the next 14 seconds, that is way better than getting an answer that you're 95% sure of, in 42 minutes, yeah, it's exponentially as you get your accuracy. You pay with money you pay with computational time, you pay with losing the engineer's focus, the longer he has to sit there twiddling his thumbs like his like he's daydreaming about what he's going to do in the track closes or whatever, you know, right? It's easy to lose yourself when you're running 200 Sims a week? I can imagine. Wow. So one thing I've been thinking about as we're talking is, all these different inputs, trying to notice what correlations there might be, you have access to a lot of the different cars and whatnot, it seems like there's probably a lot of machine learning stuff that you could potentially apply here, like, what's the story of machine learning in your world, and I think it is the future. So when I say we have a lot of data, most of our projects, it's not what most people like big data, guys would think, is big data. We don't have a lot of places where we can do like deep learning applications. Because we just don't have enough of the data that fits in this box. We're trying to get very specific answers. And even though you have a race with four hours of data, there's a ton of data in there that's completely worthless, because the caution came out or right if you can't feed that to a training system, when over two different races where one part you did that sent with no, no yellow flag, the other you did, obviously, higher pressures and temperatures will change. The amount of fuel used to say all those things are just like they're not comparable, right? Yeah, there's a few places that we've used some deep learning, okay, some photo stuff, you know, General Motors provides the photographer to the track. Well, during the pandemic, they don't always, but they provide a professional photographer to the track to take pictures of all your other cars, all the cars on track. So you can say, Well, here's their attitude on track. And here's our attitude. And we're doing it wrong, because they're faster than us or whatever, right. But over a weekend, you have about 7000 photos taken. And to go in, of course, it comes in with the file name of whatever the camera is set up to produce, which is pretty much meaningless when you want to find all the pictures of the 18 car, right. And so you have to look at skim through all these thumbnails of these mix cars, because they're always on track at the same time. So it's not like they're grouped together in any way. So one good application is to use a neural net to Yeah, I guess I should say convolution neural net, to look at these photos and write new file names and organize them into folders and just take the manual drudgery out of that kind of thing, right, maybe even create a dashboard that says, I want to look at this car. And I need to look at it from the side, so that I can understand how much it's like tilting forward or whatever, write the rake. So show me that show me that for this car, you could probably build that with Streamlight. That's a great idea. I think I'll build that next week.

43:28 what's crazy is like you, I mean, you're joking. It, theoretically, could be a couple of weeks, whereas like 10 years ago, that was like, we're gonna need 50 years and a million dollars of research and like a bunch of PhDs. And now it's like, maybe we'll do that in this little app. Yeah, our cute little app. Yeah, so a lot of the performance stuff. We have enough data during the race to use some deep learning. But I really think the simpler just regression analysis and classification analysis types of things. Where you're looking at data, you take all the metrics of output of these different cars, and you split it up around the track, and then you train a fairly simplified model on what do the fast cars have in common? What did the slow cars have in common? And let's not be like the slow cars. Because there is so much data it's hard to say what knob does matter what knob is the crucial Yeah, thing. So that's the direction we're going and I'm excited about it, building some new skills and being given the opportunity to apply them in so many different aspects of the job is just issued. Keep keep me motivated.

44:37 Talk Python to me. It's partially supported by our training courses. How does your team keep their Python skills sharp? How do you make sure new hires Get Started fast and learn the pythonic way? If the answer is a series of boring videos that don't inspire, or a subscription service you pay way too much for and use way too little. Listen up. A Talk Python Training. We have enterprise tears for all of our courses.

45:00 is just the one course you need for your team with for reporting and monitoring, or ditch that unused subscription for our course bundles, which include all the courses and you pay about the same price as a subscription. Once For details, visit training, talkpython.fm/ business or just email sales at talk python.fm.

45:21 Yeah, I can't imagine and racing is one of those things. That's pretty interesting. Because there's a lot of bespoke engineering that happens like one off custom engineering. Yeah, there's a team of people that are building stuff and adjusting stuff. It's not like, well, these are the three things I can get from the part store. I'm going to stick on here. Like, you guys are like, well, it would be better if it was like this. Let's go build that and try it. Right. Yeah. And our hands have been tied quite a bit recently with the rules package. And we can't do a lot of that anymore. All the parts have to be submitted to NASCAR ahead of time, and then they judge whether they like it or not. And if it's too, okay, if it's too different from anybody else, they won't approve it. So it turns into a bit of a cat and mouse game where you're trying to sneak stuff around. And every once while you see somebody get caught with something some unapproved part and they get $100,000 fine in their hand slapped. Yeah, you know, but that's a real deal. Yeah, I can imagine every little bit is an edge. And you know, you got to push it to the limit. Yeah, for sure. But I think a lot of people take for granted how much tech is in NASCAR because they look at the somewhat antiquated cars with a rear suspension from a 1956 Chevrolet pickup, and they can't understand. But the science behind trying to make a 3500 pound car with a truck suspension go fast is actually pretty impressive. Because Yeah, I mean, the 41 cars absolutely designed to be unbelievable racecars. But we're not allowed to do that. So you have to use a lot of weird tricks and things to get these things to go fast and Hanwell. And so it's it's a little bit different. I think from an engineering standpoint, the jobs in the different series is quite a bit different. I think NASCAR and IndyCar are pretty similar. You see people going back and forth between those series. You don't see a lot of Formula One, guys. Yeah, both of those series have the somewhat spec right aspect to it, right. Like a lot of rules about we're kind of going to agree on this part goes here, or any cars the same chassis as all telara chassis is or something like that. Right. Right. Yeah. But I think the jobs are quite a bit different to if a race team has 300 employees, they might only have 25. engineers in NASCAR. Yeah, in Formula One. If they have 300 employees, my understanding is that almost 300 of them have an engineering degree. Exactly. And they're they're back there to building carbon carbon adapters or for who knows what, right. Yeah. And I think that we had a few Formula One people come in and work at Richard Childress a few years ago. And the parts that they had worked on, they were incredibly talented at that aspect. But like in NASCAR, because you have fewer people, you can't be, you can't just be a tire guy. Really, like, as a race engineer, you need to be, you know, over the full spectrum of working on every aspect of this car to even hope the thing is going to go fast. Yeah. And if you had 30 or 40 people working on the little details, it'd be better, but our budgets just aren't there. Right, right. I don't know what the NASCAR prices maybe tell me to run an IndyCar? I think it's about 15 million per year, on a Formula One car. You know, Ferrari and Mercedes are spending like 300 $400 million a year? Yeah, it's a bit that's a 10 X or 20. x difference? That means a really, yeah, different constraints. If you can operate those two numbers. Yeah, there's nobody spending 100 million dollars that I'm aware of running. You know, you have to keep in mind too, that the Formula One cars, they're only running two cars. Yeah. Right. And so they have all that resource, and they're still only running two cars. So they're only paying two drivers. You look at a you know, Hendrick Motorsports or something. And they have four drivers that you're paying the driver is the most expensive part for sure. Yeah. sighs maybe that adapter that measures the wheel that you don't want to crash? Yes. Not the driver. But most drivers are still way more expensive than that. But when they when it's worth it, right, right. Yeah. I haven't looked at much of the budget stuff in a long time. What I'll say is there's a huge gap in what kind of team you're running. The guys that are out there running 35 to 40 are doing it pretty cheap. The cars themselves aren't ridiculously expensive, because it's old tech and there's, you know, we can't do carbon bodies. I mean, we have some carbon parts, but teams don't have autoclaves where they're making a monocoque. Right. But I think that going on the budget, I think the last number I heard it was about 100

50:00 $50,000 a week, you know, an event. So if you do as good as I am at math and science, I'm terrible at basic math.

50:10 So whatever 150,000 times 38 is a pretty decent number. Yeah. 5.7 million. Yeah. Nice. Yeah. So there's a big difference there. Yeah. Yeah, for sure. You know, but there's a lot of benefits to keeping your costs down to yeah. Oh, yeah. Because when you're looking at the sponsorship, and you're trying to make the sponsor dollar goes as far as possible, you know, being much cheaper is better? Yeah. Well, and it means that the sport could be more vibrant, right? Like, if one team drops down, another can come in, it's not like they have to come up with half a billion dollars. Right, right, or something insane, right, and an engineering, factory and all that kind of stuff. So yeah, it's definitely an interesting angle. So let's maybe just wrap up our show on this, which has been really, really fun, just to maybe get your thoughts on this idea of open source and Python, both for ramping up the capabilities, but also, like opening up the possibilities, right, you don't have to buy expensive licenses to custom modeling software and whatnot. How do you see that affecting, or the advantage of your team or the industry in general? Yeah, I think it's gonna be the wave of the future. I mean, I don't see why you would buy a MATLAB license now. Yeah, definitely. If you're having young engineers coming in, that haven't ever used MATLAB, and to have that be your standard, I feel like the learning curve of Matlab is just much more difficult getting it all right, getting things to work, especially the file input output aspects, that, you know, I always struggle, I had a ton of experience with MATLAB, and I still struggled with, you know, oh, I've got an XML I've got to get Okay. Well, how do I even do that? And, you know, or JSON or something? And yeah, with pandas, you just it's one line, and interprets what you've what it thinks you mean it to be in it? Yeah, I think it's going to be the wave of the future. And for race teams, free is always better. Yeah, cheap is not always good. But free is better, right. And the other angle is you can bring in people who are not potentially trained, you know, brought up through them the engineering side, or the math and MATLAB side of things, right. You could find somebody who was working at a startup, but is passionate about this, and they're really good at Python, data science, they could maybe make that transition over, potentially. Yeah, absolutely. Yeah. I mean, that's what I was saying before the science of what you do, it doesn't matter if you're, if you're working at Caterpillar, or a race team, or, you know, toilet paper factory, the the way that you're studying the data, all the data science stuff, it applies to every field in the in the universe. So that's absolutely true that you could bring in some excellent programmers. The one thing I will say, and we have some excellent programmers that are the ones who actually do our simulation department and everything. And but they don't necessarily come from a racing background. And the one thing I'll say, like I said, I was passionate about UX, the biggest thing we fight with them is trying to get them to do it the way we want. Right? not the easiest way to code. Yeah, because I need flexible tools. I need a lot of buttons and things to be able to manipulate this the way I want. And it's like one of our programmers, he was doing a job for me. And he delivered it to me. And I'm like, What is this? This is nothing like what we discussed? And like, Where is this part of it? And where is this part? How did you not include this in he's a Spanish guy, I won't try to mimic his accent. He's an experiment one guy, two, brilliant programmer, but he explained it to me. He said, when when we talked about the project, you explained a lot of things, and I didn't see why they were needed. Here's what you need to understand. If you hand me a banana, and tell me to eat it, and don't tell me to peel it, I will eat it unpeeled, I'm just like, ah.

53:57 But now he's a great guy. And we're doing a lot of good work. Right now. He's building a data store to be a server based data store for all these dashboards to be able to work flawlessly across, we're all over the country, right? So you need to have a good data system, and you need to keep that data synced. So if somebody does an analysis and post it up, it needs to change on everybody's computer, right? But the synchronization part is tough problems still, with if you have a database, and there's 18 people across the company editing the same setup, like how do you merge all that stuff? And so that has been the bane of my existence for a long time. Yeah, I'm sure you keeping all that data in sync, and you're gonna run a report and expect an answer out of it. You want to run it against the same data, because otherwise, right, you want to run out so date and all that kind of stuff, right? Oh, yeah. Yeah, absolutely. Well, thank you so much for sharing your story about how you're using Python and over at the race team. That's, that's just fantastic. Now, before we get out of here, though, I got to ask you the final two questions. Oh yeah, if you're going to write so I'm going to write the

55:00 Python code, how do you, whatever you use? If it's an analysis project, I almost always start with Jupyter notebook. Okay, a Jupyter or JupyterLab? Which one are you on right now? Jupyter, okay. And that lets me do my old MATLAB like searching around where I can print out the data. And just it's a visual thing for me to understand how the flow of this analysis needs to go. And then generally, what I'll do is, once I get done, I'll merge that all into one sale and put it in VS Code for when it's ready to actually be used on a regular basis. That way, I don't have to go through and click all the cells and well this thing was out of order. And this thing was, you know, yeah, the Jupyter is a gift and also a curse. Yeah, it's a little bit like excel in that regard that it has like these implicit go twos, not because the control flow, but because you could go back three cells, run that thing, and then jump down five cells and run the next one. And it looks like in order like they happen in order, but no, you've got to read that little execution number, then there's missing numbers that you don't really know. They maybe did. But you there's no more evidence of them. It's very tricky in that regard. So I think productizing straight Python files makes a lot of sense. Yeah. Yeah. So that's my typical workflow. Yeah, that sounds good. And then notable pipe package. I know everybody's heard about black. But for anybody who uses Jupyter, there's another package called Black seal magic that lets you apply black formatting inside a Jupyter notebook. And so Oh, my goodness. So that keeps even like my workbook, things that never make it to production, at least formatted right and looking nice. And then I can't say enough about open pixel, which is a an Excel, a Python Excel interface. It provides all the functionality of cell colors and borders, you could program it all just by typing it out, instead of clicking through 8000. Excel pop up windows and things. That's cool. And this gives you this is like your bridge to all the people who have legacy Excel stuff laying around, or they want to work in Excel. And they're like Excel, and they're like, here you go. You're not doing VBA Hold on, ya know, and and when a crew chief can only use Excel, you have to pass them an Excel sheet at the end of the day. Yeah. So that has been a blessing. And then the one thing I found out today, when I went and downloaded when I was going through the documentation on streamlet, is they have a new streamlet for teams coming out. I don't know if you've seen that. Yeah, this is going to have one click server deployment for your app. So you can work can be sweet work, the other and everything. So definitely check that out if you haven't. All right, awesome. Very good recommendations. Okay, final call to action. People are excited about this stuff, maybe making Python a bigger part of their engineering story. What do you say? I like it, they got to do it. It's a friendly environment, great places to learn all over the internet, also mostly free. And I guess the other thing I'd like to say is just shout out to all my teammates in case anybody listens to this. They probably hear me talk about Python enough. But we won. We finished first and second in the race on Sunday. So shout out to Austin Dillon. For Wow, what event was that? It was Texas, Texas motor speedway. Yeah. Cool. All right. Congratulations. And I guess it's cool to know a little bit of Python was behind the scenes there. Oh, yeah. Yeah, winning races right on. And I will mention that there's another race tomorrow night, Thursday on the NBC streaming network cool in Kansas. So definitely check that out. Right on. Awesome. Okay, and thanks again for being on the show. It's really good to hear your story and it's inspiring what you're doing. Yeah. Thanks so much for having me. I really enjoyed it and love the show. Yeah, do it right back.

58:31 This has been another episode of talk Python to me. Our guest on this episode was Robert Cain replicable. And it's been brought to you by sonar cube and linode sonar cube finds bugs, vulnerabilities, code smells and security hotspots in your code. Try it out today. It's free to use. Just visit talkpython.fm/ sonar and click download to get started. That's s o n AR, or just click the link in your podcast player. Start your next Python project on the nodes state of the art cloud service. Just visit talkpython.fm/ linode li n od E, you'll automatically get a $20 credit when you create a new account. Want to level up your Python. If you're just getting started, try my Python jumpstart by building 10 apps course or if you're looking for something more advanced, check out our new async course the digs into all the different types of async programming you can do in Python. And of course, if you're interested in more than one of these, be sure to check out our everything bundle. It's like a subscription that never expires. Be sure to subscribe to the show. Open your favorite pod catcher and search for Python. We should be right at the top. You can also find the iTunes feed at /itunes. The Google Play feed is /play in the direct RSS feed at /rss on talk python.fm. This is your host Michael Kennedy. Thanks so much for listening. I really appreciate it. Get out there and write some Python code

Back to show page
Talk Python's Mastodon Michael Kennedy's Mastodon