Defines an interface in Julia for interacting with simulated and physical processes.
-
AbstractProcess
Base abstract type for all lab processes. This should not be inherited from directly. -
PhysicalProcess <: AbstractProcess
Pysical processes should inherit from this abstract type. -
SimulatedProcess <: AbstractProcess
Simulated processes should inherit from this abstract type.
-
ny = num_outputs(P::AbstractProcess)
Return the number of outputs (measurement signals) of the process. -
nu = num_inputs(P::AbstractProcess)
Return the number of inputs (control signals) of the process. -
yrange = outputrange(P::AbstractProcess)
Return the range of outputs (measurement signals) of the process.yrange
is a vector of tuples,length(yrange) = num_outputs(P), eltype(yrange) = Tuple(Real, Real)
-
urange = inputrange(P::AbstractProcess)
Return the range of inputs (control signals) of the process.urange
is a vector of tuples,length(urange) = num_inputs(P), eltype(urange) = Tuple(Real, Real)
-
isstable(P::AbstractProcess)
Return true/false indicating whether or not the process is stable -
isasstable(P::AbstractProcess)
Return true/false indicating whether or not the process is asymptotically stable -
h = sampletime(P::AbstractProcess)
Return the sample time of the process in seconds. -
b = bias(P::AbstractProcess)
Return an input bias for the process. This could be, i.e., the constant input u₀ around which a nonlinear system is linearized, or whatever other bias might exist on the input.
length(b) = num_inputs(P)
-
control(P::AbstractProcess, u::AbstractVector)
Send a control signal to the process whereu
is anAbstractVector
with dimension equal tonum_inputs(P)
.
There is a default method which acceptsu
as aNumber
and forwards it as aVector
to the implemented version. -
y = measure(P::AbstractProcess)
Return a measurement from the process wherey
has lengthnum_outputs(P)
-
last_time = periodic_wait(P::AbstractProcess, last_time, dt)
Should continue execution at start of next period, i.e. whendt
seconds has passed sincelast_time
.
For aPhysicalProcess
this is has a default implementation which sleeps fromtime()
untillast_time + dt
usingLibc.systemsleep
. Though this is more precise than using the standardsleep
in Julia, it also blocks the entire Julia thread it is running on so one has to be careful with that sleep.
For aSimulatedProcess
it can either be running in realtime, in which case it should be implemented similarly to the physical process, or it runs at full simulation speed, in which case the environment should simulate a step corresponding todt
time whenperiodic_wait
is called. -
initialize(P::AbstractProcess)
This function is called before any control or measurement operations are performed. During a call toinitialize
, one might set up external communications etc. After control is done, the functionfinalize
is called. -
finalize(P::AbstractProcess)
This function is called after any control or measurement operations are performed. During a call tofinalize
, one might finalize external communications etc. Before control is done, the functioninitialize
is called.
The repo https://github.com/ControlLTH/FurutaPendulums.jl implements this interface in for both a connection to the physical proces as well as a simulated version of the physical process.