#include <PositionControl.hh>
Inherits MotorControl.
The PositionControl module implements PD motion control for a single axis. It uses the EncoderReader module instance with the same index and outputs commands through the DCMotorHW hardware component's corresponding axis.
Depending on the configuration of the underlying DC motors, it performs computations for either voltage or torque mode operations. For the latter, the motor command is simply computed with a proportional derivative feedback term based on current shaft position and velocity measurements. In contrast, in the former case, the module can be configured to perform back-EMF compensation to obtain approximate torque control.
Public Types | |
enum | CompensationType { NONE, BACKEMF } |
Public Member Functions | |
PositionControl (int index) | |
void | init (void) |
void | uninit (void) |
void | activate (void) |
void | deactivate (void) |
void | update (void) |
float | getTorqueOffset (void) |
void | setTorqueOffset (float torque) |
void | setErrorOffset (float offset) |
float | getErrorOffset (void) |
void | setCompensationType (CompensationType type) |
CompensationType | getCompensationType (void) |
float | getSpeedErr (void) |
float | getPositionErr (void) |
void | freeze (void) |
|
This enum type defines possible types of command compensation if the underlying hardware operates in voltage mode. |
|
This constructor selects the index of the module, establishing correspondances with the appropriate EncoderReader and the axis number of the underlying hardware |
|
This method sets the motor target to the current motor pos. |
|
This method returns the current type for the command compensation |
|
This method returns the current error offset setting |
|
This method returns the current error in shaft position |
|
This method returns the current error in shaft speed |
|
This method returns the current feedforward torque command |
|
This method can be used to choose the type of command compensation term in the feedback loop. |
|
This metod sets the error offset for angular difference computations. The need for such an offset comes from the periodicity of angular values and the ambiguity of what "error" means for angle differences. This error offset determines the range of the position error in the PD calculations. The range of the error becomes: [-PI+offset,PI+offset] where offset is in [-PI, PI]. Using this feature, it is possible to set the preferred direction of travel for the motor. |
|
This method sets the value of the feedforward torque command for PD computations |