Skip to content

Class hal::motor

ClassList > hal > motor

Hardware abstraction for an open loop rotational actuator. More...

  • #include <motor.hpp>

Inherited by the following classes: hal::mock::motor, hal::rmd::drc_motor, hal::rmd::mc_x_motor, hal::soft::inert_motor

Classes

Type Name
struct power_t
Feedback from setting the motor power.

Public Functions

Type Name
result< power_t > power (float p_power)
Apply power to the motor.
virtual ~motor () = default

Detailed Description

The motor interface can represent a variety of things such as:

  • A driver for motor controller IC like the DRV8801
  • A driver for a motor with integrated controller & serial interface
  • A unidirectional motor controlled by a single transistor
  • A servo with open loop motor control

Public Functions Documentation

function power

Apply power to the motor.

inline result< power_t > hal::motor::power (
    float p_power
) 

Power is a percentage and thus cannot be used as a way to gauge how fast the motor is moving. In general applying more power means to increase speed and/or torque to the motor.

  • 0% power would mean that no power is being applied to the motor. In this situation an unloaded motor will not move. 0% power does not guarantee that the motor will hold its position. These specifics depend greatly on the type of motor used and careful selection of motor and motor driver are important for applications using this interface.
  • 100% power means that the maximum available of power is being applied to the motor. As an example, if the max voltage of a DC brushed motor's power supply is 12V, then 12V would be supplied to this motor.
  • 50% power would mean that half of the available power is being applied to the motor. Using the same example, in this case 6V would be applied to the motor either as a DC constant voltage or via PWM at 50% duty cycle.
  • Negative values will cause the motor to move in the opposite direction as positive values. In the event that motor driver can * only go in one direction, this function should clamp the power applied to 0%.

Parameters:

  • p_power - Percentage of power to apply to the motor from -1.0f to +1.0f, -100% to 100%, respectively.

Returns:

result<power_t> - success or failure

function ~motor

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

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