加入PID

This commit is contained in:
2026-07-15 17:09:24 +08:00
parent 050ae25e9c
commit 8b24a3da19
10 changed files with 139 additions and 3 deletions

View File

@@ -0,0 +1,12 @@
#ifndef CHASSIS_CONTROL_H
#define CHASSIS_CONTROL_H
#include "pid.h"
#include "main.h"
void chassis_control_init(void);
void chassis_control_task(void);
void chassis_set_speed(int16_t m1, int16_t m2, int16_t m3, int16_t m4);
#endif

15
Core/Inc/pid.h Normal file
View File

@@ -0,0 +1,15 @@
#ifndef PID_H
#define PID_H
typedef struct {
float kp, ki, kd;
float integral;
float last_error;
float max_out;
float max_integral;
} pid_t;
void pid_init(pid_t *pid, float kp, float ki, float kd, float max_out, float max_i);
float pid_calc(pid_t *pid, float target, float actual);
#endif

View File

@@ -52,6 +52,7 @@ void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void DebugMon_Handler(void);
void CAN1_RX0_IRQHandler(void);
void TIM6_DAC_IRQHandler(void);
/* USER CODE BEGIN EFP */