61 template <
typename SCALAR>
88 w_n_square_(w_n_ * w_n_),
98 w_n_square_(arg.w_n_square_),
114 w_n_(std::sqrt(k / m)),
115 w_n_square_(w_n_ * w_n_),
116 zeta_(d / (2.0 * m * k)),
134 w_n_square_ = w_n_ * w_n_;
151 derivative(0) = state(1);
152 derivative(1) = g_dc_ * control(0) - 2.0 * zeta_ * w_n_ * state(1) - w_n_square_ * state(0);
163 std::cout <<
"Warning: Damping is negative!" << std::endl;
168 std::cout <<
"Warning: Frequency w_n is negative!" << std::endl;
173 std::cout <<
"Warning: Steady state gain is negative!" << std::endl;
178 std::cout <<
"Warning: Steady state gain is zero!" << std::endl;
188 std::cout <<
"Frequency: " << w_n_ << std::endl;
189 std::cout <<
"Zeta: " << zeta_ << std::endl;
190 std::cout <<
"DC gain: " << g_dc_ << std::endl;
192 std::cout <<
"System is ";
195 std::cout <<
"undamped" << std::endl;
199 std::cout <<
"critically damped" << std::endl;
203 std::cout <<
"overdamped" << std::endl;
207 std::cout <<
"underdamped" << std::endl;
void setDynamics(SCALAR w_n, SCALAR zeta=SCALAR(1.0), SCALAR g_dc=SCALAR(1.0))
set the dynamics
Definition: SecondOrderSystem.h:131
Base::time_t time_t
Definition: ControlledSystem.h:53
SecondOrderSystem * clone() const override
deep copy
Definition: SecondOrderSystem.h:122
SecondOrderSystem(const SecondOrderSystem &arg)
copy constructor
Definition: SecondOrderSystem.h:95
Describes a damped oscillator.
Definition: SecondOrderSystem.h:62
bool checkParameters()
check the parameters
Definition: SecondOrderSystem.h:159
virtual void computeControlledDynamics(const StateVector< 2, SCALAR > &state, const time_t &t, const ControlVector< 1, SCALAR > &control, StateVector< 2, SCALAR > &derivative) override
evaluate the system dynamics
Definition: SecondOrderSystem.h:146
virtual ~SecondOrderSystem()
destructor
Definition: SecondOrderSystem.h:124
a pure second-order system
Definition: System.h:18
Definition: ControlVector.h:12
CppAD::AD< CppAD::cg::CG< double > > SCALAR
void printSystemInfo()
print out infos about the system
Definition: SecondOrderSystem.h:186
Base::time_t time_t
Definition: SecondOrderSystem.h:69
SecondOrderSystem()=delete
default constructor
SecondOrderSystem(SCALAR k, SCALAR m, SCALAR d, SCALAR g_dc, std::shared_ptr< Controller< 2, 1 >> controller=nullptr)
constructor using a more mechanical definition (spring-mass-damping)
Definition: SecondOrderSystem.h:112
static const size_t CONTROL_DIM
control dimension (force)
Definition: SecondOrderSystem.h:66
SecondOrderSystem(SCALAR w_n, SCALAR zeta=SCALAR(1.0), SCALAR g_dc=SCALAR(1.0), std::shared_ptr< Controller< 2, 1, SCALAR >> controller=nullptr)
constructor directly using frequency and damping coefficients
Definition: SecondOrderSystem.h:82
static const size_t STATE_DIM
state dimension (position, velocity)
Definition: SecondOrderSystem.h:65
SYSTEM_TYPE
type of system
Definition: System.h:15
ControlledSystem< 2, 1, SCALAR > Base
Definition: SecondOrderSystem.h:68
A general, non-linear dynamic system with a control input.
Definition: ControlledSystem.h:46
Interface class for all controllers.
Definition: Controller.h:26