Struct jalansim::dynamics::models::DiffDrivePID
template <typename T>
ClassList > jalansim > dynamics > models > DiffDrivePID
Differential drive robot with PID-controlled wheels. More...
#include <diff_drive_pid.hpp>
Public Attributes
Type | Name |
---|---|
T | kd = 0.0 PID controller gains. |
T | ki = 0.0 |
T | kp = 0.025 |
controller::PID< T > | pid_l = {kp, ki, [**kd**](structjalansim_1_1dynamics_1_1models_1_1_diff_drive_p_i_d.md#variable-kd), [**w\_min**](structjalansim_1_1dynamics_1_1models_1_1_diff_drive_p_i_d.md#variable-w_min), [**w\_max**](structjalansim_1_1dynamics_1_1models_1_1_diff_drive_p_i_d.md#variable-w_max), [**torque\_min**](structjalansim_1_1dynamics_1_1models_1_1_diff_drive_p_i_d.md#variable-torque_min), [**torque\_max**](structjalansim_1_1dynamics_1_1models_1_1_diff_drive_p_i_d.md#variable-torque_max)} Left wheel PID controller. |
controller::PID< T > | pid_r = {kp, ki, [**kd**](structjalansim_1_1dynamics_1_1models_1_1_diff_drive_p_i_d.md#variable-kd), [**w\_min**](structjalansim_1_1dynamics_1_1models_1_1_diff_drive_p_i_d.md#variable-w_min), [**w\_max**](structjalansim_1_1dynamics_1_1models_1_1_diff_drive_p_i_d.md#variable-w_max), [**torque\_min**](structjalansim_1_1dynamics_1_1models_1_1_diff_drive_p_i_d.md#variable-torque_min), [**torque\_max**](structjalansim_1_1dynamics_1_1models_1_1_diff_drive_p_i_d.md#variable-torque_max)} Right wheel PID controller. |
T | torque_max = 50.0 Maximum wheel torque (N⋅m) |
T | torque_min = -50.0 Minimum wheel torque (N⋅m) |
T | w_max = 20.4082 Maximum wheel angular velocity (rad/s) |
T | w_min = -20.4082 Minimum wheel angular velocity (rad/s) |
T | wheel_J = 0.0024 Wheel moment of inertia (kg⋅m²) |
T | wheel_b = 0.262 Wheelbase/track width (m) |
T | wheel_r = 0.098 Wheel radius (m) |
Public Static Attributes
Type | Name |
---|---|
std::size_t | INPUT_DIM = 2 Input dimension: [v, omega]. |
std::size_t | STATE_DIM = 5 State dimension: [x, y, theta, wr, wl]. |
Public Functions
Type | Name |
---|---|
JALANSIM_HOST_DEVICE void | reset () Reset the model and PID controllers to initial state. |
JALANSIM_HOST_DEVICE void | rhs (const T * x, const T * u, T * dx, T dt) Compute state derivatives with PID wheel control. |
Public Static Functions
Type | Name |
---|---|
JALANSIM_HOST_DEVICE T | clamp (T v, T lo, T hi) Clamp a value between lower and upper bounds. |
Detailed Description
Implements a differential drive model with closed-loop wheel speed control using PID controllers. Takes high-level velocity commands (linear, angular) and converts them to wheel speed setpoints, then uses PID controllers to generate wheel torques. Models wheel inertia and includes constraints.
State: [x, y, theta, omega_right, omega_left] Input: [linear_velocity, angular_velocity]
Template parameters:
T
Numeric type (float, double)
Public Attributes Documentation
variable kd
PID controller gains.
T jalansim::dynamics::models::DiffDrivePID< T >::kd;
variable ki
T jalansim::dynamics::models::DiffDrivePID< T >::ki;
variable kp
T jalansim::dynamics::models::DiffDrivePID< T >::kp;
variable pid_l
Left wheel PID controller.
controller::PID<T> jalansim::dynamics::models::DiffDrivePID< T >::pid_l;
variable pid_r
Right wheel PID controller.
controller::PID<T> jalansim::dynamics::models::DiffDrivePID< T >::pid_r;
variable torque_max
Maximum wheel torque (N⋅m)
T jalansim::dynamics::models::DiffDrivePID< T >::torque_max;
variable torque_min
Minimum wheel torque (N⋅m)
T jalansim::dynamics::models::DiffDrivePID< T >::torque_min;
variable w_max
Maximum wheel angular velocity (rad/s)
T jalansim::dynamics::models::DiffDrivePID< T >::w_max;
variable w_min
Minimum wheel angular velocity (rad/s)
T jalansim::dynamics::models::DiffDrivePID< T >::w_min;
variable wheel_J
Wheel moment of inertia (kg⋅m²)
T jalansim::dynamics::models::DiffDrivePID< T >::wheel_J;
variable wheel_b
Wheelbase/track width (m)
T jalansim::dynamics::models::DiffDrivePID< T >::wheel_b;
variable wheel_r
Wheel radius (m)
T jalansim::dynamics::models::DiffDrivePID< T >::wheel_r;
Public Static Attributes Documentation
variable INPUT_DIM
Input dimension: [v, omega].
std::size_t jalansim::dynamics::models::DiffDrivePID< T >::INPUT_DIM;
variable STATE_DIM
State dimension: [x, y, theta, wr, wl].
std::size_t jalansim::dynamics::models::DiffDrivePID< T >::STATE_DIM;
Public Functions Documentation
function reset
Reset the model and PID controllers to initial state.
inline JALANSIM_HOST_DEVICE void jalansim::dynamics::models::DiffDrivePID::reset ()
function rhs
Compute state derivatives with PID wheel control.
inline JALANSIM_HOST_DEVICE void jalansim::dynamics::models::DiffDrivePID::rhs (
const T * x,
const T * u,
T * dx,
T dt
)
Parameters:
x
State vector [x, y, theta, omega_r, omega_l]u
Input vector [linear_vel, angular_vel]dx
Output state derivativesdt
Time step for PID computation and constraints
Public Static Functions Documentation
function clamp
Clamp a value between lower and upper bounds.
static inline JALANSIM_HOST_DEVICE T jalansim::dynamics::models::DiffDrivePID::clamp (
T v,
T lo,
T hi
)
Parameters:
v
Value to clamplo
Lower boundhi
Upper bound
Returns:
Clamped value
The documentation for this class was generated from the following file include/jalansim/dynamics/models/diff_drive_pid.hpp