Ravens Robotics FRC 2015
Public Member Functions | Private Attributes | List of all members
SmoothAxis Class Reference

#include <SmoothAxis.h>

Public Member Functions

 SmoothAxis ()
 
virtual ~SmoothAxis ()
 
void SetTarget (float newTarget)
 
float GetValue ()
 
bool isEnabled ()
 
void setEnabled (bool enabled)
 

Private Attributes

bool m_enabled
 =true if smoothing enabled More...
 
float m_target
 
float m_prevTarget
 current & previous target settings for smoothing algo More...
 
const float kAccelVal = 0.01
 Acceleration increment: approach target by 1%. More...
 

Detailed Description

Helper class for motor control, such as MecanumDrive.

This object is used to transform raw speed settings read from controls such as Joystick axes, to provide "smoothed" values for writing to motors.

Definition at line 19 of file SmoothAxis.h.

Constructor & Destructor Documentation

SmoothAxis::SmoothAxis ( )

Constructor

Definition at line 16 of file SmoothAxis.cpp.

References setEnabled().

SmoothAxis::~SmoothAxis ( )
virtual

Destructor

Definition at line 23 of file SmoothAxis.cpp.

Member Function Documentation

float SmoothAxis::GetValue ( )

Get target axis value to apply to motor. When enabled, this will be a value that has been smoothed to limit the change in speed (acceleration) and improve wheel traction.

Returns
Current target axis value.

Get target axis value to apply to motor.

The smoothing algorithm limits acceleration to a fixed maximum per iteration. The maximum increment is defined as kAccelVal. The standard iteration period is nominally 20ms, however that value is neither measured nor enforced in this simple algorithm.

Definition at line 47 of file SmoothAxis.cpp.

References isEnabled(), kAccelVal, m_prevTarget, and m_target.

Referenced by MecanumDrive::DoWork().

bool SmoothAxis::isEnabled ( )

Get state of axis value smoothing capability.

Returns
Current state, true if enabled.

Get state of axis value smoothing capability.

Definition at line 60 of file SmoothAxis.cpp.

References m_enabled.

Referenced by GetValue().

void SmoothAxis::setEnabled ( bool  enabled)

Set state of axis value smoothing capability.

Parameters
enabledNew state, true to enable.

Set state of axis value smoothing capability.

Definition at line 67 of file SmoothAxis.cpp.

References m_enabled, m_prevTarget, and m_target.

Referenced by MecanumDrive::SetSmoothAccel(), and SmoothAxis().

void SmoothAxis::SetTarget ( float  newTarget)

Feed a new target axis value

Parameters
newTargetTarget value [-1..+1], typically read from Joystick axis.

Feed a new target axis value

Definition at line 30 of file SmoothAxis.cpp.

References m_prevTarget, and m_target.

Referenced by MecanumDrive::Sense().

Member Data Documentation

const float SmoothAxis::kAccelVal = 0.01
private

Acceleration increment: approach target by 1%.

Definition at line 64 of file SmoothAxis.h.

Referenced by GetValue().

bool SmoothAxis::m_enabled
private

=true if smoothing enabled

Definition at line 62 of file SmoothAxis.h.

Referenced by isEnabled(), and setEnabled().

float SmoothAxis::m_prevTarget
private

current & previous target settings for smoothing algo

Definition at line 63 of file SmoothAxis.h.

Referenced by GetValue(), setEnabled(), and SetTarget().

float SmoothAxis::m_target
private

Definition at line 63 of file SmoothAxis.h.

Referenced by GetValue(), setEnabled(), and SetTarget().


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