Q&A with the 2020 Simulink Student Challenge Winner
At the beginning of this year, we completed the 2020 Simulink Student Challenge. There were many great entries but in todays blog I wanted to learn about the 1st place winning video. This year’s first place winning video featured an aerospace example showing how Simulink could be used to simulate a rocket launch in the game Kerbal Space program. This project was an innovative way to use Simulink and because of that I wanted to learn more about the project and the student behind the video, Thomas Hayden, with a Q&A.
Q&A with Thomas
Hello Thomas, can you tell use a little bit about yourself and where you go to school?
I’m a 4th year undergraduate student at Northeastern University, studying Computer Science. I’ve always enjoyed being at the intersection of robotics and programming and have done two co-ops involving robotics and programming.
What was your motivation to create a Simulink model that controls a KSP rocket launch?
I’ve always been interested in robotics, am really into rockets, and I had been playing Kerbal Space Program (KSP) for a while. One day I wondered if there was a way to automate a launch in the game since all real-world launches are completely automated. I thought that would be the sort of challenge I would enjoy. I started off with Kerbal Operating System (kOS) which is a custom text-based language for controlling rockets in KSP. I had a good amount of success with using kOS, but it always felt a little limiting especially compared to something like Simulink, which has all sorts of features relevant to aerospace. Hence, I decided to try and get Simulink working with KSP.
How tricky was it to get Simulink to talk to KSP? Did you encounter any problems while connecting the MATLAB function block to the java code of KSP?
It took me a while to get the communication working between Simulink and KSP, but a lot of that time was spent finding the right tool to use. At first, I tried to communicate the applications over a telnet connection, but that couldn’t handle high enough polling rates. Once I found kRPC I tested it with a standalone Java program to make sure I knew how to use it before I looked at how Simulink could talk with it. I had never used a Java program with MATLAB before, so I needed to learn how they interacted, as well as how the MATLAB function block in Simulink interfaced with Java code. It took some work (probably since I wasn’t familiar with it) but I got the correct setup where a script run beforehand would configure the connection and then the Simulink blocks could talk over that connection.
How did you go about creating and tuning the controllers for the different sections of the flights?
The orientation of the vehicle is directly controlled using PID loops which were tuned largely with several test flights to see how it reacted. The guidance of the vehicle was notably more difficult since the ascent profile of a rocket varies based on a ton of factors including thrust of both the first and second stages, drag, payload mass, target orbit, and more. I realized I would be unable to calculate an ideal trajectory (in fact I’m not even sure if an ideal trajectory is calculated in practice or if simplifications are made to make it calculatable in flight), so I made a simplified design. The first stage flight follows a curve I plotted which aims to be horizontal at a certain altitude. The second stage then looks at the orbit it’s in and determines whether it should be burning and what attitude (orientation) to do it with.
In your video you mention logging flight data in Simulink to tune the flight parameters. What data did log and how was this data used to improve the controllers in your model?
The data logging was added to debug the attitude control which had some edge cases causing problems. An added benefit to the data logging however was that I could tune the PID loops much better, particularly the long axis rotation which is a lot harder to see in game since the rocket is nearly rotationally symmetrical. On top of these practical benefits, I had fun making other interesting plots of the flight profile and other data I found in the kRPC API.
How did Simulink make this project possible? Were there any features that you used that allowed this project to go smoothly?
The biggest reason I decided to use Simulink was the ease of looking at and debugging the design. For applications like these I find being able to visually follow the paths and the calculations incredibly valuable. I want to take the state code I have now and swap it out for some Stateflow blocks since they are designed for what I was trying to do with Simulink switches and other components. When I get around to switching it out, the code should be even easier to read through and look at.
Where would you suggest someone get started if they wanted to recreate this project?
The latest version of the code for this project is available in this github repository and can serve as a great starting point. There are some aspects that are difficult or can take a while to understand, but a similar project could be made by taking it slowly. I don’t have any formal experience writing rocket control code, but this project was done by thinking through the problems logically and taking it step by step. Remember that the benefit of a simulation is that you can run it over and over again without actually destroying a rocket!
What are your plans for this project going forward? Where can we go to see future updates?
The best and worst thing about this project is that there is an endless supply of things I want to do. First on the list is adding more options for the target orbit and adding some more complex maneuvers. After that I want to make sure the code is decently robust and then add a slew of realism mods which will bring everything up to actual earth scale, make the aerodynamics more realistic, and other improvements such as engine ignition conditions. There’s a whole list of ideas, so many in fact that there’s no chance I ever get to all of them! I would like to post updates as they seem important to my YouTube channel.
What do you want to do after you graduate?
After graduation I want to do some sort of robotic programming, and if that involves programming rockets then even better!
Is there anything else you want to say about this project?
Overall, this project has been really fun and I’d recommend other people try something like it out. I find it very rewarding to watch something run smoothly because of code I wrote, and I know many other people think the same thing.
Thank you so much Thomas for taking your time to answer these questions. It’s great to learn more about how you made this project and look forward to seeing future updates!
To view Thomas’ winning Simulink Student Challenge video and other check out the 2020 challenge page. Thanks for reading and I hope you enjoyed.
要发表评论，请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。