mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-25 03:47:47 +08:00
完成了LKmotor模块的重构,优化了DJIMotor的反馈计算
This commit is contained in:
@@ -6,32 +6,60 @@
|
||||
#include "controller.h"
|
||||
#include "motor_def.h"
|
||||
|
||||
#define LK_MOTOR_CNT 2
|
||||
#define LK_MOTOR_MX_CNT 4
|
||||
|
||||
#define I_MIN -2000
|
||||
#define I_MAX 2000
|
||||
#define CURRENT_SMOOTH_COEF 0.9f
|
||||
#define SPEED_SMOOTH_COEF 0.85f
|
||||
#define REDUCTION_RATIO_DRIVEN 1
|
||||
#define ECD_ANGLE_COEF (360.0f/65536.0f)
|
||||
|
||||
typedef struct // 9025
|
||||
{
|
||||
uint16_t last_ecd;
|
||||
uint16_t ecd;
|
||||
int16_t speed_rpm;
|
||||
int16_t real_current;
|
||||
uint8_t temperate;
|
||||
uint16_t last_ecd;// 上一次读取的编码器值
|
||||
uint16_t ecd; //
|
||||
float angle_single_round; // 单圈角度
|
||||
float speed_aps; // speed angle per sec(degree:°)
|
||||
int16_t real_current; // 实际电流
|
||||
uint8_t temperate; //温度,C°
|
||||
|
||||
PIDInstance *pid;
|
||||
CANInstance *motor_can_instance;
|
||||
float total_angle; // 总角度
|
||||
int32_t total_round; //总圈数
|
||||
|
||||
} driven_instance;
|
||||
} LKMotor_Measure_t;
|
||||
|
||||
typedef enum
|
||||
typedef struct
|
||||
{
|
||||
unused = 0,
|
||||
} driven_mode;
|
||||
LKMotor_Measure_t measure;
|
||||
|
||||
driven_instance *LKMotroInit(CAN_Init_Config_s config);
|
||||
Motor_Control_Setting_s motor_settings;
|
||||
|
||||
void DrivenControl(int16_t motor1_current, int16_t motor2_current);
|
||||
float *other_angle_feedback_ptr; // 其他反馈来源的反馈数据指针
|
||||
float *other_speed_feedback_ptr;
|
||||
PIDInstance current_PID;
|
||||
PIDInstance speed_PID;
|
||||
PIDInstance angle_PID;
|
||||
float pid_ref;
|
||||
|
||||
Motor_Working_Type_e stop_flag; // 启停标志
|
||||
|
||||
CANInstance* motor_can_ins;
|
||||
|
||||
}LKMotorInstance;
|
||||
|
||||
|
||||
LKMotorInstance *LKMotroInit(Motor_Init_Config_s* config);
|
||||
|
||||
void LKMotorSetRef(LKMotorInstance* motor,float ref);
|
||||
|
||||
void LKMotorControl();
|
||||
|
||||
void LKMotorStop(LKMotorInstance *motor);
|
||||
|
||||
void LKMotorEnable(LKMotorInstance *motor);
|
||||
|
||||
void LKMotorSetRef(LKMotorInstance *motor,float ref);
|
||||
|
||||
void SetDrivenMode(driven_mode cmd, uint16_t motor_id);
|
||||
|
||||
#endif // LK9025_H
|
||||
|
||||
Reference in New Issue
Block a user