309 lines
10 KiB
C
309 lines
10 KiB
C
/*
|
||
* 配置相关
|
||
*/
|
||
|
||
/* Includes ----------------------------------------------------------------- */
|
||
#include "module/config.h"
|
||
#include "bsp/can.h"
|
||
#include "device/motor_dm.h"
|
||
|
||
|
||
/* Private typedef ---------------------------------------------------------- */
|
||
/* Private define ----------------------------------------------------------- */
|
||
/* Private macro ------------------------------------------------------------ */
|
||
/* Private variables -------------------------------------------------------- */
|
||
|
||
/* Exported variables ------------------------------------------------------- */
|
||
|
||
// 机器人参数配置
|
||
Config_RobotParam_t robot_config = {
|
||
.shoot_param = {
|
||
.trig_step_angle=M_2PI/8,
|
||
.shot_delay_time=0.05f,
|
||
.shot_burst_num=50,
|
||
.fric_motor_param[0] = {
|
||
.can = BSP_CAN_2,
|
||
.id = 0x201,
|
||
.module = MOTOR_M3508,
|
||
.reverse = true,
|
||
.gear=false,
|
||
},
|
||
.fric_motor_param[1] = {
|
||
.can = BSP_CAN_2,
|
||
.id = 0x202,
|
||
.module = MOTOR_M3508,
|
||
.reverse = false,
|
||
.gear=false,
|
||
},
|
||
.trig_motor_param = {
|
||
.can = BSP_CAN_1,
|
||
.id = 0x201,
|
||
.module = MOTOR_M2006,
|
||
.reverse = true,
|
||
.gear=true,
|
||
},
|
||
.fric_follow = {
|
||
.k=1.0f,
|
||
.p=1.8f,
|
||
.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,
|
||
},
|
||
|
||
|
||
},
|
||
|
||
.gimbal_param = {
|
||
.pid = {
|
||
.yaw_omega = {
|
||
.k = 1.0f,
|
||
.p = 1.0f,
|
||
.i = 0.3f,
|
||
.d = 0.0f,
|
||
.i_limit = 1.0f,
|
||
.out_limit = 1.0f,
|
||
.d_cutoff_freq = -1.0f,
|
||
.range = -1.0f,
|
||
},
|
||
.yaw_angle = {
|
||
.k = 8.0f,
|
||
.p = 3.0f,
|
||
.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 = 5.0f,
|
||
.p = 5.0f,
|
||
.i = 2.5f,
|
||
.d = 0.0f,
|
||
.i_limit = 0.0f,
|
||
.out_limit = 10.0f,
|
||
.d_cutoff_freq = -1.0f,
|
||
.range = M_2PI,
|
||
},
|
||
},
|
||
.mech_zero = {
|
||
.yaw = 0.0f,
|
||
.pit = 1.77f,
|
||
},
|
||
.travel = {
|
||
.yaw = -1.0f,
|
||
.pit = 0.8f,
|
||
},
|
||
.low_pass_cutoff_freq = {
|
||
.out = -1.0f,
|
||
.gyro = 1000.0f,
|
||
},
|
||
.pit_motor ={
|
||
.can = BSP_CAN_2,
|
||
.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,
|
||
}
|
||
},
|
||
|
||
.chassis_param = {
|
||
.yaw={
|
||
.k=1.0f,
|
||
.p=1.0f,
|
||
.i=0.01f,
|
||
.d=0.05f,
|
||
.i_limit=0.0f,
|
||
.out_limit=1.0f,
|
||
.d_cutoff_freq=30.0f,
|
||
.range=M_2PI, /* 2*PI,用于处理角度循环误差 */
|
||
},
|
||
|
||
.roll={
|
||
.k=30.0f,
|
||
.p=20.0f, /* 横滚角比例系数 */
|
||
.i=1.0f, /* 横滚角积分系数 */
|
||
.d=0.5f, /* 横滚角微分系数 */
|
||
.i_limit=20.0f, /* 积分限幅 */
|
||
.out_limit=100.0f, /* 输出限幅,腿长差值限制 */
|
||
.d_cutoff_freq=30.0f, /* 微分截止频率 */
|
||
.range=-1.0f, /* 不使用循环误差处理 */
|
||
},
|
||
|
||
.leg_length={
|
||
.k = 50.0f,
|
||
.p = 10.0f,
|
||
.i = 0.0f,
|
||
.d = 1.0f,
|
||
.i_limit = 0.0f,
|
||
.out_limit = 100.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=2.0f,
|
||
.p=2.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_2,
|
||
.can_id = 0x1,
|
||
.master_id = 0x11,
|
||
.module = MOTOR_DM_J4310,
|
||
.reverse = false,
|
||
},
|
||
|
||
.mech_zero_yaw = 4.34085676f, /* 250.5度,机械零点 */
|
||
|
||
.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 = { -1.498109852818409e+02f, 1.918923604951453e+02f, -1.080984818173493e+02f, -1.540703437137126e+00f }, // theta
|
||
.k12_coeff = { 8.413682810667103e+00f, -6.603584762798329e+00f, -6.421063158996702e+00f, -5.450666844349098e-02f }, // d_theta
|
||
.k13_coeff = { -3.146938649452867e+01f, 3.671781823697795e+01f, -1.548019975847165e+01f, -3.659482046966758e-01f }, // x
|
||
.k14_coeff = { -3.363190268966418e+01f, 4.073114332036178e+01f, -1.877821151363973e+01f, -6.755848684037919e-01f }, // d_x
|
||
.k15_coeff = { 1.813346556940570e+00f, 1.542139674818206e+01f, -1.784151260000496e+01f, 6.975189972486323e+00f }, // phi
|
||
.k16_coeff = { -1.683339907923917e+00f, 3.762911505427638e+00f, -2.966405826579746e+00f, 1.145611903160937e+00f }, // d_phi
|
||
.k21_coeff = { 3.683683451383080e+02f, -3.184826128050574e+02f, 7.012281968985167e+01f, 1.232691707185163e+01f }, // theta
|
||
.k22_coeff = { 2.256451382235226e+01f, -2.387074220964917e+01f, 8.355357863648345e+00f, 1.148384164091676e+00f }, // d_theta
|
||
.k23_coeff = { 1.065026516142075e+01f, 1.016717837738013e+01f, -1.810442639595643e+01f, 7.368019318950717e+00f }, // x
|
||
.k24_coeff = { 2.330418054102148e+00f, 2.193671212435775e+01f, -2.502198732490354e+01f, 9.621144599080463e+00f }, // d_x
|
||
.k25_coeff = { 1.784444885521937e+02f, -2.030738611028434e+02f, 8.375405599993576e+01f, -2.204042546242858e-01f }, // phi
|
||
.k26_coeff = { 2.646425532528492e+01f, -3.034702782249508e+01f, 1.275100635568078e+01f, -4.878639273974432e-01f }, // d_phi
|
||
},
|
||
|
||
.theta = 0.0f,
|
||
.x = 0.0f,
|
||
.phi = -0.1f,
|
||
|
||
.virtual_chassis_param = {
|
||
.motors = {
|
||
.can = BSP_CAN_1,
|
||
.enable_id = 121,
|
||
.joint_cmd_id = 122,
|
||
.joint_feedback_base_id = 124,
|
||
.wheel_left_id = 0x128,
|
||
.wheel_right_id = 0x129,
|
||
.wheel_left_feedback_id = 0x82,
|
||
.wheel_right_feedback_id = 0x83,
|
||
},
|
||
.imu = {
|
||
.can = BSP_CAN_1,
|
||
.accl_id = 0x301,
|
||
.gyro_id = 0x302,
|
||
.euler_id = 0x303,
|
||
.quat_id = 0x304,
|
||
},
|
||
},
|
||
},
|
||
|
||
|
||
};
|
||
|
||
/* Private function prototypes ---------------------------------------------- */
|
||
/* Exported functions ------------------------------------------------------- */
|
||
|
||
/**
|
||
* @brief 获取机器人配置参数
|
||
* @return 机器人配置参数指针
|
||
*/
|
||
Config_RobotParam_t* Config_GetRobotParam(void) {
|
||
return &robot_config;
|
||
} |