roboglia.base.Sensor

class Sensor(name='SENSOR', device=None, value_read=None, activate=None, inverse=False, offset=0.0, auto=True, **kwargs)[source]

Bases: object

A one-value sensor.

A sensor is associated with a device and has at least a connection to a register in that device that represents the value the sensor is representing. In addition a sensor can have an optional register used to activate or deactivate the device and can publish a value that can be either boolean if the bits parameter is used or float, in which case the sensor can also apply an inverse and and offset to the values read from the device registry.

Parameters
  • name (str) – The name of the sensor

  • device (BaseDevice or subclass) – The device associated with the sensor

  • value_read (str) – The name of the register in device used to retrieve the sensor’s value

  • activate (str or None) – The name of the register used to activate the device. If None is used no activation for the device can be done and the sensor is by default assumed to be activated.

  • inverse (bool) – Indicates if the value read from the register should be inverted before being presented to the user in the value(). The inverse operation is performed before the offset (see below). Default is False. It is ignored if bits property is used.

  • offset (float) – Indicates an offest to be adder to the value read from the register (after inverse if True). Default is 0.0. It is ignored if bits property is used.

  • auto (bool) – Indicates if the sensor should be automatically activated when the robot is started (:py:meth:roboglia.base.BaseRobot.`start` method). Default is True.

__init__(name='SENSOR', device=None, value_read=None, activate=None, inverse=False, offset=0.0, auto=True, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

property name

The name of the sensor.

property device

The devices associated with the sensor.

property read_register

The register used to access the sensor value.

property activate_register

(read-only) The register for activation sensor.

property active

(read-write) Accessor for activating the senser. If the activation registry was not specified (None) the method will return True (assumes the sensors are active by default if not controllable.

The setter will log a warning if you try to assign a value to this property if there is no register assigned to it.

Returns

Value of the activate register or True if no register was specified when the sensor was created.

Return type

bool

property auto_activate

Indicates if the joint should automatically be activated when the robot starts.

property inverse

(read-only) sensor uses inverse coordinates versus the device.

property offset

(read-only) The offset between sensor coords and device coords.

property value

Returns the value of the sensor.

Returns

The value of the register is adjusted with the offset and the inverse attributes.

Return type

bool or float