RoPID: PID Control in Roblox!

If you don’t want to read blobs of text I created a video that explains the module and gives an example.

A PID (Proportional, Integral, Derivative) Controller is a type of closed feedback loop that uses an algorithm to get an output that gets to the desired position quickly, doesn’t overshoot, and can resist transient errors.

PID was created for applications such as heating (to get to a desired temperature), robotics (getting a motor to a specific velocity), and cruise control for a car. The set point of a PID controller is the value you want to achieve, and the process value is the value read from the environment. PID gains are the constant values to tweak the reactions of the system (kP, kI, and kD). For a more in depth explanation of PID, see this YouTube series.

RoPID implements the PID algorithm into Roblox! It can be used for custom BodyGyros, BodyPositions, and BodyVelocities, as well as cruise control for cars or as dynamic GUI animations. PID is super useful for vehicles to get just the right amount of handling. Unlike any other PID module, RoPID has built in integral windup clamping (to stop drastic changes in output) as well as a few utility modules to assist with the PID process.

Example PID Uses:

Ball rolling with a constant velocity (uses base RoPID module)

Rolling Ball with P Controller

GUI frame following mouse, but with dynamic movement (uses Vec2 Util module)

Gui Following Mouse

Ball following goal part (uses Vec3 util module)

Ball achieving goal

I created a submarine in this video using RoPID. It’s a good example of the module in use. The uncopylocked place is here.

Installation

  • Get the Roblox Model and put it wherever you want (ReplicatedStorage recommended)
  • Go to the GitHub Repo and either download the zip or add a git submodule, then sync the src directory into your place using a tool like Rojo

The documentation and quickstart is on the GitHub README

Feel free to make Pull Requests and ask for changes!

Note: This module is similar to AeroGameFramework’s PID module. However, it adds extra utility and integral windup clamping, along with extensive documentation
41 Likes

Thanks, man! I find this convenient as I’ve been needing to make camera tweens that feel more lively.

2 Likes

These movements are so smooth and it being a module it makes it so much more convenient. Keep up the good work.

2 Likes