Skip to content

Class hal::servo

ClassList > hal > servo

Hardware abstraction for a closed loop position controlled rotational actuator.

  • #include <servo.hpp>

Inherited by the following classes: hal::mock::servo, hal::rmd::drc_servo, hal::rmd::mc_x_servo, hal::soft::rc_servo

Classes

Type Name
struct position_t
Feedback from setting the servo position.
struct range_error
Error information indicating the range of the servo.

Public Functions

Type Name
result< position_t > position (hal::degrees p_position)
Set the position of the servo's output shaft.
virtual ~servo () = default

Public Functions Documentation

function position

Set the position of the servo's output shaft.

inline result< position_t > hal::servo::position (
    hal::degrees p_position
) 

Position is the rotational position as a angle in degrees that the caller wants the shaft to rotate to. The allowed range of positions is defined by the servo itself. Many servos have intrinsic limits to their range.

Developers must choose servos that fit the range for their applications. Applications must clearly define the range that they require in order to perform correctly.

The velocity in which the servo shaft moves is not defined by this function but is either intrinsic to the servo or a configuration of the servo.

Parameters:

  • p_position - the position to move the servo shaft in degrees.

Returns:

result<position_t> - success or failure

Exception:

  • std::errc::invalid_argument - when position exceeds the range of the servo. When this error occurs, the guaranteed behavior is that the servo keeps its last set position.
  • hal::servo::range_error - when position exceeds the range of the servo. Provides details about the min and max range of the servo. When this error occurs, the guaranteed behavior is that the servo keeps its last set position.

function ~servo

virtual hal::servo::~servo () = default

The documentation for this class was generated from the following file libraries/include/libhal/servo.hpp