In the beginning, I simply wanted to build a self-stabilizing model rocket. This turned out to be a much more difficult task than I was prepared for. From PID loops to sensor fusion & integration, writing the thrust vector control (TVC) software was a huge struggle. There were many obstacles in my path to my dream of a self-stabilizing model rocket.
A Losing Battle
I’ll admit – I didn’t choose a great IMU for my rocket flight computer STARLIGHT. It would have been significantly easier if I had chosen a better IMU such as the BNO085, with built-in sensor fusion. This wasn’t a critical mistake, however it made my life harder.
I had to choose between two ways of receiving my gyroscope data. I could either take the raw data from the gyroscope and integrate it, which would get me a very precise reading. However, this reading was not always accurate. If I moved the board too fast, the RP2040 simply couldn’t keep up and integrate fast enough. This lead to error building up and overall rendering this strategy pointless.
Sensor Fusion
I chose to go the more standard (albeit more complex) route – sensor fusion. This was difficult to get running, but it was made significantly easier with the help of https://github.com/micropython-IMU/micropython-fusion. This is an IMU sensor fusion algorithm already written and ready to use. The downside to using sensor fusion instead of integration is it was significantly less precise. I was getting fluctuations of +-2-3 degrees, even when the board was sitting completely still. I decided this would be good enough for my rocket. However, it may present issues for other applications.
From Numbers to Movement
Mapping this data to servo positions was fairly easy. All I really had to do was find the limits on both my X and Y servos and map the sensor fusion output to these servos through a PID loop.
The Result
The result was a TVC gimbal ready to be placed inside a model rocket. After nine months, I had finally done it – built a TVC system (hopefully) capable of self-stabilizing a model rocket. I’ll be launching HORIZON I hopefully sometime soon, but with school the launch might be delayed. I’m shooting for an October launch.
I know that writing sensor fusion code and interfacing with STARLIGHT might be intimidating for some people. If you have any questions or concerns regarding STARLIGHT, even if you just need help writing code, reach out to [email protected].
2 responses
[…] This is a bit of a shorter blog post, as it expands on my previous article. […]
The gimbal is actuating backwards in the video – my bad! The code has since been updated to correct this behavior.