mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-24 11:37:45 +08:00
简化了电机测量的命名,完成初版平衡底盘的功能编写,待测试方向和符号的正确性
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "LK9025.h"
|
||||
#include "stdlib.h"
|
||||
#include "general_def.h"
|
||||
|
||||
static uint8_t idx;
|
||||
static LKMotorInstance *lkmotor_instance[LK_MOTOR_MX_CNT] = {NULL};
|
||||
@@ -23,8 +24,8 @@ static void LKMotorDecode(CANInstance *_instance)
|
||||
|
||||
measure->angle_single_round = ECD_ANGLE_COEF_LK * measure->ecd;
|
||||
|
||||
measure->speed_aps = (1 - SPEED_SMOOTH_COEF) * measure->speed_aps +
|
||||
SPEED_SMOOTH_COEF * (float)((int16_t)(rx_buff[5] << 8 | rx_buff[4]));
|
||||
measure->speed_rads = (1 - SPEED_SMOOTH_COEF) * measure->speed_rads +
|
||||
DEGREE_2_RAD * SPEED_SMOOTH_COEF * (float)((int16_t)(rx_buff[5] << 8 | rx_buff[4]));
|
||||
|
||||
measure->real_current = (1 - CURRENT_SMOOTH_COEF) * measure->real_current +
|
||||
CURRENT_SMOOTH_COEF * (float)((int16_t)(rx_buff[3] << 8 | rx_buff[2]));
|
||||
@@ -101,7 +102,7 @@ void LKMotorControl()
|
||||
if (setting->angle_feedback_source == OTHER_FEED)
|
||||
pid_measure = *motor->other_speed_feedback_ptr;
|
||||
else
|
||||
pid_measure = measure->speed_aps;
|
||||
pid_measure = measure->speed_rads;
|
||||
pid_ref = PIDCalculate(&motor->angle_PID, pid_measure, pid_ref);
|
||||
if (setting->feedforward_flag & CURRENT_FEEDFORWARD)
|
||||
pid_ref += *motor->current_feedforward_ptr;
|
||||
|
||||
@@ -14,13 +14,14 @@
|
||||
#define SPEED_SMOOTH_COEF 0.85f
|
||||
#define REDUCTION_RATIO_DRIVEN 1
|
||||
#define ECD_ANGLE_COEF_LK (360.0f / 65536.0f)
|
||||
#define CURRENT_TORQUE_COEF_LK 0.003645f // 电流设定值转换成扭矩的系数,算出来的设定值除以这个系数就是扭矩值
|
||||
|
||||
typedef struct // 9025
|
||||
{
|
||||
uint16_t last_ecd; // 上一次读取的编码器值
|
||||
uint16_t ecd; // 当前编码器值
|
||||
float angle_single_round; // 单圈角度
|
||||
float speed_aps; // speed angle per sec(degree:°)
|
||||
float speed_rads; // speed rad/s
|
||||
int16_t real_current; // 实际电流
|
||||
uint8_t temperate; // 温度,C°
|
||||
|
||||
|
||||
Reference in New Issue
Block a user