Skip to content

openstb.simulator.system.ping_times

Ping time calculator plugins for the openSTB simulator.

Classes:

Name Description
ConstantDistance

Pings at a constant distance.

ConstantInterval

Pings at a constant interval.

ConstantDistance

ConstantDistance(distance, start_offset, end_offset, sampling_factor=10)

Bases: PingTimes

Pings at a constant distance.

The mean speed of the trajectory is used to find the mean interval between pings. The position of the system is sampled at a rate greater than this and the cumulative distance between these positions is calculated to give an estimated mapping between the elapsed time and distance travelled. The ping times are then found by interpolating the mapping at the desired positions using a Piecewise Cubic Hermite Interpolating Polynomial (PCHIP) interpolator.

Parameters:

Name Type Description Default
distance float

The distance between pings in metres.

required
start_offset float

The distance (in metres) between the start of the trajectory and the position of the first ping.

required
end_offset float

The minimum distance (in metres) between the position of the final ping and the end of the trajectory.

required
sampling_factor int

Sample the system position this many times in each mean interval. For example, a mean speed of 2m/s and a distance of 0.5m corresponds to a mean interval of 0.25s. A sampling factor of 10 means the trajectory will be sampled every 0.025s.

10
Source code in openstb/simulator/system/ping_times.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
def __init__(
    self,
    distance: float,
    start_offset: float,
    end_offset: float,
    sampling_factor: int = 10,
):
    """
    Parameters
    ----------
    distance : float
        The distance between pings in metres.
    start_offset : float
        The distance (in metres) between the start of the trajectory and the
        position of the first ping.
    end_offset : float
        The minimum distance (in metres) between the position of the final ping and
        the end of the trajectory.
    sampling_factor : int
        Sample the system position this many times in each mean interval. For
        example, a mean speed of 2m/s and a distance of 0.5m corresponds to a mean
        interval of 0.25s. A sampling factor of 10 means the trajectory will be
        sampled every 0.025s.

    """
    if not distance > 0:
        raise ValueError(_("ping-to-ping distance must be greater than zero"))
    if start_offset < 0:
        raise ValueError(_("start offset cannot be less than zero"))
    if end_offset < 0:
        raise ValueError(_("end offset cannot be less than zero"))
    if sampling_factor < 1:
        raise ValueError(_("sampling factor cannot be less than one"))

    self.distance = distance
    self.start_offset = start_offset
    self.end_offset = end_offset
    self.sampling_factor = sampling_factor

ConstantInterval

ConstantInterval(interval, start_delay, end_delay)

Bases: PingTimes

Pings at a constant interval.

Parameters:

Name Type Description Default
interval float

The ping interval in seconds.

required
start_delay float

Delay (in seconds) between the start of the trajectory and the first ping.

required
end_delay float

Delay (in seconds) between the last ping and the end of the trajectory.

required
Source code in openstb/simulator/system/ping_times.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def __init__(self, interval: float, start_delay: float, end_delay: float):
    """
    Parameters
    ----------
    interval : float
        The ping interval in seconds.
    start_delay : float
        Delay (in seconds) between the start of the trajectory and the first ping.
    end_delay : float
        Delay (in seconds) between the last ping and the end of the trajectory.

    """
    if not interval > 0:
        raise ValueError(_("ping interval must be greater than zero"))
    if start_delay < 0:
        raise ValueError(_("delay of first ping cannot be less than zero"))
    if end_delay < 0:
        raise ValueError(_("delay of last ping cannot be less than zero"))

    self.interval = interval
    self.start_delay = start_delay
    self.end_delay = end_delay