Sensors#

Common Interface#

All sensors in PyMagba share a common interface for geometric properties.

property position: ArrayLike3

Position of the object [x, y, z] in meters.

property orientation: scipy.spatial.transform.Rotation

Orientation as a scipy.spatial.transform.Rotation object.

translate(translation)

Translate the object by a displacement vector.

Parameters:

translation (ArrayLike3) – Displacement [dx, dy, dz] in meters.

rotate(rot)

Rotate the object about its own origin.

Parameters:

rot (Rotation | ArrayLike4) – Rotation to apply. Can be a scipy.spatial.transform.Rotation object or a unit quaternion as a list.

rotate_anchor(rot, anchor)

Rotate the object about an arbitrary anchor point.

Parameters:
  • rot (Rotation | ArrayLike4) – Rotation to apply.

  • anchor (ArrayLike3) – Anchor point [x, y, z] in meters about which to rotate.

Available Sensors#

LinearHallSensor#

class pymagba.sensors.LinearHallSensor(position=None, orientation=None, sensitive_axis=None, sensitivity=1.0, supply_voltage=5.0)[source]#

A physical representation of a linear Hall effect sensor.

Outputs an analog voltage proportional to the magnetic field component along its sensitive axis. The output is centered at supply_voltage / 2 (quiescent voltage) and clamped to the range [0, supply_voltage].

Parameters:
  • position (ArrayLike3, optional) – Sensor position [x, y, z] in meters. Defaults to [0.0, 0.0, 0.0].

  • orientation (PyRotation, optional) – Orientation as a unit quaternion [x, y, z, w] or a scipy.spatial.transform.Rotation object. Defaults to identity.

  • sensitive_axis (ArrayLike3, optional) – The local axis along which the field is measured [ax, ay, az]. Normalized internally. Defaults to [0.0, 0.0, 1.0].

  • sensitivity (float, optional) – Sensor sensitivity in V/T. Defaults to 1.0.

  • supply_voltage (float, optional) – Supply voltage in volts. Sets the output range to [0, supply_voltage] with quiescent point at supply_voltage / 2. Defaults to 5.0.

Examples

from pymagba.sensors import LinearHallSensor
from pymagba.magnets import CylinderMagnet

magnet = CylinderMagnet(
    position=[0.0, 0.0, 0.01],
    diameter=0.01,
    height=0.005,
    polarization=[0.0, 0.0, 1.0],
)
sensor = LinearHallSensor(
    position=[0.0, 0.0, 0.025],
    sensitive_axis=[0.0, 0.0, 1.0],
    sensitivity=0.05,
    supply_voltage=5.0,
)
voltage = sensor.read_voltage(magnet)

HallSwitch#

class pymagba.sensors.HallSwitch(position=None, orientation=None, sensitive_axis=None, b_op=0.01)[source]#

A physical representation of a unipolar Hall effect switch sensor.

Outputs a digital True/False reading based solely on whether the projected magnetic field component along the sensitive axis exceeds the operate point b_op. This sensor is stateless — it does not model hysteresis.

Parameters:
  • position (ArrayLike3, optional) – Sensor position [x, y, z] in meters. Defaults to [0.0, 0.0, 0.0].

  • orientation (PyRotation, optional) – Orientation as a unit quaternion [x, y, z, w] or a scipy.spatial.transform.Rotation object. Defaults to identity.

  • sensitive_axis (ArrayLike3, optional) – The local axis along which the field is measured [ax, ay, az]. Normalized internally. Defaults to [0.0, 0.0, 1.0].

  • b_op (float, optional) – Magnetic operate point in Tesla. The switch turns ON when the projected field exceeds this threshold. Defaults to 0.010 (10 mT).

Examples

from pymagba.sensors import HallSwitch
from pymagba.magnets import CylinderMagnet

magnet = CylinderMagnet(
    position=[0.0, 0.0, 0.01],
    diameter=0.01,
    height=0.005,
    polarization=[0.0, 0.0, 1.0],
)
sensor = HallSwitch(
    position=[0.0, 0.0, 0.025],
    sensitive_axis=[0.0, 0.0, 1.0],
    b_op=0.010,
)
state = sensor.read_state(magnet)  # True if ON

HallLatch#

class pymagba.sensors.HallLatch(position=None, orientation=None, sensitive_axis=None, b_op=0.01, b_rp=Ellipsis)[source]#

A physical representation of a Hall effect latch sensor.

Outputs a digital True/False reading based on the magnetic operate point (b_op) and release point (b_rp) thresholds. Provides hysteresis by maintaining internal state:

  • When projected field ≥ b_op: state becomes True (Active).

  • When projected field ≤ b_rp: state becomes False (Inactive).

  • When field is between b_rp and b_op: state is preserved.

Parameters:
  • position (ArrayLike3, optional) – Sensor position [x, y, z] in meters. Defaults to [0.0, 0.0, 0.0].

  • orientation (PyRotation, optional) – Orientation as a unit quaternion [x, y, z, w] or a scipy.spatial.transform.Rotation object. Defaults to identity.

  • sensitive_axis (ArrayLike3, optional) – The local axis along which the field is measured [ax, ay, az]. Normalized internally. Defaults to [0.0, 0.0, 1.0].

  • b_op (float, optional) – Magnetic operate point in Tesla. Field must exceed this to switch ON. Defaults to 0.010 (10 mT).

  • b_rp (float, optional) – Magnetic release point in Tesla. Field must fall below this to switch OFF. Defaults to -0.010 (-10 mT).

Examples

from pymagba.sensors import HallLatch
from pymagba.magnets import CylinderMagnet

magnet = CylinderMagnet(
    position=[0.0, 0.0, 0.01],
    diameter=0.01,
    height=0.005,
    polarization=[0.0, 0.0, 1.0],
)
sensor = HallLatch(
    position=[0.0, 0.0, 0.025],
    sensitive_axis=[0.0, 0.0, 1.0],
    b_op=0.010,
    b_rp=-0.010,
)
state = sensor.read_state(magnet)  # True if latched ON