Passing Control
Advanced topic
POSSIBLE CHANGES
Each controller
object implements a passControl
method. It is a QoL feature
that abstracts the most common way of using specific controller, but you can achieve
the exact same results by using getThrottle
, getSteering
, completed
methods.
Even though passControl
is considered QoL, it does have it’s quirks when it
comes to gliding related controllers. If you’re a beginner I’d recommend avoiding
passControl
method in glideController and glidePIDController for the time being.
Table of contents:
Blocking nature
Controller.passControl method is using wait
to hold control until completed
method returns true.
It means that until certain condition is met, the passControl
method will not fully execute.
Unlocks control after execution
By default passControl
will unlock both steering
and throttle
at the end of execution.
You can change this behavior by calling it with false
argument.
How it works
Let’s consider two examples. First:
and second:
Both do the exactly same thing.
The Quirks
Now that we know very basic logic of passControl
, let’s consider glidePIDController
object :
Which is equivalent to:
By default glidePIDController["completed"]()
returns true only if the throttle
is larger than 0 and gliding related controllers never apply any throttle. This
means that if you don’t setup any kind of event before passing control, it will
never fully execute.
Currently this problem occurs only with glide related controllers.
How to deal with it
Even though passing control to glide controllers seems quite scary, there are ways to deal with their nasty nature.
When … then …
We can setup a when ... then ...
before passing control:
Overloading
We could also overload completed
method:
This way gliding controller will release control as soon as our landing controller wants to start the final burn.