This is a Model Rocket Simulator oriented towards active stabilization. It integrates the 3DOF Equations of Motion, allowing to tune controllers used in Model Rockets. There is pre-coded controller in the file control.py, one can modify it or run the real Flight Computer's software through Software in the Loop.

The program computes the 3DOF Equations of Motion of the Rocket and integrates their result. The Aerodynamic Coefficients are calculated using the same Extended Barrowman Equations that Open Rocket uses. The fins use modified wind tunnel data to better model their behaviour. The program also allows for fins separated from the body. More information can be found inside ZPC_PID_SIMULATOR.py and rocket_functions.py
Without the optional dependencies, the Software in the Loop module will not work.
If someone can make an .exe that works with VPython, please let me know.
The setup of the rocket is fairly simple. However, the program is not meant for designing the rocket. Open Rocket is a more comfortable option.
To run the program, run main.py.
The program will open in the file tab.

One can create a new file or open an existing one. Once a file is open, a copy can be created with the Save As button.

One must fill the required parameters of the rocket. New motors can be added in the motors folder.
- Iy is the pitching moment of inertia.
- Speed is your enemy, therefore is recommended to use the lowest mass and inertia.
- Xcg is the position of the Center of Gravity.
- Xt is the position of the TVC mount. If one is using fins, the program automatically calculates the force application point.
- All distances are measured from the tip of the nose cone.
- The Servo Definition is the minimum angle it can rotate.
- The Max Actuator Angle is the maximum angle the actuator can move (either the TVC mount or the fin).
- The Actuator Reduction is the gear ratio between the servo and the actuator.
- The Initial Misalignment only modifies the initial angle of the TVC mount (in case of using TVC stabilization).
- The Servo Velocity Compensation slows down the servo according to the load, its value is 1.45 for an SG90 without load, and 2.1 with a TVC mount. The servo class found in servo_lib.py has a test method to modify this value to fit one's servo.
- The wind is positive from right to left, and the gusts follow a Gaussian distribution.
- The effective launch rod length is the length at which the rocket can pitch somewhat freely.
- Angle of the launch rod.
Please do not leave blank entries
THE SAVE BUTTON SAVES ONLY THE CURRENT TAB, BE SURE TO CLICK IT ON ALL OF THEM

To draw the rocket, one must insert the point as coordinate from the nose cone tip, diameter in that point. With the Add Point button, one adds the point written in the entry. The Delete Point button deletes the point currently selected in the combobox. To modify a point, one has to select the desired point in the combobox, click the Select Point button, write the new coordinates in the entry, and at last, click the Modify Point button.
To draw the fins, the procedure is similar. One must fill the entries with their respective points as:
coordinate from the nose cone tip, radius to that point.
The order is the following:

Only trapezoidal fins are modelled, therefore, ensure that the root and tip chords are parallel.
After the points are written in the entries, one can either update the stabilization or control fin. Clicking the Load "" Fins button will fill the entries with the current data of the fin. The button Reset Fin sets the fin entries to a zero-area fin.
WARNING: THE USE OF CONTROL FINS DISABLES THE TVC STABILIZATION.
Examples of detached fins:
Sprint - BPS.space, and our own Roll Control System Testbed
The space between the body and the fin must be considerable, if one is unsure about a fin being attached or detached, the most conservative option is the right option.
The Angle of Attack slider allows to change the AoA at which the CP (red point) is calculated. The blue point represents the CG of the rocket. One can enable and disable the fins to quickly redraw the rocket and ensure that the CG is in the correct position.
One can activate the 3D Graphics by clicking the checkbox. IT REQUIRES VPYTHON

It was only tested on an Arduino Nano clone, so compatibility is not ensured.
Even on the Arduino, the program did not work properly with sample times smaller than 5 milliseconds.
To use the Software in the Loop function, one has to set the Port to the one in which the board is connected, and the Baudrate to the one set in the Arduino program.
One can simulate sensor noise by filling the entries with the Noise Standard Deviation of the specified sensor.
Download and include the library and create the instance with the name you want.
At the end of void setup, start the simulation.

Replace your sensor readings with Sim.getSimData() and the name of your variables.

Positive values are positive in the direction of the axes!
(Refer to the Technical Documentation)
Replace your servo.write() for:

Replace servo_command for your servo variable (in º).
The parachute variable is an int, it's normally 0 and one must make it 1 when the parachute would deploy.
In case of using the Python SITL module, refer to the example. The objective was to make it as similar as possible to an Arduino, but there are some differences, specially with the global variables having the prefix self. Only the Python SITL module is compatible with GNSS and sample times.
REMEMBER THAT THE DATA IS IN DEGREES, G'S AND M, AND YOU HAVE TO SEND THE SERVO COMMAND IN DEGREES AND THE PARACHUTE DEPLOYMENT SIGNAL AS 0 OR 1.

IF ONE IS USING SOFTWARE IN THE LOOP, THE CONTROLLER SETTINGS DO NOTHING

There are five plots in total, one can choose between a variety of variables.
$ claude mcp add AeroVECTOR \
-- python -m otcore.mcp_server <graph>