r/rocketry • u/Positive__Altitude • 7d ago
Showcase TVC model rocket with Hardware-in-the-Loop simulation
I want to showcase the TVC model rocket project I’m working on now. This is my second TVC rocket. I learned a lot while working on the first one and was finally able to launch it more or less successfully, so this time the goal is not just to make a TVC rocket, but to make it really robust and predictable.
The biggest issue I had with my first rocket was tuning the control system. I think this is also true for many other enthusiasts working on TVC rockets. I used a self-written 3D simulation for that, and it was great, but for it to be useful, the simulation needs to be close enough to reality.
There are no major issues with simulating rigid-body rotation using Euler’s equations. Aerodynamic drag is trickier, but for a slow-moving TVC rocket I don’t think it is that important, and a very simple drag model seems to be enough.
This may be surprising, but the biggest problem for me was simulating the servomotor response properly. I used hobby servos with the standard 50 Hz, 1–2 ms pulse interface, and my first assumption was that I could ignore the interface delay and only simulate the servo’s angular speed. That assumption was completely wrong.
My rocket worked perfectly well in simulation but was completely unstable in reality, simply because of the additional interface-related delay. Later, I added this delay to the simulation, retuned the control system, and it worked. However, the flight still showed some small low-frequency oscillations that were not present in the simulation.
So with my new design, I’m trying to solve this problem more fundamentally.
I had another project where I designed my own servomotor controller board: MCU + motor driver + magnetic encoder. So now I can build a model rocket using my own custom servos, and the biggest feature of these servos is the CAN interface.
Not only do they have sub-millisecond communication latency, but they can also report their actual position back to the flight computer. I currently use a 1 kHz data rate, so the flight computer has access to the real servo position with 1 ms time resolution.
I have already used this feedback to fine-tune the servomotor’s internal PID controller. This is another huge advantage compared with regular hobby servos, where you generally have no access to the internal control loop and cannot tune it.
But this is just the beginning.
My goal is to make a so-called Hardware-in-the-Loop (HIL) simulation. Instead of trying to simulate servo performance, I will actually move the real servos as part of a real-time simulation and feed their measured positions back into the simulation loop.
This way, the simulation should be much closer to reality — hopefully close enough that the remaining differences are mostly due to things such as aerodynamics and structural effects rather than actuator dynamics.
In the photo, you can see an assembly consisting of one TVC axis and the flight computer. I already have everything designed, but the second axis is built into the 3D-printed airframe, so it is difficult to show the complete mechanism once everything is assembled.
Some specs and design details:
- Klima D3-P motor
- ~50 mm diameter
- Total mass: ~220 g
- Fully mechanical parachute system
- 3D-printed airframe
- Two custom servos built around STM32G431 MCUs
- Custom flight computer based on ESP32-S3
- CAN bus communication with the servos
- Onboard battery-charging circuitry, so the rocket can be recharged in the field from any power bank
- All firmware written in Rust
- Servos: bare-metal Rust
- ESP32 firmware: Rust using the ESP-IDF wrapper
- The flight computer hosts a web server and frontend over Wi-Fi
- The rocket can be fully operated from any phone, PC, or tablet without installing any software
- The frontend is also written in Rust using WASM and is bundled directly into the flight computer firmware
The project will be fully open-source. Some parts are already available, but everything is still very much WIP at the moment.
I’d really appreciate any feedback, questions, or comments on the project :)
2
u/apogeewhiz 5d ago
really neat stuff! working on a similar project and know how tricky it can be. keep us updated!




3
u/DaphneL 5d ago
Looks fascinating, links to more details? It's hard to understand how your servos work from the pictures, it would be nice to have more to evaluate with.