neclib.safety.decelerate#

Additionally restrict the maximum drive speed near drive range limits.

If you understand the junior-high physics, you know the algorithm:

\[\begin{split}v &= \int a \ dt = a \int dt = at \qquad (v_0 = 0) \\ x &= \int v \ dt = a \int t \ dt = \frac{a t^2}{2} \qquad (x_0 = 0) \\ v(x) &= a \sqrt{\frac{2x}{a}} = \sqrt{2ax}\end{split}\]

where \(x\) is the distance between encoder reading and drive limits.

Aliases#

ValueRange

Value range bound by 2 values.

get_quantity

Convert a value to astropy Quantity.

class Decelerate(limit, max_acceleration)[source]#

Bases: object

Decelerate the telescope drive as it nears the drive range limits.

Parameters:
  • limit (ValueRange[Quantity]) – The range of encoder values that are considered the drive range limits.

  • max_acceleration (Quantity) – The maximum (absolute) acceleration of the telescope drive.

Examples

>>> limit = neclib.core.ValueRange(5 << u.deg, 355 << u.deg)
>>> calculator = neclib.safety.Decelerate(limit, 1.0 << u.deg / u.s**2)
>>> calculator(354.6 << u.deg, 1 << u.deg / u.s)
<Quantity 0.89442719 deg / s>
>>> calculator(354.6 << u.deg, -1 << u.deg / u.s)
<Quantity -1. deg / s>