|
Teleoperated Robot Hand
|
PID control and motor control helpers for robotic hand fingers. More...
#include "pid.h"Functions | |
| void | PID_Init (PID_t *pid, float kp, float ki, float kd, float out_min, float out_max) |
| Initialize a PID controller structure. | |
| void | InitPIDs () |
| Initialize all PID controllers used by the robotic hand. | |
| void | PID_Reset (PID_t *pid) |
| Reset a PID controller's internal state. | |
| float | PID_Step (PID_t *pid, float error, float dt) |
| Perform one PID control step. | |
| void | SetPhase (float u, uint32_t motor_phase_pin) |
| Set motor direction based on signed control effort. | |
| void | PositionControlFinger (uint32_t enc, uint32_t target, PID_t *pid, int pwm_channel, int phase_pin, float dt) |
| Perform PID-based position control for a single finger motor. | |
| bool | HomeFinger (uint32_t enc, uint32_t home_target, int pwm_channel, int phase_pin) |
| Home a single finger motor to a reference position. | |
PID control and motor control helpers for robotic hand fingers.
This module provides:
Designed for use with FreeRTOS-based embedded systems.
| bool HomeFinger | ( | uint32_t | enc, |
| uint32_t | home_target, | ||
| int | pwm_channel, | ||
| int | phase_pin ) |
Home a single finger motor to a reference position.
Drives the motor toward a known home encoder value using a proportional controller until the error falls below ::HOMING_THRESHOLD.
| enc | Current encoder reading. |
| home_target | Desired home encoder value. |
| pwm_channel | LEDC PWM channel controlling the motor. |
| phase_pin | GPIO pin controlling motor direction. |
| void InitPIDs | ( | ) |
Initialize all PID controllers used by the robotic hand.
Sets gains and output limits for all fingers and palm.
| void PID_Init | ( | PID_t * | pid, |
| float | kp, | ||
| float | ki, | ||
| float | kd, | ||
| float | out_min, | ||
| float | out_max ) |
Initialize a PID controller structure.
Sets controller gains, output limits, and clears internal state.
| pid | Pointer to PID controller structure. |
| kp | Proportional gain. |
| ki | Integral gain. |
| kd | Derivative gain. |
| out_min | Minimum allowable output. |
| out_max | Maximum allowable output. |
| void PID_Reset | ( | PID_t * | pid | ) |
Reset a PID controller's internal state.
Clears the integral accumulator and previous error term.
| pid | Pointer to PID controller structure. |
| float PID_Step | ( | PID_t * | pid, |
| float | error, | ||
| float | dt ) |
Perform one PID control step.
Computes the control output using proportional, integral, and derivative terms and applies output clamping.
| pid | Pointer to PID controller structure. |
| error | Current control error (setpoint - measurement). |
| dt | Time step in seconds since last update. |
| void PositionControlFinger | ( | uint32_t | enc, |
| uint32_t | target, | ||
| PID_t * | pid, | ||
| int | pwm_channel, | ||
| int | phase_pin, | ||
| float | dt ) |
Perform PID-based position control for a single finger motor.
Computes the control effort using PID, sets motor direction, enforces a minimum PWM threshold, and applies the PWM output.
| enc | Current encoder reading. |
| target | Desired encoder target value. |
| pid | Pointer to PID controller for this finger. |
| pwm_channel | LEDC PWM channel controlling the motor. |
| phase_pin | GPIO pin controlling motor direction. |
| dt | Control loop timestep in seconds. |
| void SetPhase | ( | float | u, |
| uint32_t | motor_phase_pin ) |
Set motor direction based on signed control effort.
Uses the sign of the control signal to determine the motor rotation direction via the phase pin.
| u | Signed control output. |
| motor_phase_pin | GPIO pin controlling motor direction. |