Main Page | Modules | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

PositionControl Class Reference
[Miscellaneous Library Utilities]

#include <PositionControl.hh>

Inherits MotorControl.

List of all members.


Detailed Description

Module to implement basic PD control of DC motors.

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)


Member Enumeration Documentation

enum PositionControl::CompensationType
 

This enum type defines possible types of command compensation if the underlying hardware operates in voltage mode.


Constructor & Destructor Documentation

PositionControl::PositionControl int  index  ) 
 

This constructor selects the index of the module, establishing correspondances with the appropriate EncoderReader and the axis number of the underlying hardware


Member Function Documentation

void PositionControl::freeze void   ) 
 

This method sets the motor target to the current motor pos.

CompensationType PositionControl::getCompensationType void   )  [inline]
 

This method returns the current type for the command compensation

float PositionControl::getErrorOffset void   )  [inline]
 

This method returns the current error offset setting

float PositionControl::getPositionErr void   )  [inline]
 

This method returns the current error in shaft position

float PositionControl::getSpeedErr void   )  [inline]
 

This method returns the current error in shaft speed

float PositionControl::getTorqueOffset void   )  [inline]
 

This method returns the current feedforward torque command

void PositionControl::setCompensationType CompensationType  type  )  [inline]
 

This method can be used to choose the type of command compensation term in the feedback loop.

void PositionControl::setErrorOffset float  offset  )  [inline]
 

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.

void PositionControl::setTorqueOffset float  torque  )  [inline]
 

This method sets the value of the feedforward torque command for PD computations


RHexLib Reference Documentation