Class PID#

Inheritance Relationships#

Base Type#

Class Documentation#

class PID : public Karana::Models::KModel<PID, PIDParams>#

Simple PID controller model.

Public Functions

PID(std::string_view name, const kc::ks_ptr<kd::StatePropagator> &sp, const kc::ks_ptr<kd::PhysicalSubhinge> &sh, std::function<km::Vec(const km::Ktime&)> q_traj, std::function<km::Vec(const km::Ktime&)> u_traj)#

PID constructor. The constructor is not meant to be called directly. Please use the create(…) method instead to create an instance.

The PID model adds force to a subhinge. The model uses the incoming function as the desired trajectory. The output of this function should be the desired Q values of the subhinge.

Parameters:
  • name – The name of the model.

  • sp – The StatePropagator to register this model with.

  • sh – The Subhinge to apply the forces calculated by the PID controller to.

  • q_traj – A function that defines the reference trajectory for Q.

  • u_traj – A function that defines the reference trajectory for U.

~PID()#

Destructor for PID.

void preDeriv(const km::Ktime &t, const km::Vec &x)#

Calculate and apply the output of the PID model to the subhinge.

Parameters:
  • t – Current time.

  • x – Current state. Not used.

void preModelStep(const km::Ktime &t, const km::Vec &x)#

Calculate the contribution of integral control.

Parameters:
  • t – Current time.

  • x – Current state. Not used.

Public Static Functions

static kc::ks_ptr<PID> create(std::string_view name, const kc::ks_ptr<kd::StatePropagator> &sp, const kc::ks_ptr<kd::PhysicalSubhinge> &sh, std::function<km::Vec(const km::Ktime&)> q_traj, std::function<km::Vec(const km::Ktime&)> u_traj)#

Constructor. The PID model adds force to a subhinge. The model uses the incoming function as the desired trajectory. The output of this function should be the desired Q values of the subhinge.

Parameters:
  • name – The name of the model.

  • sp – The StatePropagator to register this model with.

  • sh – The Subhinge to apply the forces calculated by the PID controller to.

  • q_traj – A function that defines the reference trajectory for Q.

  • u_traj – A function that defines the reference trajectory for U.

Returns:

A ks_ptr to the newly created instance of the PID model.