Infantry/User/module/config.c

313 lines
6.8 KiB
C

/*
* 配置相关
*/
/* Includes ----------------------------------------------------------------- */
#include "user_math.h"
#include "module\config.h"
#include "bsp\can.h"
#include "module\shoot.h"
/* Private typedef ---------------------------------------------------------- */
/* Private define ----------------------------------------------------------- */
/* Private macro ------------------------------------------------------------ */
/* Private variables -------------------------------------------------------- */
/* Exported variables ------------------------------------------------------- */
// 机器人参数配置
Config_RobotParam_t robot_config = {
.gimbal_param = {
/* 云台欧拉角与角速度自由选择 */
.Direction={
.Eulr={
.pit=Pit,
.yaw=Yaw,
},
.Gyro={
.pit=Gyro_x,
.yaw=Gyro_z,
},
},
/*欧拉角限位和电机角度限位*/
.Limit_t= {
.pit_max= 0.462614686,
.pit_min=-0.518002629,
/*零点参数*/
.zero={
.yaw_encoder=1.26,
.travel={
.yaw=1.5,
},
},
},
.feedforward={
.imu = {
.yaw=false,
.pit=false,
},
},
.motor={
/*按自己需求选择电机*/
// .major_yaw=DM,
.pit=RM,
.yaw=RM,
/*是否开启限位*/
.limit_yaw=false,
.limit_pit=true,
.pit_rm_motor={BSP_CAN_2,0x20A,MOTOR_GM6020,true,false},
.yaw_rm_motor={BSP_CAN_2,0x209,MOTOR_GM6020,false,false},
/*达妙电机参数自己配*/
},
.dm_Params_t={
},
.low_pass_cutoff_freq = {
.out = -1.0f,
.gyro = 1000.0f,
},
.pid = {
/*欧拉角控制参数*/
.yaw_omega = {
.k = 0.45f,
.p = 1.0f,
.i = 6.0f,
.d = 0.0008f,//0
.i_limit = 1.0f,
.out_limit = 1.0f,
.d_cutoff_freq = -1.0f,
.range = -1.0f,
},
.yaw_angle = {
.k = 10.0f,
.p = 2.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.001901f,
.i_limit = 1.0f,
.out_limit = 1.0f,
.d_cutoff_freq = -1.0f,
.range = -1.0f,
},
.pit_angle = {
.k = 2.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,
},
}
},
.shoot_param = {
.basic={
.projectileType=SHOOT_PROJECTILE_17MM,
.fric_num=2,
.extra_deceleration_ratio=36.0f,
.num_trig_tooth=10,
.shot_freq=10.0f,
.shot_burst_num=5,
.ratio_multilevel = {1.0f},
},
.jamDetection={
.enable=true,
.threshold=105.0f,
.suspectedTime=1.0f,
},
.motor={
.fric = {
{
.param = {
.can = BSP_CAN_2,
.id = 0x205,
.module = MOTOR_M2006,
.reverse = false,
.gear = false,
},
.level=1,
},
{
.param = {
.can = BSP_CAN_2,
.id = 0x206,
.module = MOTOR_M2006,
.reverse = true,
.gear = false,
},
.level=1,
},
},
.trig = {
.can = BSP_CAN_2,
.id = 0x207,
.module = MOTOR_M2006,
.reverse = false,
.gear=true,
},
},
.pid={
.fric_follow = {
.k=1.0f,
.p=1.5f,
.i=0.3f,
.d=0.0f,
.i_limit=0.2f,
.out_limit=0.9f,
.d_cutoff_freq=-1.0f,
.range=-1.0f,
},
.fric_err = {
.k=0.0f,
.p=4.0f,
.i=0.4f,
.d=0.0f,
.i_limit=0.25f,
.out_limit=0.25f,
.d_cutoff_freq=-1.0f,
.range=-1.0f,
},
.trig_2006 = {
.k = 12.0f,
.p = 1.0f,
.i = 0.0f,
.d = 0.0450000018f,
.i_limit = 1.0f,
.out_limit = 1.0f,
.d_cutoff_freq = -1.0f,
.range = M_2PI,
},
.trig_omg_2006 = {
.k=0.f,
.p=1.0f,
.i=0.3f,
.d=0.5f,
.i_limit=0.2f,
.out_limit=1.0f,
.d_cutoff_freq=-1.0f,
.range=-1.0f,
},
},
.filter={
.fric = {
.in = 30.0f,
.out = 30.0f,
},
.trig = {
.in = 30.0f,
.out = 30.0f,
},
},
},
.chassis_param = {
/* DJI3508电机*/
.motor_param = {
{
.can = BSP_CAN_1,
.id = 0x201,
.module = MOTOR_M3508,
.reverse = false,
.gear = true
},
{
.can = BSP_CAN_1,
.id = 0x202,
.module = MOTOR_M3508,
.reverse = false,
.gear = true
},
{
.can = BSP_CAN_1,
.id = 0x203,
.module = MOTOR_M3508,
.reverse = false,
.gear = true
},
{
.can = BSP_CAN_1,
.id = 0x204,
.module = MOTOR_M3508,
.reverse = false,
.gear = true
},
},
.type = CHASSIS_TYPE_MECANUM,
/* PID */
.pid = {
/* 底盘电机 PID */
.motor_pid_param = {
.k = 0.001f,
.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,
},
/* 跟随 */
.follow_pid_param = {
.k = 0.5f,
.p = 1.0f,
.i = 0.0f,
.d = 0.0f,
.i_limit = 1.0f,
.out_limit = 1.0f,
.d_cutoff_freq = -1.0f,
.range = M_2PI,
},
},
.low_pass_cutoff_freq = {
.in = 50.0f,
.out = 50.0f,
},
.reverse = {
.yaw = false,
},
.limit = {
.max_vx = 3.0f,
.max_vy = 3.0f,
.max_wz = 2.0f,
.max_current = 16000.0f
},
},
};
/**
* @brief 获取机器人配置参数
* @return 机器人配置参数指针
*/
Config_RobotParam_t* Config_GetRobotParam(void) {
return &robot_config;
}