379 lines
13 KiB
C
379 lines
13 KiB
C
/*
|
||
* 配置相关
|
||
*/
|
||
|
||
/* Includes ----------------------------------------------------------------- */
|
||
#include "module/config.h"
|
||
#include <stdbool.h>
|
||
|
||
|
||
/* Private typedef ---------------------------------------------------------- */
|
||
/* Private define ----------------------------------------------------------- */
|
||
/* Private macro ------------------------------------------------------------ */
|
||
/* Private variables -------------------------------------------------------- */
|
||
|
||
/* Exported variables ------------------------------------------------------- */
|
||
|
||
/**
|
||
* @brief 机器人参数配置
|
||
* @note 在此配置机器人参数
|
||
*/
|
||
Config_RobotParam_t robot_config = {
|
||
/* USER CODE BEGIN robot_config */
|
||
|
||
.gimbal_param = {
|
||
.pid = {
|
||
.yaw_omega = {
|
||
.k = 0.25f,
|
||
.p = 1.0f,
|
||
.i = 0.0f,
|
||
.d = 0.0f,
|
||
.i_limit = 1.0f,
|
||
.out_limit = 1.0f,
|
||
.d_cutoff_freq = -1.0f,
|
||
.range = -1.0f,
|
||
},
|
||
.yaw_angle = {
|
||
.k = 7.0f,
|
||
.p = 3.5f,
|
||
.i = 0.0f,
|
||
.d = 0.0f,
|
||
.i_limit = 0.0f,
|
||
.out_limit = 10.0f,
|
||
.d_cutoff_freq = -1.0f,
|
||
.range = M_2PI,
|
||
},
|
||
.pit_omega = {
|
||
.k = 0.25f,
|
||
.p = 1.0f,
|
||
.i = 0.0f,
|
||
.d = 0.0f,
|
||
.i_limit = 1.0f,
|
||
.out_limit = 1.0f,
|
||
.d_cutoff_freq = -1.0f,
|
||
.range = -1.0f,
|
||
},
|
||
.pit_angle = {
|
||
.k = 2.5f,
|
||
.p = 5.0f,
|
||
.i = 0.2f,
|
||
.d = 0.01f,
|
||
.i_limit = 0.0f,
|
||
.out_limit = 10.0f,
|
||
.d_cutoff_freq = -1.0f,
|
||
.range = M_2PI,
|
||
},
|
||
},
|
||
.mech_zero = {
|
||
.yaw = 0.0f,
|
||
.pit = 2.2f,
|
||
},
|
||
.travel = {
|
||
.yaw = -1.0f,
|
||
.pit = 0.85f,
|
||
},
|
||
.low_pass_cutoff_freq = {
|
||
.out = -1.0f,
|
||
.gyro = 1000.0f,
|
||
},
|
||
.pit_motor ={
|
||
.can = BSP_CAN_1,
|
||
.id = 0x206,
|
||
.gear = false,
|
||
.module = MOTOR_GM6020,
|
||
.reverse = true,
|
||
},
|
||
.yaw_motor = {
|
||
.can = BSP_CAN_1,
|
||
.can_id = 0x1,
|
||
.master_id = 0x11,
|
||
.module = MOTOR_DM_J4310,
|
||
.reverse = false,
|
||
},
|
||
.imu = {
|
||
.can = BSP_CAN_2,
|
||
.accl_id = 0x100, // 加速度计 (十进制256)
|
||
.gyro_id = 0x101, // 陀螺仪 (十进制257)
|
||
.eulr_id = 0x102, // 欧拉角 (十进制258)
|
||
.quat_id = 0x103 // 四元数 (十进制259)
|
||
},
|
||
|
||
},
|
||
|
||
|
||
|
||
.shoot_param = {
|
||
.trig_step_angle=M_2PI/8,
|
||
.shot_delay_time=0.05f,
|
||
.shot_burst_num=1,
|
||
.fric_motor_param[0] = {
|
||
.can = BSP_CAN_1,
|
||
.id = 0x201,
|
||
.module = MOTOR_M3508,
|
||
.reverse = false,
|
||
.gear=false,
|
||
},
|
||
.fric_motor_param[1] = {
|
||
.can = BSP_CAN_1,
|
||
.id = 0x202,
|
||
.module = MOTOR_M3508,
|
||
.reverse = true,
|
||
.gear=false,
|
||
},
|
||
.trig_motor_param = {
|
||
.can = BSP_CAN_1,
|
||
.id = 0x203,
|
||
.module = MOTOR_M2006,
|
||
.reverse = true,
|
||
.gear=true,
|
||
},
|
||
.fric_follow = {
|
||
.k=1.0f,
|
||
.p=1.5f,
|
||
.i=0.0f,
|
||
.d=0.0f,
|
||
.i_limit=0.0f,
|
||
.out_limit=0.9f,
|
||
.d_cutoff_freq=30.0f,
|
||
.range=-1.0f,
|
||
},
|
||
|
||
.fric_err = {
|
||
.k=1.0f,
|
||
.p=4.0f,
|
||
.i=0.4f,
|
||
.d=0.04f,
|
||
.i_limit=0.25f,
|
||
.out_limit=0.25f,
|
||
.d_cutoff_freq=40.0f,
|
||
.range=-1.0f,
|
||
},
|
||
.trig_omg = {
|
||
.k=1.0f,
|
||
.p=1.5f,
|
||
.i=0.3f,
|
||
.d=0.5f,
|
||
.i_limit=0.2f,
|
||
.out_limit=0.9f,
|
||
.d_cutoff_freq=-1.0f,
|
||
.range=-1.0f,
|
||
},
|
||
.trig = {
|
||
.k=1.0f,
|
||
.p=1.0f,
|
||
.i=0.1f,
|
||
.d=0.05f,
|
||
.i_limit=0.8f,
|
||
.out_limit=0.5f,
|
||
.d_cutoff_freq=-1.0f,
|
||
.range=M_2PI,
|
||
},
|
||
.filter.fric = {
|
||
.in = 30.0f,
|
||
.out = 30.0f,
|
||
},
|
||
.filter.trig = {
|
||
.in = 30.0f,
|
||
.out = 30.0f,
|
||
},
|
||
},
|
||
|
||
.chassis_param = {
|
||
.yaw={
|
||
.k=1.0f,
|
||
.p=1.0f,
|
||
.i=0.0f,
|
||
.d=0.3f,
|
||
.i_limit=0.0f,
|
||
.out_limit=1.0f,
|
||
.d_cutoff_freq=30.0f,
|
||
.range=M_2PI, /* 2*PI,用于处理角度循环误差 */
|
||
},
|
||
|
||
.roll={
|
||
.k=0.15f,
|
||
.p=0.3f, /* 横滚角腿长补偿比例系数 (降低避免抖动) */
|
||
.i=0.0f, /* 横滚角腿长补偿积分系数 (关闭避免震荡) */
|
||
.d=0.01f, /* 横滚角腿长补偿微分系数 (关闭避免噪声放大) */
|
||
.i_limit=0.0f, /* 积分限幅 */
|
||
.out_limit=0.03f, /* 输出限幅,腿长差值限制(m) 降低避免过度补偿 */
|
||
.d_cutoff_freq=30.0f, /* 微分截止频率 */
|
||
.range=-1.0f, /* 不使用循环误差处理 */
|
||
},
|
||
|
||
.roll_force={
|
||
.k=5.0f,
|
||
.p=10.0f, /* 横滚角力补偿比例系数 (大幅降低避免抖动) */
|
||
.i=0.0f, /* 横滚角力补偿积分系数 */
|
||
.d=5.0f, /* 横滚角力补偿微分系数 (降低避免高频抖动) */
|
||
.i_limit=0.0f, /* 积分限幅 */
|
||
.out_limit=20.0f, /* 输出限幅,力补偿限制(N) 降低避免过度补偿 */
|
||
.d_cutoff_freq=30.0f, /* 微分截止频率 */
|
||
.range=-1.0f, /* 不使用循环误差处理 */
|
||
},
|
||
|
||
.leg_length={
|
||
.k = 40.0f,
|
||
.p = 20.0f,
|
||
.i = 0.01f,
|
||
.d = 2.0f,
|
||
.i_limit = 0.0f,
|
||
.out_limit = 200.0f,
|
||
.d_cutoff_freq = -1.0f,
|
||
.range = -1.0f,
|
||
},
|
||
|
||
.leg_theta={
|
||
.k=5.0f,
|
||
.p=2.0f, /* 摆角比例系数 */
|
||
.i=0.0f, /* 摆角积分系数 */
|
||
.d=0.0f, /* 摆角微分系数 */
|
||
.i_limit=0.0f, /* 积分限幅 */
|
||
.out_limit=0.05f, /* 输出限幅,腿长差值限制 */
|
||
.d_cutoff_freq=30.0f, /* 微分截止频率 */
|
||
.range=-1.0f, /* 不使用循环误差处理 */
|
||
},
|
||
|
||
.tp={
|
||
.k=4.0f,
|
||
.p=3.0f, /* 俯仰角比例系数 */
|
||
.i=0.0f, /* 俯仰角积分系数 */
|
||
.d=0.0f, /* 俯仰角微分系数 */
|
||
.i_limit=0.0f, /* 积分限幅 */
|
||
.out_limit=10.0f, /* 输出限幅,腿长差值限制 */
|
||
.d_cutoff_freq=30.0f, /* 微分截止频率 */
|
||
.range=-1.0f, /* 不使用循环误差处理 */
|
||
},
|
||
|
||
.low_pass_cutoff_freq = {
|
||
.in = 30.0f,
|
||
.out = 30.0f,
|
||
},
|
||
|
||
.yaw_motor = { // 云台Yaw轴电机
|
||
.can = BSP_CAN_1,
|
||
.can_id = 0x1,
|
||
.master_id = 0x11,
|
||
.module = MOTOR_DM_J4310,
|
||
.reverse = false,
|
||
},
|
||
|
||
.joint_param = {
|
||
{ // 左髋关节
|
||
.can = BSP_CAN_3,
|
||
.motor_id = 124,
|
||
.host_id = 0xFF,
|
||
.module = MOTOR_LZ_RSO3,
|
||
.reverse = false,
|
||
.mode = MOTOR_LZ_MODE_MOTION,
|
||
},
|
||
{ // 右髋关节
|
||
.can = BSP_CAN_3,
|
||
.motor_id = 125,
|
||
.host_id = 0xFF,
|
||
.module = MOTOR_LZ_RSO3,
|
||
.reverse = false,
|
||
.mode = MOTOR_LZ_MODE_MOTION,
|
||
},
|
||
{ // 左膝关节
|
||
.can = BSP_CAN_3,
|
||
.motor_id = 126,
|
||
.host_id = 0xFF,
|
||
.module = MOTOR_LZ_RSO3,
|
||
.reverse = true,
|
||
.mode = MOTOR_LZ_MODE_MOTION,
|
||
},
|
||
{ // 右膝关节
|
||
.can = BSP_CAN_3,
|
||
.motor_id = 127,
|
||
.host_id = 0xFF,
|
||
.module = MOTOR_LZ_RSO3,
|
||
.reverse = true,
|
||
.mode = MOTOR_LZ_MODE_MOTION,
|
||
},
|
||
},
|
||
|
||
.wheel_param = {
|
||
{ // 左轮电机
|
||
.can = BSP_CAN_3,
|
||
.id = 0x142,
|
||
.module = MOTOR_LK_MF9025,
|
||
.reverse = false,
|
||
},
|
||
{ // 右轮电机
|
||
.can = BSP_CAN_3,
|
||
.id = 0x141,
|
||
.module = MOTOR_LK_MF9025,
|
||
.reverse = true,
|
||
},
|
||
},
|
||
|
||
.mech_zero_yaw = 1.78040409f, /* 机械零点 */
|
||
.joint_zero = {0.0f, 0.0f, 3.84780002f, -1.16999996f}, /* 关节电机零点偏移位置 */
|
||
.hip_width = 0.423f, /* 髋宽,即两腿间距 (m),用于Roll几何补偿 */
|
||
.vmc_param = {
|
||
{ // 左腿
|
||
.leg_1 = 0.215f, // 后髋连杆长度 (L1) (m)
|
||
.leg_2 = 0.258f, // 后膝连杆长度 (L2) (m)
|
||
.leg_3 = 0.258f, // 前膝连杆长度 (L3) (m)
|
||
.leg_4 = 0.215f, // 前髋连杆长度 (L4) (m)
|
||
.hip_length = 0.0f // 髋宽 (L5) (m)
|
||
},
|
||
{ // 右腿
|
||
.leg_1 = 0.215f, // 后髋连杆长度 (L1) (m)
|
||
.leg_2 = 0.258f, // 后膝连杆长度 (L2) (m)
|
||
.leg_3 = 0.258f, // 前膝连杆长度 (L3) (m)
|
||
.leg_4 = 0.215f, // 前髋连杆长度 (L4) (m)
|
||
.hip_length = 0.0f // 髋宽 (L5) (m)
|
||
}
|
||
},
|
||
|
||
.lqr_gains = {
|
||
.k11_coeff = { -2.110325959941390e+02f, 2.474876302869424e+02f, -1.259312069344584e+02f, -3.555067587081389e+00f }, // theta
|
||
.k12_coeff = { 1.729035713826111e+00f, -1.094205267383853e+00f, -8.235618497594484e+00f, -2.949091603597677e-01f }, // d_theta
|
||
.k13_coeff = { -3.661055595462458e+01f, 4.066046385752247e+01f, -1.618786894025212e+01f, -1.618742454043447e+00f }, // x
|
||
.k14_coeff = { -2.988926501197955e+01f, 3.445642428071118e+01f, -1.547117906530474e+01f, -2.039186188549067e+00f }, // d_x
|
||
.k15_coeff = { -4.094585161782607e+01f, 6.119228618474273e+01f, -3.603009625243965e+01f, 1.037078067693317e+01f }, // phi
|
||
.k16_coeff = { -7.625020535837323e+00f, 1.097226354374976e+01f, -6.302244199082423e+00f, 1.920720114282383e+00f }, // d_phi
|
||
.k21_coeff = { 3.113860878856309e+02f, -2.577426343951217e+02f, 4.982404130107013e+01f, 1.415180465415879e+01f }, // theta
|
||
.k22_coeff = { 1.126082466887103e+01f, -9.812804977178935e+00f, 1.814407629267238e+00f, 1.941377111901043e+00f }, // d_theta
|
||
.k23_coeff = { -1.771607516002724e+01f, 4.047388400543465e+01f, -2.962942748901807e+01f, 8.971209797230671e+00f }, // x
|
||
.k24_coeff = { -3.391460592939657e+01f, 5.575858169617614e+01f, -3.466996436706782e+01f, 9.833893476570065e+00f }, // d_x
|
||
.k25_coeff = { 2.392778926806863e+02f, -2.574664846375947e+02f, 9.953632837845201e+01f, 2.579297039170335e+00f }, // phi
|
||
.k26_coeff = { 4.297556375859175e+01f, -4.657509218314731e+01f, 1.826212630358702e+01f, 1.257410509642398e-01f }, // d_phi
|
||
},
|
||
|
||
|
||
.jump_params = {
|
||
.crouch_time_ms = 100,
|
||
.launch_time_ms = 120,
|
||
.retract_time_ms = 80,
|
||
.land_time_ms = 300,
|
||
.crouch_leg_length = 0.14f,
|
||
.launch_force = 200.0f,
|
||
.retract_leg_length = 0.1f, /* 收腿目标更短 */
|
||
.retract_force = -120.0f, /* 收腿前馈力加大 */
|
||
},
|
||
.theta = 0.0f,
|
||
.x = 0.0f,
|
||
.phi = 0.0f,
|
||
|
||
},
|
||
|
||
.ai_param = {
|
||
.can = BSP_FDCAN_2,
|
||
.vision_id = 0x104,
|
||
},
|
||
/* USER CODE END robot_config */
|
||
};
|
||
|
||
/* Private function prototypes ---------------------------------------------- */
|
||
/* Exported functions ------------------------------------------------------- */
|
||
|
||
/**
|
||
* @brief 获取机器人配置参数
|
||
* @return 机器人配置参数指针
|
||
*/
|
||
Config_RobotParam_t* Config_GetRobotParam(void) {
|
||
return &robot_config;
|
||
} |