Signals

class staliro.signals.Signal

Representation of a time-varying input to a system.

abstractmethod at_time(time)

Get the value of the signal at the specified time.

Parameters:

time (float)

Return type:

float

at_times(times)

Get the value of the signal at each specified time.

Parameters:

times (Iterable[float])

Return type:

list[float]

class staliro.signals.SignalFactory(*args, **kwargs)

Factory interface for creating signals from a set of times and control points.

__call__(times, control_points, /)

Create a Signal from a set of times and control points.

The number of times and control points can be assumed to be equal.

Parameters:
  • times (Iterable[float]) – The time value for each control point

  • control_points (Iterable[float]) – The values of the signal at the given times

Returns:

A signal

Return type:

Signal

Implementations

staliro.signals.pchip(times, control_points)

Create a signal using PChip interpolation.

Pchip is a smooth 3rd-order cubic spline interpolation.

Parameters:
  • times (Iterable[float]) – The time value for each control point

  • control_points (Iterable[float]) – The values of the signal at the given times

Returns:

A signal interpolated using PChip

Return type:

Pchip

staliro.signals.piecewise_linear(times, control_points)

Create a signal that is interpolated linearly between control points.

The values of the signal between control points are interpolated by using the control point before and after the time to create a linear equation that is evaluated at the current time.

Parameters:
  • times (Iterable[float]) – The time values for each control point

  • control_points (Iterable[float]) – The values of the signal at the given times

Returns:

A piecewise linear interpolated signal

Return type:

Piecewise

staliro.signals.piecewise_constant(times, values)

Create a signal that is constant between control points.

The values of the signal between control points are constant until the next control point.

Parameters:
  • times (Iterable[float]) – The time values for each control point

  • control_points – The values of the signal at the given times

  • values (Iterable[float])

Returns:

A piecewise constant interpolated signal

Return type:

Piecewise

staliro.signals.harmonic(_, control_points)

Create a signal that is the sum of multiple sinusoidal components.

The bias value for this signal is the first control point and any harmonic components must be defined after the bias in groups of 3 with the order being the amplitude, frequency, and phase.

Parameters:
  • times – Ignored

  • control_points (Iterable[float]) – The bias term, and the parameters for each harmonic component

  • _ (Iterable[float])

Returns:

A signal composed of harmonic components

Return type:

Harmonic

Combinators

staliro.signals.delayed(inner, *, delay)

Delay the control points inner signal by the given amount.

Parameters:
  • inner (SignalFactory) – Factory for the signal to delay

  • delay (float) – The amount of time to delay

Returns:

A SignalFactory for the delayed signal

Return type:

SignalFactory

staliro.signals.clamped(inner, *, lo=None, hi=None)

Create a signal that will not exceed the given range.

Parameters:
  • inner (SignalFactory) – Factory for the signal to clamp

  • lo (float | None) – The optional lower bound of the signal

  • hi (float | None) – The optional upper bound of the signal

Returns:

A SignalFactory for the clamped signal

Return type:

SignalFactory

staliro.signals.sequenced(first, second, *, t_switch)

Create a signal that will switch behavior at a given time.

Parameters:
  • first (SignalFactory) – Factory for the signal to use before the switch time

  • second (SignalFactory) – Factory for the signal to use after the switch time

  • t_switch (float) – The time to switch from first to second

Returns:

A SignalFactory for the sequenced signal

Return type:

SignalFactory