Ravens Robotics FRC 2015
|
#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... | |
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.
SmoothAxis::SmoothAxis | ( | ) |
|
virtual |
Destructor
Definition at line 23 of file SmoothAxis.cpp.
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.
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.
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.
enabled | New 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
newTarget | Target 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().
|
private |
Acceleration increment: approach target by 1%.
Definition at line 64 of file SmoothAxis.h.
Referenced by GetValue().
|
private |
=true if smoothing enabled
Definition at line 62 of file SmoothAxis.h.
Referenced by isEnabled(), and setEnabled().
|
private |
current & previous target settings for smoothing algo
Definition at line 63 of file SmoothAxis.h.
Referenced by GetValue(), setEnabled(), and SetTarget().
|
private |
Definition at line 63 of file SmoothAxis.h.
Referenced by GetValue(), setEnabled(), and SetTarget().