加入PID
This commit is contained in:
12
Core/Inc/chassis_control.h
Normal file
12
Core/Inc/chassis_control.h
Normal 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
15
Core/Inc/pid.h
Normal 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
|
||||
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user