Besiege Wiki
Advertisement
Besiege Wiki
Logic-drone

A logic-stabilised drone.

Logic Stabilisation is the use of Automation-thumb Automation blocks and a machine's attitude control systems (thrusters, Reaction Wheels, etc) for stabilisation.

Unlike other stabilisation methods which rely on NoBounds and Scaling, this method can be implemented in the vanilla game. In exchange, it is a lot more complicated.

Background[]

PID Compensation Animated

Effects of varying PID parameters on the step response of a system. K_p = proportional gain, K_i = integral gain, K_d = derivative gain.

PID controllers are very commonly used in real life for stabilising and controlling error-prone systems. They are also possible to implement in Besiege.

PID stands for:

  • Proportional - How far you currently are from where you want to be (i.e. the error). If you want to point your ship north, you'll steer a lot harder if you're pointing south than if you're only a few degrees off of north.
  • Integral - The sum of all error over time, which adds up to the current constant error. If your ship is being blown aside by the wind, you'll hold the wheel off of center to counter it.
  • Derivative - How much you're moving right now. This stops you overshooting and dampens out oscillations.

These three components are adjusted with multipliers (i.e. gain components) and added together to produce the final response.

If your machine is properly balanced, you don't need the Integral component to correct constant error.

Applications[]

Like Balloon Stabilisation, it is most commonly used for VTOL aircraft stabilisation, due to its two main advantages - it can be toggled, and it's strong (in contrast to VES, which is quite weak). It also isn't completely rigid, so it can deal with massive external forces instead of just exploding. And unlike Balloon Stabilisation, it is far stronger and more resilient.

It can also be used for hover vehicles (with Sensor-thumb Sensors), ground vehicles (sorta), self-landing rockets, and stabilised gun Turrets.

Prerequisites[]

Unlike the other stabilisation technologies, Logic Stabilisation doesn't just magically work. It requires a preexisting way of controlling the machine, and a way to figure out what angle it's currently at relative to what it should be.

Attitude Control[]

This can be one of three things:

These should be balanced around the machine's Center of Mass (except for Reaction Wheels, because they're magic).

Angle Trackers[]

Angle-tracker

An anglometer-based angle tracker.

There are two forms of angle trackers:

  • Two Anglometer-thumb Anglometers on a Steering Hinge, with limits 0°-180° and keyed so that the Anglometers always try to keep 0° rotation
  • A Sensor-thumb Sensor on an RTC Steering Hinge (or two Sensors on a non-RTC Hinge)

The first is simple, while the second is complicated enough that CCCanyon wrote two blog posts on them.

If the machine uses Steering Hinges for thrust vectoring, the angle tracker must also use a Steering Hinge with the same limits and speed (or at least multiplied proportionally). This prevents the thrust vectoring system from saturating and losing its position, and allows it to wrap around and recover when the machine flips over.


Components[]

Implementations of each component are outlined as follows.

These are not meant to be used on their own! They must be combined into a full PID (or PD) controller to work properly.

Proportional[]

Pid-p

The further away from zero the machine is, the harder it will try to turn.

Use an tracker to detect the angle of the machine (relative to zero). Use it to directly control a non-RTC Steering Hinge.

  • To test if its the right way around, just run it. If the machine instantly pitches over and crashes, reverse the inputs. If it oscillates, move on.
  • Adjust the response/gain by changing the speed of the Steering Hinge (or the tracker). Make sure their limits are multiplied accordingly. Usually, 1-1 is good enough when the Derivative component is added.
  • Too much gain will make the machine oscillate. And probably crash.


Integral[]

Pid-i

If the machine is leaning to one side because of an uncentered CoM, this will (eventually) correct it. However, the machine will slide around. This is most useful if your machine drops large parts of itself (like bombs), but technically isn't required if your machine is always balanced properly.

Use fixed Anglometer-thumb Anglometers to detect which side the machine is leaning towards. Use it to activate a Timer-thumb Timer with Loop and Hold to Run enabled (and zero activation time, so it only fires for one frame) to nudge a non-RTC Steering Hinge slightly in the other direction.

This non-RTC steering hinge can be the same one used for the Proportional component. However, you need to use another set of keys.

  • To test if it's the right way around, set delay to 0 and run it. If the machine instantly pitches over and crashes, reverse the inputs. If it oscillates, move on.
  • Adjust the response/gain by changing the delay of the Timer.
  • Too much gain will make the machine oscillate. And probably crash.

Use a NOT Logic Gate-thumb Logic Gate to only turn on the Anglometers if the player control keys are not being pressed. This prevents extra error being introduced into the system.

It's technically not a proper implementation of Integral, as it is either on or off, but it achieves the same effect.


Derivative[]

Pid-d

This component dampens rotation - the faster the machine is rotating, the harder the system pushes against it. If you are stabilising a plane or other vehicle which moves at high speed, the aerodynamics of the vehicle can adequately fulfil this role.

Use a tracker to detect the rate of rotation. Use it to directly control a Reaction Wheel, RTC Steering Hinge, or thruster in the other direction.

Separate, unlimited trackers and separate attitude control systems are required for this component. Using limited-angle trackers for this component will cause problems if the machine is flipped upside-down (as it cannot work if the angle trackers are saturated, and being that far off-axis is precisely when it's needed), and a hinge cannot be RTC and non-RTC at the same time. In theory, it is possible to mix this component and the other two components (and player control as well) into a single hinge using a tracker, but in practice this isn't nearly precise enough to work.

  • To test if it's the right way around, rotate the machine. If it spins out of control, reverse the inputs. If it stops, move on.
  • Adjust the response/gain by changing the speed of the Reaction Wheel (or power of thrusters, or speed of hinge).
  • If it's too much, the machine will oscillate. However, this is pretty difficult to achieve.

For Besiege machines, this is probably the most important element of the PID controller. It makes all of the problems with the other two components go away. Its outputs can also be used at the same time for manual control, if efficiency is a must and you don't want to add a third attitude control system.

Implementation[]

The methods used to translate the component outputs into machine control are outlined as follows.

Analog[]

Logic-drone

An analog logic stabilised drone. Uses thrust vectoring to steer.

Pid-analog

The analog drone in action.

For analog control, the Proportional and Integral outputs directly control the Steering Hinges in the attitude control systems (e.g. directly controlling the angle of the thrust vectoring nozzle).

Advantages[]

  • Smooth and precise
  • Block-efficient

Disadvantages[]

  • Complicated/multiple attitude control setups


Digital[]

Logic-drone-2

A digital logic stabilised drone. Uses thrusters to steer.

Pid-digital

The digital drone in action.

Digital control uses Pulse-Width Modulation to translate the Proportional and Integral outputs into signals that can be used with on/off attitude control (e.g. Reaction Wheels, RTC Steering Hinges, and thrusters).

So instead of using the output hinges directly for Proportional and Integral, use them to control a PWM setup which then controls the machine's attitude control. Derivative is already digital, so it can be plugged into the same outputs. This allows only one set of Hinges/thrusters/Reaction Wheels to be required to control the vehicle.

However, due to the low Automation update rate (50hz), it is extremely choppy. This is manageable with large, heavy machines (e.g. rockets), but makes it impractical for small vehicles compared to Balloon Stabilisation.

Advantages[]

  • Only requires one set of thrusters/hinges
  • Most of the (extra) blocks can be put on the ground

Disadvantages[]

  • Choppy and imprecise
  • Slightly more expensive


See Also[]

Advertisement