trikRuntime
trikControl::MotorInterface Class Referenceabstract

Abstract motor. It is differently implemented by different motor types (like servo and power motors). More...

#include <motorInterface.h>

Inheritance diagram for trikControl::MotorInterface:
Collaboration diagram for trikControl::MotorInterface:

Public Types

enum  Type { Type::powerMotor, Type::servoMotor }
 
- Public Types inherited from trikControl::DeviceInterface
enum  Status {
  Status::permanentFailure, Status::temporaryFailure, Status::off, Status::starting,
  Status::ready, Status::stopping
}
 Device status. More...
 

Public Slots

virtual void setPower (int power, bool constrain=true)=0
 Sets current motor power to specified value, 0 to stop motor. More...
 
virtual int power () const =0
 Returns currently set power of a motor. More...
 
virtual void powerOff ()=0
 Turns off motor. More...
 
virtual void brake (int durationMs=500)=0
 Force brake state for durationMs and then powerOff() More...
 
virtual void setPeriod (int uSec=20000)=0
 Set period for PWM generator. More...
 

Public Member Functions

virtual int minControl () const =0
 Returns minimal value of control accepted by a motor (-90..90, 0..100, for example). More...
 
virtual int maxControl () const =0
 Returns maximal value of control accepted by a motor (-90..90, 0..100, for example). More...
 
- Public Member Functions inherited from trikControl::DeviceInterface
 DeviceInterface ()=default
 
virtual ~DeviceInterface ()=default
 
virtual Status status () const =0
 Returns current status of the device. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from trikControl::DeviceInterface
static Status combine (const DeviceInterface &underlying, const DeviceInterface::Status &dependent)
 Helper method to return status of a device relying on other device to work. More...
 

Detailed Description

Abstract motor. It is differently implemented by different motor types (like servo and power motors).

Member Enumeration Documentation

Enumerator
powerMotor 
servoMotor 

Member Function Documentation

virtual void trikControl::MotorInterface::brake ( int  durationMs = 500)
pure virtualslot

Force brake state for durationMs and then powerOff()

virtual int trikControl::MotorInterface::maxControl ( ) const
pure virtual

Returns maximal value of control accepted by a motor (-90..90, 0..100, for example).

Implemented in trikControl::ServoMotor, and trikControl::PowerMotor.

virtual int trikControl::MotorInterface::minControl ( ) const
pure virtual

Returns minimal value of control accepted by a motor (-90..90, 0..100, for example).

Implemented in trikControl::ServoMotor, and trikControl::PowerMotor.

virtual int trikControl::MotorInterface::power ( ) const
pure virtualslot

Returns currently set power of a motor.

virtual void trikControl::MotorInterface::powerOff ( )
pure virtualslot

Turns off motor.

This is not the same as setPower(0), because setPower can leave motor on in a break mode, and this method will turn motor off.

virtual void trikControl::MotorInterface::setPeriod ( int  uSec = 20000)
pure virtualslot

Set period for PWM generator.

Parameters
uSec- microseconds
virtual void trikControl::MotorInterface::setPower ( int  power,
bool  constrain = true 
)
pure virtualslot

Sets current motor power to specified value, 0 to stop motor.

Parameters
power- power of a motor, from -100 (full reverse) to 100 (full forward), 0 — break.
constrain- if true, power will be constrained in an interval [-100, 100], if false, "power" value will be sent to a motor unaltered.

The documentation for this class was generated from the following file: