19 #include "tgSCASineControl.h"
30 const double amplitude,
31 const double frequency,
34 const double length) :
37 m_controlStep(controlStep),
38 m_commandedTension(0.0),
39 cpgAmplitude(amplitude),
40 cpgFrequency(frequency),
45 m_controlLength(length),
46 m_tempConfig(pidConfig),
47 m_PIDController(NULL),
48 m_pMotorControl(p_ipc)
50 if (m_controlStep < 0.0)
52 throw std::invalid_argument(
"Negative control step");
60 tgSCASineControl::~tgSCASineControl()
62 delete m_PIDController;
77 if (m_controlTime >= m_controlStep)
80 cycle = cos(m_totalTime * 2.0 * M_PI * cpgFrequency + phaseOffset);
81 target = cycle*cpgAmplitude + offsetSpeed;
84 m_commandedTension = m_pMotorControl->
control(*m_PIDController, dt, m_controlLength, target);
90 const double currentTension = subject.
getTension();
91 m_PIDController->
control(dt, m_commandedTension, currentTension);
96 void tgSCASineControl::updateTensionSetpoint(
double newTension)
98 if (newTension >= 0.0)
104 throw std::runtime_error(
"Tension setpoint is less than zero!");
108 void tgSCASineControl::updateControlLength(
double newControlLength)
110 if (newControlLength >= 0.0)
112 m_controlLength = newControlLength;
116 throw std::runtime_error(
"Length setpoint is less than zero!");
Contains the definition of class ImpedanceControl. $Id$.
virtual const double getTension() const
tgSCASineControl(const double controlStep, tgImpedanceController *p_ipc, tgPIDController::Config pidConfig, const double amplitude, const double frequency, const double phase, const double offset, const double length)
virtual void control(double dt)
const tgControllable *const getControllable() const
virtual void onStep(tgSpringCableActuator &subject, double dt)
virtual void onAttach(tgSpringCableActuator &subject)
double control(tgBasicController &mLocalController, double deltaTimeSeconds, double newPosition, double offsetVel=0)
Control Functions.
void setOffsetTension(double offsetTension)