Rotational Sensor#

Hardware Interface#

Defined in namespace hal

#include <libhal/rotation_sensor.hpp>

class rotation_sensor#

Rotation measuring hardware abstraction interface.

Examples of rotary encoder are:

  • Rotary Potentiometers

  • Quadrature Encoders

  • Incremental Encoders

  • Absolute Encoders

  • Rotary Magnetic Encoders

  • Inertial Measurement Unit or IMU

Rotation sensors can be relative or absolute. Relative position means that the sensor can only see changes in rotation from where measurement started. In other words, at application start, relative encoders will start at 0. Absolute encoders know their position at all times. At application start, the absolute encoder will be able to determine its exact orientation relative to a frame of reference when read.

Examples of relative rotation sensors are:

  • Quadrature Encoders

  • Incremental Encoders

Examples of absolute rotation sensors are:

  • Rotary Potentiometers

  • Absolute Encoders

  • Rotary Magnetic Encoders

  • IMUs

Rotation sensors can also be finite or infinite. Finite meaning that the angle that can be reported is a fixed amount for the device. Infinite means that the encoder can continue rotating and adding more to its angle reading forever. Infinite rotation sensors tend to not have a physical stop that limits how much they can be rotated.

Examples of finite rotation sensors are:

  • Rotary Potentiometers

  • Absolute Encoders

  • IMUs

Examples of infinite rotation sensors are:

  • Rotary Magnetic Encoders

  • Quadrature Encoders

  • Incremental Encoders

This interface does not provide a means to determine these attributes of a rotation sensor as this is an application architecture decision. Drivers that implement this interface should document what kind of rotary sensor it is such that a developer can determine its applicability to their application. The context of which sensor ought to be used for an application is solely known at architecture definition time and software should not be expected to at runtime, if the right type of rotation sensor was passed into the object.

Subclassed by hal::soft::inert_rotation_sensor

Public Functions

inline read_t read()#

Read the current angle measured by the device.

Returns:

read_t - rotation data

struct read_t#

Result from reading the rotation sensor.

Public Members

degrees angle#

Rotation angle measurement.