Class jalansim::controller::PID

template <typename T>

ClassList > jalansim > controller > PID

Proportional-Integral-Derivative ( PID ) controller.More...

  • #include <pid.hpp>

Public Functions

Type Name
JALANSIM_HOST_DEVICE PID (T kp, T ki, T kd, T min_value=T(-1e9), T max_value=T(1e9), T min_output=T(-1e9), T max_output=T(1e9))
Constructor for PID controller.
JALANSIM_HOST_DEVICE T compute (T setpoint, T measured_value, T dt)
Compute PID control output.
JALANSIM_HOST_DEVICE void reset ()
Reset the PID controller to initial state.

Detailed Description

Implements a standard PID controller with configurable gains and output limits. Provides proportional, integral, and derivative control actions to minimize the error between setpoint and measured values. Includes input/output clamping for stability and safety.

Template parameters:

  • T Numeric type (float, double)

Public Functions Documentation

function PID

Constructor for PID controller.

inline JALANSIM_HOST_DEVICE jalansim::controller::PID::PID (
    T kp,
    T ki,
    T kd,
    T min_value=T(-1e9),
    T max_value=T(1e9),
    T min_output=T(-1e9),
    T max_output=T(1e9)
) 

Parameters:

  • kp Proportional gain
  • ki Integral gain

  • kd Derivative gain

  • min_value Minimum allowed input value (default: -1e9)
  • max_value Maximum allowed input value (default: 1e9)
  • min_output Minimum allowed output value (default: -1e9)
  • max_output Maximum allowed output value (default: 1e9)

function compute

Compute PID control output.

inline JALANSIM_HOST_DEVICE T jalansim::controller::PID::compute (
    T setpoint,
    T measured_value,
    T dt
) 

Calculates the control output based on the error between setpoint and measured value. Updates internal state (integral and previous error) for next iteration. Applies input and output clamping for stability.

Parameters:

  • setpoint Desired target value
  • measured_value Current measured/actual value
  • dt Time step since last computation

Returns:

Computed control output (clamped to output limits)


function reset

Reset the PID controller to initial state.

inline JALANSIM_HOST_DEVICE void jalansim::controller::PID::reset () 

Clears the accumulated integral error and previous error values. Useful when starting control of a new trajectory or after a significant disturbance.



The documentation for this class was generated from the following file include/jalansim/controller/pid.hpp