Compare commits
No commits in common. "5bf4f99113c76d796675b61851533f17db3b0512" and "88acd92609c9c8b8116bed852e7dcb2868d8022b" have entirely different histories.
5bf4f99113
...
88acd92609
@ -146,19 +146,15 @@ int8_t CMD_CtrlSet(Chassis_CMD_t *c_cmd, const CMD_RC_t *rc, Gimbal_CMD_t *g_cmd
|
|||||||
{
|
{
|
||||||
case CMD_SW_UP:
|
case CMD_SW_UP:
|
||||||
g_cmd->ctrl_mode = GIMBAL_MODE_REMOTE;
|
g_cmd->ctrl_mode = GIMBAL_MODE_REMOTE;
|
||||||
s_cmd->control_mode=SHOOT_REMOTE;
|
|
||||||
break;
|
break;
|
||||||
case CMD_SW_MID:
|
case CMD_SW_MID:
|
||||||
g_cmd->ctrl_mode = GIMBAL_MODE_AI;
|
g_cmd->ctrl_mode = GIMBAL_MODE_AI;
|
||||||
s_cmd->control_mode=SHOOT_AI;
|
|
||||||
break;
|
break;
|
||||||
case CMD_SW_DOWN:
|
case CMD_SW_DOWN:
|
||||||
g_cmd->ctrl_mode = GIMBAL_MODE_AI;
|
g_cmd->ctrl_mode = GIMBAL_MODE_AI;
|
||||||
s_cmd->control_mode=SHOOT_AI;
|
|
||||||
break;
|
break;
|
||||||
case CMD_SW_ERR:
|
case CMD_SW_ERR:
|
||||||
g_cmd->ctrl_mode = GIMBAL_MODE_REMOTE;
|
g_cmd->ctrl_mode = GIMBAL_MODE_REMOTE;
|
||||||
s_cmd->control_mode=SHOOT_REMOTE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +183,7 @@ int8_t CMD_CtrlSet(Chassis_CMD_t *c_cmd, const CMD_RC_t *rc, Gimbal_CMD_t *g_cmd
|
|||||||
s_cmd->mode = SHOOT_MODE_SINGLE;
|
s_cmd->mode = SHOOT_MODE_SINGLE;
|
||||||
break;
|
break;
|
||||||
case CMD_SW_DOWN:
|
case CMD_SW_DOWN:
|
||||||
s_cmd->mode = SHOOT_MODE_BURST;
|
s_cmd->mode = SHOOT_MODE_CONTINUE;
|
||||||
break;
|
break;
|
||||||
case CMD_SW_ERR:
|
case CMD_SW_ERR:
|
||||||
s_cmd->mode = SHOOT_MODE_SAFE;
|
s_cmd->mode = SHOOT_MODE_SAFE;
|
||||||
@ -195,7 +191,6 @@ int8_t CMD_CtrlSet(Chassis_CMD_t *c_cmd, const CMD_RC_t *rc, Gimbal_CMD_t *g_cmd
|
|||||||
}
|
}
|
||||||
switch(rc->ET16s.key_D)
|
switch(rc->ET16s.key_D)
|
||||||
{
|
{
|
||||||
|
|
||||||
case CMD_SW_UP:
|
case CMD_SW_UP:
|
||||||
s_cmd->firecmd = false;
|
s_cmd->firecmd = false;
|
||||||
s_cmd->ready = false;
|
s_cmd->ready = false;
|
||||||
|
|||||||
@ -126,14 +126,8 @@ typedef enum {
|
|||||||
SHOOT_MODE_NUM
|
SHOOT_MODE_NUM
|
||||||
}Shoot_Mode_t;
|
}Shoot_Mode_t;
|
||||||
|
|
||||||
typedef enum{
|
|
||||||
SHOOT_REMOTE,
|
|
||||||
SHOOT_AI
|
|
||||||
}Shoot_CONTROL_Mode_t;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Shoot_Mode_t mode;/* 射击模式 */
|
Shoot_Mode_t mode;/* 射击模式 */
|
||||||
Shoot_CONTROL_Mode_t control_mode;
|
|
||||||
bool ready; /* 准备射击 */
|
bool ready; /* 准备射击 */
|
||||||
bool firecmd; /* 射击 */
|
bool firecmd; /* 射击 */
|
||||||
}Shoot_CMD_t;
|
}Shoot_CMD_t;
|
||||||
|
|||||||
@ -165,19 +165,10 @@ static const Config_Param_t config = {
|
|||||||
// .d_cutoff_freq = 0.0f,
|
// .d_cutoff_freq = 0.0f,
|
||||||
// .range = M_2PI
|
// .range = M_2PI
|
||||||
/*上面一组pid会导致电机超调,可能是因为pid计算错误,正在进行重新修改pid*/
|
/*上面一组pid会导致电机超调,可能是因为pid计算错误,正在进行重新修改pid*/
|
||||||
// .k = 2.0f,
|
|
||||||
// .p = 5.0f,
|
|
||||||
// .i = 0.0f,
|
|
||||||
// .d = 0.0f,
|
|
||||||
// .i_limit = 1.0f,
|
|
||||||
// .out_limit = 10.0f,
|
|
||||||
// .d_cutoff_freq = 0.0f,
|
|
||||||
// .range = M_2PI
|
|
||||||
|
|
||||||
.k = 2.0f,
|
.k = 2.0f,
|
||||||
.p = 7.0f,
|
.p = 5.0f,
|
||||||
.i = 0.5f,
|
.i = 0.0f,
|
||||||
.d = 1.0f,
|
.d = 0.0f,
|
||||||
.i_limit = 1.0f,
|
.i_limit = 1.0f,
|
||||||
.out_limit = 10.0f,
|
.out_limit = 10.0f,
|
||||||
.d_cutoff_freq = 0.0f,
|
.d_cutoff_freq = 0.0f,
|
||||||
@ -194,17 +185,8 @@ static const Config_Param_t config = {
|
|||||||
// .d_cutoff_freq = -1.0f,
|
// .d_cutoff_freq = -1.0f,
|
||||||
// .range = -1.0f
|
// .range = -1.0f
|
||||||
|
|
||||||
// .k = 0.35f,
|
|
||||||
// .p = 0.3f,
|
|
||||||
// .i = 0.0f,
|
|
||||||
// .d = 0.0f,
|
|
||||||
// .i_limit = 1.0f,
|
|
||||||
// .out_limit = 1.0f,
|
|
||||||
// .d_cutoff_freq = -1.0f,
|
|
||||||
// .range = -1.0f
|
|
||||||
|
|
||||||
.k = 0.35f,
|
.k = 0.35f,
|
||||||
.p = 0.35f,
|
.p = 0.3f,
|
||||||
.i = 0.0f,
|
.i = 0.0f,
|
||||||
.d = 0.0f,
|
.d = 0.0f,
|
||||||
.i_limit = 1.0f,
|
.i_limit = 1.0f,
|
||||||
@ -240,8 +222,8 @@ static const Config_Param_t config = {
|
|||||||
.basic.extra_deceleration_ratio = 1,
|
.basic.extra_deceleration_ratio = 1,
|
||||||
.basic.ratio_multilevel[0] = 1.0f,
|
.basic.ratio_multilevel[0] = 1.0f,
|
||||||
.basic.num_trig_tooth = 8,
|
.basic.num_trig_tooth = 8,
|
||||||
.basic.shot_freq = 5.0f,
|
.basic.shot_freq = 20.0f,
|
||||||
.basic.shot_burst_num = 1,
|
.basic.shot_burst_num = 5,
|
||||||
|
|
||||||
.jamDetection.enable = true,
|
.jamDetection.enable = true,
|
||||||
.jamDetection.threshold = 120.0f,
|
.jamDetection.threshold = 120.0f,
|
||||||
@ -271,8 +253,8 @@ static const Config_Param_t config = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
.trig_2006={
|
.trig_2006={
|
||||||
.k=0.7f,
|
.k=0.5f,
|
||||||
.p=0.7f,
|
.p=0.5f,
|
||||||
.i=0.5f,
|
.i=0.5f,
|
||||||
.d=0.05f,
|
.d=0.05f,
|
||||||
.i_limit=0.2f,
|
.i_limit=0.2f,
|
||||||
|
|||||||
@ -377,7 +377,7 @@ void Gimbal_Output(Gimbal_t *g)
|
|||||||
|
|
||||||
MOTOR_MIT_Output_t output_yaw_4310 = {0};
|
MOTOR_MIT_Output_t output_yaw_4310 = {0};
|
||||||
output_yaw_4310.torque = g->out.yaw_4310 * 1.0f;
|
output_yaw_4310.torque = g->out.yaw_4310 * 1.0f;
|
||||||
output_yaw_4310.kd = 0.2f;
|
output_yaw_4310.kd = 0.1f;
|
||||||
// output_yaw_4310.kd=0.1f;
|
// output_yaw_4310.kd=0.1f;
|
||||||
|
|
||||||
MOTOR_MIT_Output_t output_pitch_4310 = {0};
|
MOTOR_MIT_Output_t output_pitch_4310 = {0};
|
||||||
|
|||||||
@ -6,9 +6,6 @@
|
|||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include "task/user_task.h"
|
#include "task/user_task.h"
|
||||||
/* USER INCLUDE BEGIN */
|
/* USER INCLUDE BEGIN */
|
||||||
#include "bsp/can.h"
|
|
||||||
#include "device/motor_rm.h"
|
|
||||||
#include "component/pid.h"
|
|
||||||
|
|
||||||
/* USER INCLUDE END */
|
/* USER INCLUDE END */
|
||||||
|
|
||||||
@ -17,57 +14,7 @@
|
|||||||
/* Private macro ------------------------------------------------------------ */
|
/* Private macro ------------------------------------------------------------ */
|
||||||
/* Private variables -------------------------------------------------------- */
|
/* Private variables -------------------------------------------------------- */
|
||||||
/* USER STRUCT BEGIN */
|
/* USER STRUCT BEGIN */
|
||||||
MOTOR_RM_t motor_6020;
|
|
||||||
MOTOR_RM_t motor_3508;
|
|
||||||
MOTOR_RM_Param_t motor_6020_param = {
|
|
||||||
.can = BSP_CAN_1,
|
|
||||||
.id = 0x205,
|
|
||||||
.module = MOTOR_GM6020,
|
|
||||||
.reverse = false,
|
|
||||||
.gear = false,
|
|
||||||
};
|
|
||||||
MOTOR_RM_Param_t motor_3508_param = {
|
|
||||||
.can = BSP_CAN_1,
|
|
||||||
.id = 0x201,
|
|
||||||
.module = MOTOR_M3508,
|
|
||||||
.reverse = false,
|
|
||||||
.gear = false,
|
|
||||||
};
|
|
||||||
|
|
||||||
KPID_t motor_6020_speed;
|
|
||||||
KPID_t motor_3508_angle;
|
|
||||||
KPID_t motor_3508_omega;
|
|
||||||
|
|
||||||
KPID_Params_t motor_6020_speed_param = {
|
|
||||||
.k = 0.1f,
|
|
||||||
.p = 0.2f,
|
|
||||||
.i = 0.1f,
|
|
||||||
.d = 0.0f,
|
|
||||||
.i_limit = 1.0f,
|
|
||||||
.out_limit = 1.0f,
|
|
||||||
.d_cutoff_freq = 30.0f,
|
|
||||||
};
|
|
||||||
KPID_Params_t motor_3508_angle_param = {
|
|
||||||
.k = 1.0f,
|
|
||||||
.p = 5.0f,
|
|
||||||
.i = 0.1f,
|
|
||||||
.d = 0.0f,
|
|
||||||
.i_limit = 1.0f,
|
|
||||||
.out_limit = 1.0f,
|
|
||||||
.d_cutoff_freq = 30.0f,
|
|
||||||
};
|
|
||||||
KPID_Params_t motor_3508_omega_param = {
|
|
||||||
.k = 1.0f,
|
|
||||||
.p = 5.0f,
|
|
||||||
.i = 0.1f,
|
|
||||||
.d = 0.0f,
|
|
||||||
.i_limit = 1.0f,
|
|
||||||
.out_limit = 1.0f,
|
|
||||||
.d_cutoff_freq = 30.0f,
|
|
||||||
};
|
|
||||||
|
|
||||||
float motor_3508_target_angle = 5*M_2PI;
|
|
||||||
float motor_6020_target_speed = 33.0f;
|
|
||||||
/* USER STRUCT END */
|
/* USER STRUCT END */
|
||||||
|
|
||||||
/* Private function --------------------------------------------------------- */
|
/* Private function --------------------------------------------------------- */
|
||||||
@ -83,34 +30,13 @@ void Task_Task8(void *argument) {
|
|||||||
|
|
||||||
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
||||||
/* USER CODE INIT BEGIN */
|
/* USER CODE INIT BEGIN */
|
||||||
BSP_CAN_Init();
|
|
||||||
MOTOR_RM_Register( &motor_6020_param);
|
|
||||||
MOTOR_RM_Register(&motor_3508_param);
|
|
||||||
|
|
||||||
PID_Init(&motor_6020_speed, KPID_MODE_CALC_D, TASK8_FREQ, &motor_6020_speed_param);
|
|
||||||
PID_Init(&motor_3508_angle, KPID_MODE_NO_D, TASK8_FREQ, &motor_3508_angle_param);
|
|
||||||
PID_Init(&motor_3508_omega, KPID_MODE_NO_D, TASK8_FREQ, &motor_3508_omega_param);
|
|
||||||
/* USER CODE INIT END */
|
/* USER CODE INIT END */
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||||
/* USER CODE BEGIN */
|
/* USER CODE BEGIN */
|
||||||
MOTOR_RM_UpdateAll();
|
|
||||||
|
|
||||||
motor_6020.feedback.rotor_speed= (MOTOR_GetRotorSpeed(&(MOTOR_RM_GetMotor(&motor_6020_param)->motor)) );
|
|
||||||
motor_3508.feedback.rotor_abs_angle= MOTOR_RM_GetMotor(&motor_3508_param)->gearbox_total_angle;
|
|
||||||
motor_3508.feedback.rotor_speed= (MOTOR_GetRotorSpeed(&(MOTOR_RM_GetMotor(&motor_3508_param)->motor)) );
|
|
||||||
|
|
||||||
|
|
||||||
float motor_6020out,motor_3508_ommega,motor_3508_out;
|
|
||||||
|
|
||||||
motor_6020out = PID_Calc(&motor_6020_speed, motor_6020_target_speed, motor_6020.feedback.rotor_speed, 0.0f,0.0f);
|
|
||||||
|
|
||||||
// motor_3508_ommega = PID_Calc(&motor_3508_omega, motor_3508_target_angle, motor_3508.feedback.rotor_abs_angle, 0.0f,0.0f);
|
|
||||||
// motor_3508_out = PID_Calc(&motor_3508_angle, motor_3508_ommega, motor_3508.feedback.rotor_speed, 0.0f,0.0f);
|
|
||||||
|
|
||||||
MOTOR_RM_SetOutput(&motor_6020_param, motor_6020out);
|
|
||||||
MOTOR_RM_Ctrl(&motor_6020_param);
|
|
||||||
/* USER CODE END */
|
/* USER CODE END */
|
||||||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,9 +49,6 @@ void Task_ai(void *argument) {
|
|||||||
AI_Get_NUC(&ai,&ai_cmd);
|
AI_Get_NUC(&ai,&ai_cmd);
|
||||||
osMessageQueueReset(task_runtime.msgq.gimbal.ai.g_cmd);
|
osMessageQueueReset(task_runtime.msgq.gimbal.ai.g_cmd);
|
||||||
osMessageQueuePut(task_runtime.msgq.gimbal.ai.g_cmd, &ai_cmd, 0, 0);
|
osMessageQueuePut(task_runtime.msgq.gimbal.ai.g_cmd, &ai_cmd, 0, 0);
|
||||||
|
|
||||||
osMessageQueueReset(task_runtime.msgq.gimbal.ai.s_cmd);
|
|
||||||
osMessageQueuePut(task_runtime.msgq.gimbal.ai.s_cmd, &ai_cmd, 0, 0);
|
|
||||||
/* USER CODE END */
|
/* USER CODE END */
|
||||||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,7 @@ void Task_Init(void *argument) {
|
|||||||
task_runtime.thread.gimbal = osThreadNew(Task_gimbal, NULL, &attr_gimbal);
|
task_runtime.thread.gimbal = osThreadNew(Task_gimbal, NULL, &attr_gimbal);
|
||||||
task_runtime.thread.shoot = osThreadNew(Task_shoot, NULL, &attr_shoot);
|
task_runtime.thread.shoot = osThreadNew(Task_shoot, NULL, &attr_shoot);
|
||||||
task_runtime.thread.ai = osThreadNew(Task_ai, NULL, &attr_ai);
|
task_runtime.thread.ai = osThreadNew(Task_ai, NULL, &attr_ai);
|
||||||
// task_runtime.thread.Task8 = osThreadNew(Task_Task8, NULL, &attr_Task8);
|
task_runtime.thread.Task8 = osThreadNew(Task_Task8, NULL, &attr_Task8);
|
||||||
|
|
||||||
// 创建消息队列
|
// 创建消息队列
|
||||||
/* USER MESSAGE BEGIN */
|
/* USER MESSAGE BEGIN */
|
||||||
@ -54,7 +54,7 @@ void Task_Init(void *argument) {
|
|||||||
task_runtime.msgq.shoot.cmd = osMessageQueueNew(2u, sizeof(Shoot_CMD_t),NULL);
|
task_runtime.msgq.shoot.cmd = osMessageQueueNew(2u, sizeof(Shoot_CMD_t),NULL);
|
||||||
task_runtime.msgq.gimbal.ai.feedback = osMessageQueueNew(2u, sizeof(Gimbal_feedback_t),NULL);
|
task_runtime.msgq.gimbal.ai.feedback = osMessageQueueNew(2u, sizeof(Gimbal_feedback_t),NULL);
|
||||||
task_runtime.msgq.gimbal.ai.g_cmd = osMessageQueueNew(2u, sizeof(AI_cmd_t),NULL);
|
task_runtime.msgq.gimbal.ai.g_cmd = osMessageQueueNew(2u, sizeof(AI_cmd_t),NULL);
|
||||||
task_runtime.msgq.gimbal.ai.s_cmd = osMessageQueueNew(2u, sizeof(AI_cmd_t),NULL);
|
|
||||||
/* USER MESSAGE END */
|
/* USER MESSAGE END */
|
||||||
|
|
||||||
osKernelUnlock(); // 解锁内核
|
osKernelUnlock(); // 解锁内核
|
||||||
|
|||||||
@ -4,12 +4,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include "module/cmd.h"
|
|
||||||
#include "task/user_task.h"
|
#include "task/user_task.h"
|
||||||
/* USER INCLUDE BEGIN */
|
/* USER INCLUDE BEGIN */
|
||||||
#include "module/shoot.h"
|
#include "module/shoot.h"
|
||||||
#include "module/config.h"
|
#include "module/config.h"
|
||||||
#include "device/ai.h"
|
|
||||||
/* USER INCLUDE END */
|
/* USER INCLUDE END */
|
||||||
|
|
||||||
/* Private typedef ---------------------------------------------------------- */
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
@ -19,7 +18,6 @@
|
|||||||
/* USER STRUCT BEGIN */
|
/* USER STRUCT BEGIN */
|
||||||
Shoot_t shoot;
|
Shoot_t shoot;
|
||||||
Shoot_CMD_t shoot_cmd;
|
Shoot_CMD_t shoot_cmd;
|
||||||
AI_cmd_t shoot_ai_cmd;
|
|
||||||
/* USER STRUCT END */
|
/* USER STRUCT END */
|
||||||
|
|
||||||
/* Private function --------------------------------------------------------- */
|
/* Private function --------------------------------------------------------- */
|
||||||
@ -44,28 +42,8 @@ Shoot_SetMode(&shoot,SHOOT_MODE_SINGLE);
|
|||||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||||
/* USER CODE BEGIN */
|
/* USER CODE BEGIN */
|
||||||
osMessageQueueGet(task_runtime.msgq.shoot.cmd, &shoot_cmd, NULL, 0);
|
osMessageQueueGet(task_runtime.msgq.shoot.cmd, &shoot_cmd, NULL, 0);
|
||||||
osMessageQueueGet(task_runtime.msgq.gimbal.ai.s_cmd, &shoot_ai_cmd, NULL, 0);
|
|
||||||
|
|
||||||
if(shoot_cmd.control_mode==SHOOT_REMOTE)
|
|
||||||
{
|
|
||||||
//do nothing,使用遥控器的指令
|
|
||||||
}
|
|
||||||
else if(shoot_cmd.control_mode==SHOOT_AI)
|
|
||||||
{
|
|
||||||
shoot_cmd.mode = SHOOT_MODE_SINGLE;
|
|
||||||
if(shoot_ai_cmd.mode==0 || shoot_ai_cmd.mode==1)
|
|
||||||
{
|
|
||||||
shoot_cmd.firecmd=false;
|
|
||||||
shoot_cmd.ready=true;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(shoot_ai_cmd.mode==2)
|
|
||||||
{
|
|
||||||
|
|
||||||
shoot_cmd.firecmd=true;
|
|
||||||
shoot_cmd.ready=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Shoot_UpdateFeedback(&shoot);
|
Shoot_UpdateFeedback(&shoot);
|
||||||
Shoot_SetMode(&shoot,shoot_cmd.mode);
|
Shoot_SetMode(&shoot,shoot_cmd.mode);
|
||||||
|
|||||||
@ -91,7 +91,6 @@ typedef struct {
|
|||||||
osMessageQueueId_t quat;
|
osMessageQueueId_t quat;
|
||||||
osMessageQueueId_t feedback;
|
osMessageQueueId_t feedback;
|
||||||
osMessageQueueId_t g_cmd;
|
osMessageQueueId_t g_cmd;
|
||||||
osMessageQueueId_t s_cmd;
|
|
||||||
}ai;
|
}ai;
|
||||||
/* 新增的 ai 消息队列 主要是给自瞄*/
|
/* 新增的 ai 消息队列 主要是给自瞄*/
|
||||||
} gimbal;
|
} gimbal;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user