(Demo Game) Progress Record & Soft Intro to PID Controller

BackerLeader posted 2 min read

Video Intro

As fate has it, this is the third time I am doing control system simulation stuff in real-time, after proportional control and vehicle control system.

This demo shows controlling spaceship maneuver using PID controller in 2D. The video walkthrough covers the basic rocket control. It also shows GUI features for setting up such a control system by defining operations on fuel and signals.

Online demo: https://youtu.be/Yqh1EL9nN4g

Understanding the Problem and PID Control

One example of cruise control in everyday life is cars maintaining a steady speed on a highway. Similar concept apply to rockets or spaceships. Unlike cars, which move along a single dimension (forward), rockets operate in a 2D (or even 3D) space where they must manage not just speed but also direction, orientation, and position. Designing a cruise control system for such a scenario introduces unique challenges that require more sophisticated control mechanisms.

At its core, cruise control for a rocket or spaceship means maintaining a desired velocity or position in space despite disturbances—such as gravitational pulls, drag (in simulations), or unexpected shifts in thrust. In space, this is far from straightforward. A rocket’s motion is governed by Newton’s laws, meaning it doesn’t naturally come to rest when the engines stop. Once a rocket starts moving, it will continue drifting in that direction unless an opposing force is applied. This creates the first major challenge: how to not only reach the desired speed and direction but also prevent overshooting or oscillating around the target.

The second complication is that rockets often need to control both linear motion (x and y position) and rotational motion (angle or orientation) simultaneously. In a simulation, this might mean trying to keep the rocket pointing straight up while also maintaining a stable position or velocity. Even a small error in orientation can cause the thrust to push the rocket off-course, requiring constant adjustments. This is where a PID controller comes in, as it continuously calculates how much correction is needed based on the current error, the rate of change, and past performance.

It's helpful to visualize the problem in 2D context - and reduces complexities in implementation and simulation. Imagine trying to land a rocket on a platform: you need to precisely control its horizontal and vertical speeds while keeping it upright. A simple “on-off” control (like firing thrusters only when the error is large) results in jerky, unstable behavior. PID smooths this process by blending proportional control (correcting based on error size), integral control (accounting for accumulated errors), and derivative control (damping rapid changes).

References

If you read this far, tweet to the author to show them you care. Tweet a Thanks

More Posts

DevLog 20250722: (Special Project) Correct Physics Handling

Methodox - Jul 22

Leveling Up LLM Game Development with DSPy

kitfu10 - Apr 27

A Guide to Systems-Based Development

Trent Polack - Jul 16

[Article] Divooka, Where We Are

Methodox - Aug 16

ImagePickerKMP Demo

belizairesmoy72 - Aug 24
chevron_left